diff mbox series

lib: compile memcat_p only when needed

Message ID 20201117173828.27292-1-info@metux.net
State Superseded
Headers show
Series lib: compile memcat_p only when needed | expand

Commit Message

Enrico Weigelt, metux IT consult Nov. 17, 2020, 5:38 p.m. UTC
The library function memcat_p() is currently used only once.
(drivers/hwtracing/stm). So, often completely unused.

Reducing the kernel size by about 4k by compiling it
conditionally, only when needed.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
 drivers/hwtracing/stm/Kconfig | 1 +
 lib/Kconfig                   | 3 +++
 lib/Kconfig.debug             | 1 +
 lib/Makefile                  | 4 +++-
 4 files changed, 8 insertions(+), 1 deletion(-)

Comments

Nick Desaulniers Nov. 17, 2020, 6:33 p.m. UTC | #1
On Tue, Nov 17, 2020 at 9:38 AM Enrico Weigelt, metux IT consult
<info@metux.net> wrote:
>
> The library function memcat_p() is currently used only once.
> (drivers/hwtracing/stm). So, often completely unused.

Any harm in just moving the definition into drivers/hwtracing/stm?
Then we don't need any Kconfig additions.  There never were many users
of this function, and there probably never will be.

>
> Reducing the kernel size by about 4k by compiling it
> conditionally, only when needed.
>
> Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
> ---
>  drivers/hwtracing/stm/Kconfig | 1 +
>  lib/Kconfig                   | 3 +++
>  lib/Kconfig.debug             | 1 +
>  lib/Makefile                  | 4 +++-
>  4 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/stm/Kconfig b/drivers/hwtracing/stm/Kconfig
> index aad594fe79cc..8ce5cfd759d1 100644
> --- a/drivers/hwtracing/stm/Kconfig
> +++ b/drivers/hwtracing/stm/Kconfig
> @@ -3,6 +3,7 @@ config STM
>         tristate "System Trace Module devices"
>         select CONFIGFS_FS
>         select SRCU
> +       select GENERIC_LIB_MEMCAT_P
>         help
>           A System Trace Module (STM) is a device exporting data in System
>           Trace Protocol (STP) format as defined by MIPI STP standards.
> diff --git a/lib/Kconfig b/lib/Kconfig
> index b46a9fd122c8..b42ed8d68937 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -686,6 +686,9 @@ config GENERIC_LIB_CMPDI2
>  config GENERIC_LIB_UCMPDI2
>         bool
>
> +config GENERIC_LIB_MEMCAT_P
> +       tristate
> +
>  config PLDMFW
>         bool
>         default n
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index c789b39ed527..beb5adb2f0b7 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -2334,6 +2334,7 @@ config TEST_DEBUG_VIRTUAL
>
>  config TEST_MEMCAT_P
>         tristate "Test memcat_p() helper function"
> +       select GENERIC_LIB_MEMCAT_P
>         help
>           Test the memcat_p() helper for correctly merging two
>           pointer arrays together.
> diff --git a/lib/Makefile b/lib/Makefile
> index ce45af50983a..18fd6630be0b 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -36,7 +36,9 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
>          flex_proportions.o ratelimit.o show_mem.o \
>          is_single_threaded.o plist.o decompress.o kobject_uevent.o \
>          earlycpio.o seq_buf.o siphash.o dec_and_lock.o \
> -        nmi_backtrace.o nodemask.o win_minmax.o memcat_p.o
> +        nmi_backtrace.o nodemask.o win_minmax.o
> +
> +obj-$(CONFIG_GENERIC_LIB_MEMCAT_P) += memcat_p.o
>
>  lib-$(CONFIG_PRINTK) += dump_stack.o
>  lib-$(CONFIG_SMP) += cpumask.o
> --
> 2.11.0
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20201117173828.27292-1-info%40metux.net.
diff mbox series

Patch

diff --git a/drivers/hwtracing/stm/Kconfig b/drivers/hwtracing/stm/Kconfig
index aad594fe79cc..8ce5cfd759d1 100644
--- a/drivers/hwtracing/stm/Kconfig
+++ b/drivers/hwtracing/stm/Kconfig
@@ -3,6 +3,7 @@  config STM
 	tristate "System Trace Module devices"
 	select CONFIGFS_FS
 	select SRCU
+	select GENERIC_LIB_MEMCAT_P
 	help
 	  A System Trace Module (STM) is a device exporting data in System
 	  Trace Protocol (STP) format as defined by MIPI STP standards.
diff --git a/lib/Kconfig b/lib/Kconfig
index b46a9fd122c8..b42ed8d68937 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -686,6 +686,9 @@  config GENERIC_LIB_CMPDI2
 config GENERIC_LIB_UCMPDI2
 	bool
 
+config GENERIC_LIB_MEMCAT_P
+	tristate
+
 config PLDMFW
 	bool
 	default n
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index c789b39ed527..beb5adb2f0b7 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -2334,6 +2334,7 @@  config TEST_DEBUG_VIRTUAL
 
 config TEST_MEMCAT_P
 	tristate "Test memcat_p() helper function"
+	select GENERIC_LIB_MEMCAT_P
 	help
 	  Test the memcat_p() helper for correctly merging two
 	  pointer arrays together.
diff --git a/lib/Makefile b/lib/Makefile
index ce45af50983a..18fd6630be0b 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -36,7 +36,9 @@  lib-y := ctype.o string.o vsprintf.o cmdline.o \
 	 flex_proportions.o ratelimit.o show_mem.o \
 	 is_single_threaded.o plist.o decompress.o kobject_uevent.o \
 	 earlycpio.o seq_buf.o siphash.o dec_and_lock.o \
-	 nmi_backtrace.o nodemask.o win_minmax.o memcat_p.o
+	 nmi_backtrace.o nodemask.o win_minmax.o
+
+obj-$(CONFIG_GENERIC_LIB_MEMCAT_P) += memcat_p.o
 
 lib-$(CONFIG_PRINTK) += dump_stack.o
 lib-$(CONFIG_SMP) += cpumask.o