malloc memory to be 32 byte aligned in kernel

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Tue Jan 28 20:20:31 EST 2014


On Tue, 28 Jan 2014 17:00:13 -0800, m silverstri said:
> Thanks. How big should be my  slab cache and how to allocate from that?

kmem_cache_alloc() and kmem_cache_free() are your friends.

> And to declare a struct ' __attribute__(aligned(32))'', does that mean
> I do that for every file in my struct?

I'm guessing you mean "for every field in my struct".  And the answer is
no, unless you actually need the alignment/padding for every field. You
declare the struct wrapping all the stuff you need and give that the aligned().
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140128/d609adc5/attachment.bin 


More information about the Kernelnewbies mailing list