Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lib/list_sort.c: rearrange includes

Memory allocation only happens in the self test, just as random numbers
are only used there. So move the inclusion of slab.h inside the
CONFIG_TEST_LIST_SORT.

We don't need module.h and all of the stuff it carries with it, so replace
with export.h and compiler.h. Unfortunately, the ARRAY_SIZE macro from
kernel.h requires the user to ensure bug.h is also included (for
BUILD_BUG_ON_ZERO, used by __must_be_array). We used to get that through
some maze of nested includes, but just include it explicitly.

linux/string.h is then only included implicitly through
kernel.h->printk.h->dynamic_debug.h, but only if !CONFIG_DYNAMIC_DEBUG, so
just include it explicitly (for memset).

objdump -d says the generated code is the same, and wc -l says that
lib/.list_sort.o.cmd went from 579 to 165 lines.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Rasmus Villemoes and committed by
Linus Torvalds
7259fa04 18fa6d2e

+5 -2
+5 -2
lib/list_sort.c
··· 2 2 #define pr_fmt(fmt) "list_sort_test: " fmt 3 3 4 4 #include <linux/kernel.h> 5 - #include <linux/module.h> 5 + #include <linux/bug.h> 6 + #include <linux/compiler.h> 7 + #include <linux/export.h> 8 + #include <linux/string.h> 6 9 #include <linux/list_sort.h> 7 - #include <linux/slab.h> 8 10 #include <linux/list.h> 9 11 10 12 #define MAX_LIST_LENGTH_BITS 20 ··· 148 146 149 147 #ifdef CONFIG_TEST_LIST_SORT 150 148 149 + #include <linux/slab.h> 151 150 #include <linux/random.h> 152 151 153 152 /*