linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib/flex_array: make build optional
@ 2014-11-06 21:27 Aristeu Rozanski
  2014-11-06 21:33 ` Dave Hansen
  2014-11-06 21:58 ` josh
  0 siblings, 2 replies; 7+ messages in thread
From: Aristeu Rozanski @ 2014-11-06 21:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Aristeu Rozanski, Changli Gao, Dave Hansen, David Rientjes,
	Eric Paris, Hannes Frederic Sowa, Jesse Gross, Jonathan Corbet,
	Paul Gortmaker, Pravin Shelar, Alexander Viro, Josh Triplett

From: Aristeu Rozanski <arozansk@redhat.com>

flex_array currently is built unconditionally:
	text    data     bss     dec     hex filename
	2294    1008    1568    4870    1306 lib/flex_array.o
	2294    1008    1568    4870    1306 (TOTALS)

and it's used by procfs, selinux and openvswitch. This patch is
useful for situations in which memory footprint is a concern and
those features aren't used.

Cc: Changli Gao <xiaosuo@gmail.com>
Cc: Dave Hansen <dave@linux.vnet.ibm.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Eric Paris <eparis@redhat.com>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Jesse Gross <jesse@nicira.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Pravin Shelar <pshelar@nicira.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
---
 fs/proc/Kconfig          |  1 +
 lib/Kconfig              | 10 ++++++++++
 lib/Makefile             |  3 ++-
 net/openvswitch/Kconfig  |  1 +
 security/selinux/Kconfig |  1 +
 5 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
index 2183fcf..2d624b7 100644
--- a/fs/proc/Kconfig
+++ b/fs/proc/Kconfig
@@ -1,6 +1,7 @@
 config PROC_FS
 	bool "/proc file system support" if EXPERT
 	default y
+	select FLEX_ARRAY
 	help
 	  This is a virtual file system providing information about the status
 	  of the system. "Virtual" means that it doesn't take up any space on
diff --git a/lib/Kconfig b/lib/Kconfig
index 54cf309..675920b 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -432,6 +432,16 @@ config GLOB_SELFTEST
 	  module load) by a small amount, so you're welcome to play with
 	  it, but you probably don't need it.
 
+config FLEX_ARRAY
+	bool "Flexible array"
+	default n
+	help
+	  This option enables an implementation of flexible arrays which
+	  allows creating arrays of fixed size elements with an arbritrary
+	  size without requiring the single allocation of a contiguous area.
+
+	  See Documentation/flexible-arrays.txt
+
 #
 # Netlink attribute parsing support is select'ed if needed
 #
diff --git a/lib/Makefile b/lib/Makefile
index 7512dc9..9c12cbc 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -24,7 +24,7 @@ obj-y	+= lockref.o
 
 obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
 	 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
-	 gcd.o lcm.o list_sort.o uuid.o flex_array.o iovec.o clz_ctz.o \
+	 gcd.o lcm.o list_sort.o uuid.o iovec.o clz_ctz.o \
 	 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o \
 	 percpu-refcount.o percpu_ida.o hash.o rhashtable.o
 obj-y += string_helpers.o
@@ -35,6 +35,7 @@ obj-$(CONFIG_TEST_LKM) += test_module.o
 obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
 obj-$(CONFIG_TEST_BPF) += test_bpf.o
 obj-$(CONFIG_TEST_FIRMWARE) += test_firmware.o
+obj-$(CONFIG_FLEX_ARRAY) += flex_array.o
 
 ifeq ($(CONFIG_DEBUG_KOBJECT),y)
 CFLAGS_kobject.o += -DDEBUG
diff --git a/net/openvswitch/Kconfig b/net/openvswitch/Kconfig
index ba3bb82..1d979ce 100644
--- a/net/openvswitch/Kconfig
+++ b/net/openvswitch/Kconfig
@@ -5,6 +5,7 @@
 config OPENVSWITCH
 	tristate "Open vSwitch"
 	select LIBCRC32C
+	select FLEX_ARRAY
 	---help---
 	  Open vSwitch is a multilayer Ethernet switch targeted at virtualized
 	  environments.  In addition to supporting a variety of features
diff --git a/security/selinux/Kconfig b/security/selinux/Kconfig
index bca1b74..cfcc7c1 100644
--- a/security/selinux/Kconfig
+++ b/security/selinux/Kconfig
@@ -2,6 +2,7 @@ config SECURITY_SELINUX
 	bool "NSA SELinux Support"
 	depends on SECURITY_NETWORK && AUDIT && NET && INET
 	select NETWORK_SECMARK
