OSDN Git Service

mm/slub: Define struct slab fields for CONFIG_SLUB_CPU_PARTIAL only when enabled
authorVlastimil Babka <vbabka@suse.cz>
Wed, 10 Nov 2021 13:12:45 +0000 (14:12 +0100)
committerVlastimil Babka <vbabka@suse.cz>
Thu, 6 Jan 2022 11:26:53 +0000 (12:26 +0100)
commit9c01e9af171f13cf6573f404ecaf96dfa48233ab
tree1af8f4560e4f707a0587cd9febe0ac34605f3abd
parent662188c3a20eba75babc5a910a5f1b4278069f85
mm/slub: Define struct slab fields for CONFIG_SLUB_CPU_PARTIAL only when enabled

The fields 'next' and 'slabs' are only used when CONFIG_SLUB_CPU_PARTIAL
is enabled. We can put their definition to #ifdef to prevent accidental
use when disabled.

Currenlty show_slab_objects() and slabs_cpu_partial_show() contain code
accessing the slabs field that's effectively dead with
CONFIG_SLUB_CPU_PARTIAL=n through the wrappers slub_percpu_partial() and
slub_percpu_partial_read_once(), but to prevent a compile error, we need
to hide all this code behind #ifdef.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Reviewed-by: Roman Gushchin <guro@fb.com>
Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
mm/slab.h
mm/slub.c