Re: [PATCH] mm: Functions used internally should not be put into

From: Rong Tao
Date: Mon Jan 16 2023 - 21:01:48 EST


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.

#include <linux/init.h>
#include <linux/printk.h>
#include <linux/slab.h>
#include <linux/slab_def.h>

static int kernel_init(void)
{
printk(KERN_INFO "my init.\n");
return 0;
}

static void kernel_exit(void)
{
printk(KERN_INFO "my exit.\n");
}

module_init(kernel_init);
module_exit(kernel_exit);

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.

Best wishes.

Rong Tao