+	select FLEX_ARRAY
 	default n
 	help
 	  This selects NSA Security-Enhanced Linux (SELinux).
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] lib/flex_array: make build optional
  2014-11-06 21:27 [PATCH] lib/flex_array: make build optional Aristeu Rozanski
@ 2014-11-06 21:33 ` Dave Hansen
  2014-11-06 21:44   ` Dave Hansen
  2014-11-06 21:58 ` josh
  1 sibling, 1 reply; 7+ messages in thread
From: Dave Hansen @ 2014-11-06 21:33 UTC (permalink / raw)
  To: Aristeu Rozanski, linux-kernel
  Cc: Aristeu Rozanski, Changli Gao, Dave Hansen, David Rientjes,
	Eric Paris, Hannes Frederic Sowa, Jesse Gross, Jonathan Corbet,
	Paul Gortmaker, Pravin Shelar, Alexander Viro, Josh Triplett

On 11/06/2014 01:27 PM, Aristeu Rozanski wrote:
> +config FLEX_ARRAY
> +	bool "Flexible array"
> +	default n
> +	help
> +	  This option enables an implementation of flexible arrays which
> +	  allows creating arrays of fixed size elements with an arbritrary
> +	  size without requiring the single allocation of a contiguous area.
> +
> +	  See Documentation/flexible-arrays.txt

Is there any reason to expose this to the user via Kconfig?

No sane person would even turn it on if they don't need it.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] lib/flex_array: make build optional
  2014-11-06 21:33 ` Dave Hansen
@ 2014-11-06 21:44   ` Dave Hansen
  2014-11-06 21:50     ` Aristeu Rozanski
  0 siblings, 1 reply; 7+ messages in thread
From: Dave Hansen @ 2014-11-06 21:44 UTC (permalink / raw)
  To: Aristeu Rozanski, linux-kernel
  Cc: Aristeu Rozanski, Changli Gao, David Rientjes, Eric Paris,
	Hannes Frederic Sowa, Jesse Gross, Jonathan Corbet,
	Paul Gortmaker, Pravin Shelar, Alexander Viro, Josh Triplett

On 11/06/2014 01:33 PM, Dave Hansen wrote:
> On 11/06/2014 01:27 PM, Aristeu Rozanski wrote:
>> +config FLEX_ARRAY
>> +	bool "Flexible array"
>> +	default n
>> +	help
>> +	  This option enables an implementation of flexible arrays which
>> +	  allows creating arrays of fixed size elements with an arbritrary
>> +	  size without requiring the single allocation of a contiguous area.
>> +
>> +	  See Documentation/flexible-arrays.txt
> 
> Is there any reason to expose this to the user via Kconfig?
> 
> No sane person would even turn it on if they don't need it.

IOW, I think you should just make it:

config FLEX_ARRAY
	def_bool n


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] lib/flex_array: make build optional
  2014-11-06 21:44   ` Dave Hansen
@ 2014-11-06 21:50     ` Aristeu Rozanski
  2014-11-07  3:31       ` Josh Triplett
  0 siblings, 1 reply; 7+ messages in thread
From: Aristeu Rozanski @ 2014-11-06 21:50 UTC (permalink / raw)
  To: Dave Hansen
  Cc: linux-kernel, Changli Gao, David Rientjes, Eric Paris,
	Hannes Frederic Sowa, Jesse Gross, Jonathan Corbet,
	Paul Gortmaker, Pravin Shelar, Alexander Viro, Josh Triplett

On Thu, Nov 06, 2014 at 01:44:54PM -0800, Dave Hansen wrote:
> On 11/06/2014 01:33 PM, Dave Hansen wrote:
> > On 11/06/2014 01:27 PM, Aristeu Rozanski wrote:
> >> +config FLEX_ARRAY
> >> +	bool "Flexible array"
> >> +	default n
> >> +	help
> >> +	  This option enables an implementation of flexible arrays which
> >> +	  allows creating arrays of fixed size elements with an arbritrary
> >> +	  size without requiring the single allocation of a contiguous area.
> >> +
> >> +	  See Documentation/flexible-arrays.txt
> > 
> > Is there any reason to expose this to the user via Kconfig?
> > 
> > No sane person would even turn it on if they don't need it.
> 
> IOW, I think you should just make it:
> 
> config FLEX_ARRAY
> 	def_bool n

Joe Pershes complained on a similar patch on making it default to 'n'.
Will rework the patches this way.

-- 
Aristeu


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] lib/flex_array: make build optional
  2014-11-06 21:27 [PATCH] lib/flex_array: make build optional Aristeu Rozanski
  2014-11-06 21:33 ` Dave Hansen
