Re: [Patch] Cacheline align xlog_t

Andi Kleen
2008-04-03T06:42:20Z

On Thu, Apr 03, 2008 at 08:23:47AM +1000, David Chinner wrote:
> > For the dynamic allocation you would rather need to make sure it
> > starts at a cache line boundary explicitely because the allocator doesn't
> > know the alignment of the target type, otherwise your careful
> > padding might be useless.
>
> Yup. Is there an allocator function gives us cacheline aligned
> allocation

__get_free_pages() @) [ok not serious]

> (apart from a slab initialised with SLAB_HWCACHE_ALIGN)?

That too yes.

> There isn't one, right?

You can always align yourself with kmalloc (or any other arbitary
size allocator) with the standard technique:
get L1_CACHE_BYTES-1 or possibly better cache_line_size() - 1 bytes
more and then align the pointer manually with ALIGN. Only tricky part
is that you have to undo the alignment before freeing.

-Andi