在 2021/4/2 22:41, Matthew Wilcox 写道:
On Fri, Apr 02, 2021 at 09:45:12AM +0200, Greg KH wrote:
Why is the buffer alignment considered a "waste" here? If that change
is in Linus's tree and newer kernels (it showed up in 5.4 which was
released quite a while ago), where are the people complaining about it
there?
I think backporting 59bb47985c1d ("mm, sl[aou]b: guarantee natural
alignment for kmalloc(power-of-two)") seems like the correct thing to do
here to bring things into alignment (pun intended) with newer kernels.
It's only a waste for slabs which need things like redzones (eg we could
get 7 512-byte allocations out of a 4kB page with a 64 byte redzone
and no alignment ; with alignment we can only get four). Since slub
can enable/disable redzones on a per-slab basis, and redzones aren't
terribly interesting now that we have kasan/kfence, nobody really cares.
.
Thanks for your explain! The imfluence seems minimal since the "waste"
will happen only when we enable slub_debug.
One more question for Joe Perches. Patch v2[1] does not add the
alignment check for buf and we add it in v3[2]. I don't see the
necessity for this check... Can you help to explain that why we need this?
Thanks,
Kun.
[1].
https://lore.kernel.org/lkml/a9054fb521e65f2809671fa9c18e2453061e9d91.1598744610.git.joe@xxxxxxxxxxx/
[2].
https://lore.kernel.org/lkml/743a648dc817cddd2e7046283c868f1c08742f29.camel@xxxxxxxxxxx/