@ 2014-11-06 21:58 ` josh
  1 sibling, 0 replies; 7+ messages in thread
From: josh @ 2014-11-06 21:58 UTC (permalink / raw)
  To: Aristeu Rozanski
  Cc: linux-kernel, Aristeu Rozanski, Changli Gao, Dave Hansen,
	David Rientjes, Eric Paris, Hannes Frederic Sowa, Jesse Gross,
	Jonathan Corbet, Paul Gortmaker, Pravin Shelar, Alexander Viro

On Thu, Nov 06, 2014 at 04:27:21PM -0500, Aristeu Rozanski wrote:
> From: Aristeu Rozanski <arozansk@redhat.com>
> 
> flex_array currently is built unconditionally:
> 	text    data     bss     dec     hex filename
> 	2294    1008    1568    4870    1306 lib/flex_array.o
> 	2294    1008    1568    4870    1306 (TOTALS)
> 
> and it's used by procfs, selinux and openvswitch. This patch is
> useful for situations in which memory footprint is a concern and
> those features aren't used.
> 
> Cc: Changli Gao <xiaosuo@gmail.com>
> Cc: Dave Hansen <dave@linux.vnet.ibm.com>
> Cc: David Rientjes <rientjes@google.com>
> Cc: Eric Paris <eparis@redhat.com>
> Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
> Cc: Jesse Gross <jesse@nicira.com>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
> Cc: Pravin Shelar <pshelar@nicira.com>
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Cc: Josh Triplett <josh@joshtriplett.org>
> Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>

I already have a patch for this sitting in the tiny tree (branch
tiny/unflex-array) for the next merge window, and that patch hides the
symbol from the user, just selecting it internally.

I've updated the tinification project list to mark that and several
other projects as "done" or "in progress".

- Josh Triplett

>  fs/proc/Kconfig          |  1 +
>  lib/Kconfig              | 10 ++++++++++
>  lib/Makefile             |  3 ++-
>  net/openvswitch/Kconfig  |  1 +
>  security/selinux/Kconfig |  1 +
>  5 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
> index 2183fcf..2d624b7 100644
> --- a/fs/proc/Kconfig
> +++ b/fs/proc/Kconfig
> @@ -1,6 +1,7 @@
>  config PROC_FS
>  	bool "/proc file system support" if EXPERT
>  	default y
> +	select FLEX_ARRAY
>  	help
>  	  This is a virtual file system providing information about the status
>  	  of the system. "Virtual" means that it doesn't take up any space on
> diff --git a/lib/Kconfig b/lib/Kconfig
> index 54cf309..675920b 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -432,6 +432,16 @@ config GLOB_SELFTEST
>  	  module load) by a small amount, so you're welcome to play with
>  	  it, but you probably don't need it.
>  
> +config FLEX_ARRAY
> +	bool "Flexible array"
> +	default n
> +	help
> +	  This option enables an implementation of flexible arrays which
> +	  allows creating arrays of fixed size elements with an arbritrary
> +	  size without requiring the single allocation of a contiguous area.
> +
> +	  See Documentation/flexible-arrays.txt
> +
>  #
>  # Netlink attribute parsing support is select'ed if needed
>  #
> diff --git a/lib/Makefile b/lib/Makefile
> index 7512dc9..9c12cbc 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -24,7 +24,7 @@ obj-y	+= lockref.o
>  
>  obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
>  	 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
> -	 gcd.o lcm.o list_sort.o uuid.o flex_array.o iovec.o clz_ctz.o \
> +	 gcd.o lcm.o list_sort.o uuid.o iovec.o clz_ctz.o \
>  	 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o \
>  	 percpu-refcount.o percpu_ida.o hash.o rhashtable.o
>  obj-y += string_helpers.o
> @@ -35,6 +35,7 @@ obj-$(CONFIG_TEST_LKM) += test_module.o
>  obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
>  obj-$(CONFIG_TEST_BPF) += test_bpf.o
>  obj-$(CONFIG_TEST_FIRMWARE) += test_firmware.o
> +obj-$(CONFIG_FLEX_ARRAY) += flex_array.o
>  
>  ifeq ($(CONFIG_DEBUG_KOBJECT),y)
>  CFLAGS_kobject.o += -DDEBUG
> diff --git a/net/openvswitch/Kconfig b/net/openvswitch/Kconfig
> index ba3bb82..1d979ce 100644
> --- a/net/openvswitch/Kconfig
> +++ b/net/openvswitch/Kconfig
> @@ -5,6 +5,7 @@
>  config OPENVSWITCH
>  	tristate "Open vSwitch"
>  	select LIBCRC32C
> +	select FLEX_ARRAY
>  	---help---
>  	  Open vSwitch is a multilayer Ethernet switch targeted at virtualized
>  	  environments.  In addition to supporting a variety of features
> diff --git a/security/selinux/Kconfig b/security/selinux/Kconfig
> index bca1b74..cfcc7c1 100644
> --- a/security/selinux/Kconfig
> +++ b/security/selinux/Kconfig
> @@ -2,6 +2,7 @@ config SECURITY_SELINUX
>  	bool "NSA SELinux Support"
>  	depends on SECURITY_NETWORK && AUDIT && NET && INET
>  	select NETWORK_SECMARK
> +	select FLEX_ARRAY
>  	default n
>  	help
>  	  This selects NSA Security-Enhanced Linux (SELinux).
> -- 
> 1.8.3.1
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] lib/flex_array: make build optional
  2014-11-06 21:50     ` Aristeu Rozanski
