Skip to content

Commit d3ac21c

Browse files
committed
mm: Support compiling out madvise and fadvise
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 <[email protected]>
1 parent 7d1311b commit d3ac21c

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

init/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,6 +1537,16 @@ config AIO
15371537
by some high performance threaded applications. Disabling
15381538
this option saves about 7k.
15391539

1540+
config ADVISE_SYSCALLS
1541+
bool "Enable madvise/fadvise syscalls" if EXPERT
1542+
default y
1543+
help
1544+
This option enables the madvise and fadvise syscalls, used by
1545+
applications to advise the kernel about their future memory or file
1546+
usage, improving performance. If building an embedded system where no
1547+
applications use these syscalls, you can disable this option to save
1548+
space.
1549+
15401550
config PCI_QUIRKS
15411551
default y
15421552
bool "Enable PCI quirk workarounds" if EXPERT

kernel/sys_ni.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ cond_syscall(sys_process_vm_writev);
156156
cond_syscall(compat_sys_process_vm_readv);
157157
cond_syscall(compat_sys_process_vm_writev);
158158
cond_syscall(sys_uselib);
159+
cond_syscall(sys_fadvise64);
160+
cond_syscall(sys_fadvise64_64);
161+
cond_syscall(sys_madvise);
159162

160163
/* arch-specific weak syscall entries */
161164
cond_syscall(sys_pciconfig_read);

mm/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
#
44

55
mmu-y := nommu.o
6-
mmu-$(CONFIG_MMU) := fremap.o gup.o highmem.o madvise.o memory.o mincore.o \
6+
mmu-$(CONFIG_MMU) := fremap.o gup.o highmem.o memory.o mincore.o \
77
mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
88
vmalloc.o pagewalk.o pgtable-generic.o
99

1010
ifdef CONFIG_CROSS_MEMORY_ATTACH
1111
mmu-$(CONFIG_MMU) += process_vm_access.o
1212
endif
1313

14-
obj-y := filemap.o mempool.o oom_kill.o fadvise.o \
14+
obj-y := filemap.o mempool.o oom_kill.o \
1515
maccess.o page_alloc.o page-writeback.o \
1616
readahead.o swap.o truncate.o vmscan.o shmem.o \
1717
util.o mmzone.o vmstat.o backing-dev.o \
@@ -28,6 +28,9 @@ else
2828
obj-y += bootmem.o
2929
endif
3030

31+
ifdef CONFIG_MMU
32+
obj-$(CONFIG_ADVISE_SYSCALLS) += fadvise.o madvise.o
33+
endif
3134
obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o
3235

3336
obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o

0 commit comments

Comments
 (0)