On Sat, Oct 03, 2015 at 04:29:23PM +0200, Jean-Yves Migeon wrote: > Le 03/10/2015 15:45, Joerg Sonnenberger a écrit : > > On Sat, Oct 03, 2015 at 02:46:26PM +0200, Maxime Villard wrote: > >> You can see that the pointer given to kmem_free() is not the one kmem_alloc > >> returned. Actually, I don't understand at all what this code is supposed to > >> do. Found by Brainy. > > > > It tries to make sure the pointer has a certain alignment. ...which > > likely is something we do by default, so this is not really visible. > > Regarding kmem_alloc(9) this is not necessarily true, the allocator > "steals" the first few bytes of the allocation to store the requested > size (see the KMEM_SIZE option in [1] which is enabled under DIAGNOSTIC).
That's not really relevant. For 64bit architectures for example, all allocations must be 64bit aligned otherwise you can run into issues down the line. I think we effectively guarantee 128bit alignment for all allocations at least that size, but I don't know for sure. That still means that the original pointer should be remembered, but the way to require alignment is sane. Joerg