linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: Support compiling out madvise and fadvise
@ 2014-09-22 16:11 Josh Triplett
  2014-09-22 16:47 ` Davidlohr Bueso
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Josh Triplett @ 2014-09-22 16:11 UTC (permalink / raw)
  To: Andrew Morton, H. Peter Anvin,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg

Many embedded systems will not need these syscalls, and omitting them
saves space.  Add a new EXPERT config option CONFIG_ADVISE_SYSCALLS
(default y) to support compiling them out.

bloat-o-meter:
add/remove: 0/3 grow/shrink: 0/0 up/down: 0/-2250 (-2250)
function                                     old     new   delta
sys_fadvise64                                 57       -     -57
sys_fadvise64_64                             691       -    -691
sys_madvise                                 1502       -   -1502

Signed-off-by: Josh Triplett <josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org>
---

Posting this for review.  I can upstream this directly through my new tiny
tree.

 init/Kconfig    | 10 ++++++++++
 kernel/sys_ni.c |  3 +++
 mm/Makefile     |  7 +++++--
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/init/Kconfig b/init/Kconfig
index e84c642..782a65b 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1537,6 +1537,16 @@ config AIO
 	  by some high performance threaded applications. Disabling
 	  this option saves about 7k.
 
+config ADVISE_SYSCALLS
+	bool "Enable madvise/fadvise syscalls" if EXPERT
+	default y
+	help
+	  This option enables the madvise and fadvise syscalls, used by
+	  applications to advise the kernel about their future memory or file
+	  usage, improving performance. If building an embedded system where no
+	  applications use these syscalls, you can disable this option to save
+	  space.
+
 config PCI_QUIRKS
 	default y
 	bool "Enable PCI quirk workarounds" if EXPERT
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 391d4dd..d4709d4 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -156,6 +156,9 @@ cond_syscall(sys_process_vm_writev);
 cond_syscall(compat_sys_process_vm_readv);
 cond_syscall(compat_sys_process_vm_writev);
 cond_syscall(sys_uselib);
+cond_syscall(sys_fadvise64);
+cond_syscall(sys_fadvise64_64);
+cond_syscall(sys_madvise);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
diff --git a/mm/Makefile b/mm/Makefile
index 632ae77..fe7a053 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -3,7 +3,7 @@
 #
 
 mmu-y			:= nommu.o
-mmu-$(CONFIG_MMU)	:= fremap.o gup.o highmem.o madvise.o memory.o mincore.o \
+mmu-$(CONFIG_MMU)	:= fremap.o gup.o highmem.o memory.o mincore.o \
 			   mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
 			   vmalloc.o pagewalk.o pgtable-generic.o
 
@@ -11,7 +11,7 @@ ifdef CONFIG_CROSS_MEMORY_ATTACH
 mmu-$(CONFIG_MMU)	+= process_vm_access.o
 endif
 
-obj-y			:= filemap.o mempool.o oom_kill.o fadvise.o \
+obj-y			:= filemap.o mempool.o oom_kill.o \
 			   maccess.o page_alloc.o page-writeback.o \
 			   readahead.o swap.o truncate.o vmscan.o shmem.o \
 			   util.o mmzone.o vmstat.o backing-dev.o \
@@ -28,6 +28,9 @@ else
 	obj-y		+= bootmem.o
 endif
 
+ifdef CONFIG_MMU
+	obj-$(CONFIG_ADVISE_SYSCALLS)	+= fadvise.o madvise.o
+endif
 obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o
 
 obj-$(CONFIG_SWAP)	+= page_io.o swap_state.o swapfile.o
-- 
2.1.0

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

* Re: [PATCH] mm: Support compiling out madvise and fadvise
  2014-09-22 16:11 [PATCH] mm: Support compiling out madvise and fadvise Josh Triplett
@ 2014-09-22 16:47 ` Davidlohr Bueso
  2014-09-22 17:03   ` Josh Triplett
  2014-09-25 17:21 ` Johannes Weiner
  2014-09-25 18:32 ` [PATCHv2] " josh-iaAMLnmF4UmaiuxdJuQwMA
  2 siblings, 1 reply; 6+ messages in thread
From: Davidlohr Bueso @ 2014-09-22 16:47 UTC (permalink / raw)
  To: Josh Triplett
  Cc: Andrew Morton, H. Peter Anvin, linux-kernel, linux-api, linux-mm

On Mon, 2014-09-22 at 09:11 -0700, Josh Triplett wrote:
> Many embedded systems will not need these syscalls, and omitting them
> saves space.  Add a new EXPERT config option CONFIG_ADVISE_SYSCALLS
> (default y) to support compiling them out.

general question: if a user chooses CONFIG_ADVISE_SYSCALLS=n (or any
config option related to tinyfication) and breaks the system/workload...
will that be acceptable for a kernel pov? In other words, what's the
degree of responsibility the user will have when choosing such builds?

Thanks,
Davidlohr

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

* Re: [PATCH] mm: Support compiling out madvise and fadvise
  2014-09-22 16:47 ` Davidlohr Bueso
