[PATCH 08/14] lib/Kconfig: introduce FAST_PATH option

From: Yury Norov
Date: Wed Feb 17 2021 - 23:10:16 EST


This series introduces fast paths for find_bit() routines. It is
beneficial for typical systems, but those who limited in I-cache
may be concerned about increasing the .text size of the Image.

To address this concern, one can disable FAST_PATH option in the config
and some save memory.

The effect of this option on my arm64 next-20210217 build is:

Before:
Sections:
Idx Name Size VMA LMA File off Algn
0 .head.text 00010000 ffff800010000000 ffff800010000000 00010000 2**16
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .text 0115e3a8 ffff800010010000 ffff800010010000 00020000 2**16
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .got.plt 00000018 ffff80001116e3a8 ffff80001116e3a8 0117e3a8 2**3
CONTENTS, ALLOC, LOAD, DATA
3 .rodata 007a72ca ffff800011170000 ffff800011170000 01180000 2**12
CONTENTS, ALLOC, LOAD, DATA
...

After:
Sections:
Idx Name Size VMA LMA File off Algn
0 .head.text 00010000 ffff800010000000 ffff800010000000 00010000 2**16
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .text 011623a8 ffff800010010000 ffff800010010000 00020000 2**16
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .got.plt 00000018 ffff8000111723a8 ffff8000111723a8 011823a8 2**3
CONTENTS, ALLOC, LOAD, DATA
3 .rodata 007a772a ffff800011180000 ffff800011180000 01190000 2**12
CONTENTS, ALLOC, LOAD, DATA
...

Notice that this is the cumulive effect on already existing fast paths
controlled by SMALL_CONST() together with ones added by this series.

Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx>
---
include/asm-generic/bitsperlong.h | 4 ++++
lib/Kconfig | 7 +++++++
2 files changed, 11 insertions(+)

diff --git a/include/asm-generic/bitsperlong.h b/include/asm-generic/bitsperlong.h
index 0eeb77544f1d..209e531074c1 100644
--- a/include/asm-generic/bitsperlong.h
+++ b/include/asm-generic/bitsperlong.h
@@ -23,6 +23,10 @@
#define BITS_PER_LONG_LONG 64
#endif

+#ifdef CONFIG_FAST_PATH
#define SMALL_CONST(n) (__builtin_constant_p(n) && (unsigned long)(n) < BITS_PER_LONG)
+#else
+#define SMALL_CONST(n) (0)
+#endif

#endif /* __ASM_GENERIC_BITS_PER_LONG */
diff --git a/lib/Kconfig b/lib/Kconfig
index a38cc61256f1..7a1b9c8d2a32 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -39,6 +39,13 @@ config PACKING

When in doubt, say N.

+config FAST_PATH
+ bool "Enable fast path code generation"
+ default y
+ help
+ This option enables fast path optimization with the cost of increasing
+ the text section.
+
config BITREVERSE
tristate

--
2.25.1