Re: [PATCH] 2.5.21 Nonlinear CPU support

From: Andreas Dilger (adilger@clusterfs.com)
Date: Wed Jun 12 2002 - 16:03:56 EST


On Jun 12, 2002 21:41 +0100, Anton Altaparmakov wrote:
> At 20:39 12/06/02, Andreas Dilger wrote:
> >At most you
> >will need to loop once for each available CPU if you are unlucky enough
> >to be rescheduled to a different CPU after each call to vmalloc().
>
> Um are you suggesting compression buffers to be per mounted volume? That
> would be more wasteful than the current approach of one buffer per CPU
> globally for all of ntfs driver.

No, my mistake. You should check whatever array you want.

> vfree() at a guess (I may be completely wrong on that one in which case I
> appologize!) can also sleep so that breaks that scheme.

Well, just get rid of the while loop then and use an if+goto for both
the vmalloc and the vfree case. At most we can loop NR_CPUS times.

        char *newbuf = NULL;
        int cpunum;
       
recheck:
        cpunum = current_cpu();
        if (unlikely(ntfs_compr_array[cpunum] == NULL)) {
                newbuf = vmalloc(NTFS_DECOMPR_BUFFER_SIZE);

                /*
                 * Re-check the buffer case we slept in vmalloc() and
                 * someone else already allocated a buffer for "this" CPU.
                 */
                if (likely(ntfs_compr_array[cpunum] == NULL)) {
                        ntfs_compr_array[cpunum] = newbuf;
                        newbuf = NULL;
                }
                goto recheck;
        }
        /* Hmm, we slept in vmalloc and we don't need the new buffer */
        if (unlikely(newbuf != NULL)) {
                vfree(newbuf);
                goto recheck;
        }

> But if doing something like that I might as well use the present
> approach and just allocate all buffers at once if they haven't been
> allocated yet and be done with it. Then no vfree()s are needed either and
> then it really does work. (-;

But then you may be allocating a lot of memory for CPUs that don't
even exist, which is the whole point of this exercise. Better to do
it on-demand and loop for the very few times needed.

Cheers, Andreas

--
Andreas Dilger
http://www-mddsp.enel.ucalgary.ca/People/adilger/
http://sourceforge.net/projects/ext2resize/

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jun 15 2002 - 22:00:26 EST