@ 2014-09-22 17:03   ` Josh Triplett
  0 siblings, 0 replies; 6+ messages in thread
From: Josh Triplett @ 2014-09-22 17:03 UTC (permalink / raw)
  To: Davidlohr Bueso
  Cc: Andrew Morton, H. Peter Anvin, linux-kernel, linux-api, linux-mm

On Mon, Sep 22, 2014 at 06:47:40PM +0200, Davidlohr Bueso wrote:
> On Mon, 2014-09-22 at 09:11 -0700, Josh Triplett wrote:
> > Many embedded systems will not need these syscalls, and omitting them
> > saves space.  Add a new EXPERT config option CONFIG_ADVISE_SYSCALLS
> > (default y) to support compiling them out.
> 
> general question: if a user chooses CONFIG_ADVISE_SYSCALLS=n (or any
> config option related to tinyfication) and breaks the system/workload...
> will that be acceptable for a kernel pov? In other words, what's the
> degree of responsibility the user will have when choosing such builds?

It's hidden behind EXPERT for exactly that reason: if you turn it off,
and your userspace needs it and can't cope with ENOSYS, you get to keep
all the pieces.  Only turn it off if you know your userspace doesn't
use it.

The same thing goes for several other such options, such as UID16,
SYSCTL_SYSCALL, SGETMASK_SYSCALL, and USELIB.

- Josh Triplett

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm: Support compiling out madvise and fadvise
  2014-09-22 16:11 [PATCH] mm: Support compiling out madvise and fadvise Josh Triplett
  2014-09-22 16:47 ` Davidlohr Bueso
@ 2014-09-25 17:21 ` Johannes Weiner
  2014-09-25 18:27   ` josh
  2014-09-25 18:32 ` [PATCHv2] " josh-iaAMLnmF4UmaiuxdJuQwMA
  2 siblings, 1 reply; 6+ messages in thread
From: Johannes Weiner @ 2014-09-25 17:21 UTC (permalink / raw)
  To: Josh Triplett
  Cc: Andrew Morton, H. Peter Anvin, linux-kernel, linux-api, linux-mm

On Mon, Sep 22, 2014 at 09:11:16AM -0700, Josh Triplett wrote:
> @@ -3,7 +3,7 @@
>  #
>  
>  mmu-y			:= nommu.o
> -mmu-$(CONFIG_MMU)	:= fremap.o gup.o highmem.o madvise.o memory.o mincore.o \
> +mmu-$(CONFIG_MMU)	:= fremap.o gup.o highmem.o memory.o mincore.o \
>  			   mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
>  			   vmalloc.o pagewalk.o pgtable-generic.o
>  
> @@ -11,7 +11,7 @@ ifdef CONFIG_CROSS_MEMORY_ATTACH
>  mmu-$(CONFIG_MMU)	+= process_vm_access.o
>  endif
>  
> -obj-y			:= filemap.o mempool.o oom_kill.o fadvise.o \
> +obj-y			:= filemap.o mempool.o oom_kill.o \
>  			   maccess.o page_alloc.o page-writeback.o \
>  			   readahead.o swap.o truncate.o vmscan.o shmem.o \
>  			   util.o mmzone.o vmstat.o backing-dev.o \
> @@ -28,6 +28,9 @@ else
>  	obj-y		+= bootmem.o
>  endif
>  
> +ifdef CONFIG_MMU
> +	obj-$(CONFIG_ADVISE_SYSCALLS)	+= fadvise.o madvise.o
> +endif

That makes fadvise MMU-only, but I don't see why it should be.

Was that intentional?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm: Support compiling out madvise and fadvise
  2014-09-25 17:21 ` Johannes Weiner
@ 2014-09-25 18:27   ` josh
  0 siblings, 0 replies; 6+ messages in thread
From: josh @ 2014-09-25 18:27 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, H. Peter Anvin, linux-kernel, linux-api, linux-mm

On Thu, Sep 25, 2014 at 01:21:13PM -0400, Johannes Weiner wrote:
> On Mon, Sep 22, 2014 at 09:11:16AM -0700, Josh Triplett wrote:
> > @@ -3,7 +3,7 @@
> >  #
> >  
> >  mmu-y			:= nommu.o
> > -mmu-$(CONFIG_MMU)	:= fremap.o gup.o highmem.o madvise.o memory.o mincore.o \
> > +mmu-$(CONFIG_MMU)	:= fremap.o gup.o highmem.o memory.o mincore.o \
> >  			   mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
> >  			   vmalloc.o pagewalk.o pgtable-generic.o
> >  
> > @@ -11,7 +11,7 @@ ifdef CONFIG_CROSS_MEMORY_ATTACH
> >  mmu-$(CONFIG_MMU)	+= process_vm_access.o
> >  endif
> >  
> > -obj-y			:= filemap.o mempool.o oom_kill.o fadvise.o \
> > +obj-y			:= filemap.o mempool.o oom_kill.o \
> >  			   maccess.o page_alloc.o page-writeback.o \
> >  			   readahead.o swap.o truncate.o vmscan.o shmem.o \
> >  			   util.o mmzone.o vmstat.o backing-dev.o \
> > @@ -28,6 +28,9 @@ else
> >  	obj-y		+= bootmem.o
> >  endif
> >  
> > +ifdef CONFIG_MMU
> > +	obj-$(CONFIG_ADVISE_SYSCALLS)	+= fadvise.o madvise.o
> > +endif
> 
> That makes fadvise MMU-only, but I don't see why it should be.
> 
> Was that intentional?

No.  Fixed in v2; will send out momentarily.  Thanks!

- Josh Triplett

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCHv2] mm: Support compiling out madvise and fadvise
  2014-09-22 16:11 [PATCH] mm: Support compiling out madvise and fadvise Josh Triplett
  2014-09-22 16:47 ` Davidlohr Bueso
  2014-09-25 17:21 ` Johannes Weiner
@ 2014-09-25 18:32 ` josh-iaAMLnmF4UmaiuxdJuQwMA
  2 siblings, 0 replies; 6+ messages in thread