@ 2014-11-07  3:31       ` Josh Triplett
  2014-11-07 10:18         ` David Rientjes
  0 siblings, 1 reply; 7+ messages in thread
From: Josh Triplett @ 2014-11-07  3:31 UTC (permalink / raw)
  To: Aristeu Rozanski
  Cc: Dave Hansen, linux-kernel, Changli Gao, David Rientjes,
	Eric Paris, Hannes Frederic Sowa, Jesse Gross, Jonathan Corbet,
	Paul Gortmaker, Pravin Shelar, Alexander Viro

On Thu, Nov 06, 2014 at 04:50:56PM -0500, Aristeu Rozanski wrote:
> On Thu, Nov 06, 2014 at 01:44:54PM -0800, Dave Hansen wrote:
> > On 11/06/2014 01:33 PM, Dave Hansen wrote:
> > > On 11/06/2014 01:27 PM, Aristeu Rozanski wrote:
> > >> +config FLEX_ARRAY
> > >> +	bool "Flexible array"
> > >> +	default n
> > >> +	help
> > >> +	  This option enables an implementation of flexible arrays which
> > >> +	  allows creating arrays of fixed size elements with an arbritrary
> > >> +	  size without requiring the single allocation of a contiguous area.
> > >> +
> > >> +	  See Documentation/flexible-arrays.txt
> > > 
> > > Is there any reason to expose this to the user via Kconfig?
> > > 
> > > No sane person would even turn it on if they don't need it.
> > 
> > IOW, I think you should just make it:
> > 
> > config FLEX_ARRAY
> > 	def_bool n
> 
> Joe Pershes complained on a similar patch on making it default to 'n'.
> Will rework the patches this way.

https://git.kernel.org/cgit/linux/kernel/git/josh/linux.git/commit/?h=tiny/unflex-array&id=6631d5fb4cf395ebd2dc0f2da05525b9d3436a3f

Already done.

- Josh Triplett

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] lib/flex_array: make build optional
  2014-11-07  3:31       ` Josh Triplett
@ 2014-11-07 10:18         ` David Rientjes
  0 siblings, 0 replies; 7+ messages in thread
From: David Rientjes @ 2014-11-07 10:18 UTC (permalink / raw)
  To: Josh Triplett
  Cc: Aristeu Rozanski, Dave Hansen, linux-kernel, Changli Gao,
	Eric Paris, Hannes Frederic Sowa, Jesse Gross, Jonathan Corbet,
	Paul Gortmaker, Pravin Shelar, Alexander Viro

On Thu, 6 Nov 2014, Josh Triplett wrote:

> https://git.kernel.org/cgit/linux/kernel/git/josh/linux.git/commit/?h=tiny/unflex-array&id=6631d5fb4cf395ebd2dc0f2da05525b9d3436a3f
> 
> Already done.
> 

Thanks Josh, and the "unflex array" patch title is great.

Acked-by: David Rientjes <rientjes@google.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-07 10:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-06 21:27 [PATCH] lib/flex_array: make build optional Aristeu Rozanski
2014-11-06 21:33 ` Dave Hansen
2014-11-06 21:44   ` Dave Hansen
2014-11-06 21:50     ` Aristeu Rozanski
2014-11-07  3:31       ` Josh Triplett
2014-11-07 10:18         ` David Rientjes
2014-11-06 21:58 ` josh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).