On Wed, 2008-11-05 at 14:02 +0000, Mel Gorman wrote:
> @@ -127,6 +140,34 @@ void *get_huge_pages(size_t len, ghp_t flags)
>               return NULL;
>       }
> 
> +offset:

This cache-coloring code (below) is nice.  Could we move it into it's
own function though?  I like the idea of caching the sysconf value, but
perhaps you could do that as a static variable within the new function.

> +     /*
> +      * Offset the buffer using wasted bytes to avoid using the same
> +      * cache lines for the start of every buffer returned by
> +      * get_huge_pages(). An small effort is made to select a random
> +      * cacheline rather than sequential onces to give decent behaviour
> +      * on average.
> +      */
> +     if (!(flags & GHP_ALIGN)) {
> +             char *bytebuf = (char *)buf;
> +             int numlines = wasteage / cacheline_size;
> +             int line = 0;
> +
> +             DEBUG("%d lines of cacheline size %ld due to %zd wastage\n",
> +                     numlines, cacheline_size, wasteage);
> +
> +             if (numlines) {
> +                     line = linemod % numlines;
> +                     bytebuf += cacheline_size * line;
> +
> +                     /* Pseudo-ish random line selection */
> +                     linemod += len % numlines;
> +             }
> +             DEBUG("Using line offset %d from start\n", line);
> +
> +             buf = (void *)bytebuf;
> +     }
> +
>       /* woo, new buffer of shiny */
>       return buf;
>  }

-- 
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to