From: josh-iaAMLnmF4UmaiuxdJuQwMA @ 2014-09-25 18:32 UTC (permalink / raw)
  To: Andrew Morton, H. Peter Anvin,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg

Many embedded systems will not need these syscalls, and omitting them
saves space.  Add a new EXPERT config option CONFIG_ADVISE_SYSCALLS
(default y) to support compiling them out.

bloat-o-meter:
add/remove: 0/3 grow/shrink: 0/0 up/down: 0/-2250 (-2250)
function                                     old     new   delta
sys_fadvise64                                 57       -     -57
sys_fadvise64_64                             691       -    -691
sys_madvise                                 1502       -   -1502

Signed-off-by: Josh Triplett <josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org>
---

v2: Don't make fadvise depend on CONFIG_MMU.

 init/Kconfig    | 10 ++++++++++
 kernel/sys_ni.c |  3 +++
 mm/Makefile     |  8 ++++++--
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/init/Kconfig b/init/Kconfig
index e84c642..782a65b 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1537,6 +1537,16 @@ config AIO
 	  by some high performance threaded applications. Disabling
 	  this option saves about 7k.
 
+config ADVISE_SYSCALLS
+	bool "Enable madvise/fadvise syscalls" if EXPERT
+	default y
+	help
+	  This option enables the madvise and fadvise syscalls, used by
+	  applications to advise the kernel about their future memory or file
+	  usage, improving performance. If building an embedded system where no
+	  applications use these syscalls, you can disable this option to save
+	  space.
+
 config PCI_QUIRKS
 	default y
 	bool "Enable PCI quirk workarounds" if EXPERT
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 391d4dd..d4709d4 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -156,6 +156,9 @@ cond_syscall(sys_process_vm_writev);
 cond_syscall(compat_sys_process_vm_readv);
 cond_syscall(compat_sys_process_vm_writev);
 cond_syscall(sys_uselib);
+cond_syscall(sys_fadvise64);
+cond_syscall(sys_fadvise64_64);
+cond_syscall(sys_madvise);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
diff --git a/mm/Makefile b/mm/Makefile
index 632ae77..2ad574d 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -3,7 +3,7 @@
 #
 
 mmu-y			:= nommu.o
-mmu-$(CONFIG_MMU)	:= fremap.o gup.o highmem.o madvise.o memory.o mincore.o \
+mmu-$(CONFIG_MMU)	:= fremap.o gup.o highmem.o memory.o mincore.o \
 			   mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
 			   vmalloc.o pagewalk.o pgtable-generic.o
 
@@ -11,7 +11,7 @@ ifdef CONFIG_CROSS_MEMORY_ATTACH
 mmu-$(CONFIG_MMU)	+= process_vm_access.o
 endif
 
-obj-y			:= filemap.o mempool.o oom_kill.o fadvise.o \
+obj-y			:= filemap.o mempool.o oom_kill.o \
 			   maccess.o page_alloc.o page-writeback.o \
 			   readahead.o swap.o truncate.o vmscan.o shmem.o \
 			   util.o mmzone.o vmstat.o backing-dev.o \
@@ -28,6 +28,10 @@ else
 	obj-y		+= bootmem.o
 endif
 
+obj-$(CONFIG_ADVISE_SYSCALLS)	+= fadvise.o
+ifdef CONFIG_MMU
+	obj-$(CONFIG_ADVISE_SYSCALLS)	+= madvise.o
+endif
 obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o
 
 obj-$(CONFIG_SWAP)	+= page_io.o swap_state.o swapfile.o
-- 
2.1.1

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

end of thread, other threads:[~2014-09-25 18:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-22 16:11 [PATCH] mm: Support compiling out madvise and fadvise Josh Triplett
2014-09-22 16:47 ` Davidlohr Bueso
2014-09-22 17:03   ` Josh Triplett
2014-09-25 17:21 ` Johannes Weiner
2014-09-25 18:27   ` josh
2014-09-25 18:32 ` [PATCHv2] " josh-iaAMLnmF4UmaiuxdJuQwMA

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).