Re: [PATCH] mm: Functions used internally should not be put into
From: Vlastimil Babka
Date: Tue Jan 17 2023 - 07:59:32 EST
On 1/17/23 03:01, Rong Tao wrote:
Hi, dear Hyeonggon.
If sl*b_def.h is not intended to be used externally. That is to say we should
never include sl*b_def.h in module? The following code will not compile success
since commit 40f3bf0cb04c("mm: Convert struct page to struct slab in functions
used by other subsystems"), but success in older kernel. Especially for modules
that use the kmem_cache structure, this is catastrophic.
If such module was part of the Linux tree, breaking it would be noticed
sooner and fixed, probably by changing the include to "mm/slab.h"
instead of sl*b_def
...
You are right, if sl*b_def.h is not intended to used externally, Modules that
use kmem_cache structures should not be designed from the outset to use
kmem_cache structures. Or the kernel can use this patch, and these modules can
be compiled successfully.
For out of tree modules we can't make any guarantees. It's best for
those if they don't rely on such specifics. As Hyeonggon pointed out,
there are more robust ways to get object layout than including kernel
headers. Also it was broken since 5.17, which is quite some time ago. Is
the code you're fixing still relevant or was replaced with something
based on BTF already?
Best wishes.
Rong Tao