Skip to content

Commit 97f5420

Browse files
yukaixiongJoelgranados
authored andcommitted
mm: nommu: move sysctl to mm/nommu.c
The sysctl_nr_trim_pages belongs to nommu.c, move it to mm/nommu.c from /kernel/sysctl.c. And remove the useless extern variable declaration from include/linux/mm.h Signed-off-by: Kaixiong Yu <[email protected]> Reviewed-by: Lorenzo Stoakes <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent b121dd4 commit 97f5420

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

include/linux/mm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4066,8 +4066,6 @@ unsigned long wp_shared_mapping_range(struct address_space *mapping,
40664066
pgoff_t first_index, pgoff_t nr);
40674067
#endif
40684068

4069-
extern int sysctl_nr_trim_pages;
4070-
40714069
#ifdef CONFIG_ANON_VMA_NAME
40724070
int madvise_set_anon_name(struct mm_struct *mm, unsigned long start,
40734071
unsigned long len_in,

kernel/sysctl.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,16 +2031,6 @@ static const struct ctl_table vm_table[] = {
20312031
.extra1 = SYSCTL_ONE,
20322032
.extra2 = SYSCTL_FOUR,
20332033
},
2034-
#ifndef CONFIG_MMU
2035-
{
2036-
.procname = "nr_trim_pages",
2037-
.data = &sysctl_nr_trim_pages,
2038-
.maxlen = sizeof(sysctl_nr_trim_pages),
2039-
.mode = 0644,
2040-
.proc_handler = proc_dointvec_minmax,
2041-
.extra1 = SYSCTL_ZERO,
2042-
},
2043-
#endif
20442034
{
20452035
.procname = "vfs_cache_pressure",
20462036
.data = &sysctl_vfs_cache_pressure,

mm/nommu.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ struct page *mem_map;
4848
unsigned long max_mapnr;
4949
EXPORT_SYMBOL(max_mapnr);
5050
unsigned long highest_memmap_pfn;
51-
int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
5251
int heap_stack_gap = 0;
5352

5453
atomic_long_t mmap_pages_allocated;
@@ -392,6 +391,19 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
392391
return mm->brk = brk;
393392
}
394393

394+
static int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
395+
396+
static const struct ctl_table nommu_table[] = {
397+
{
398+
.procname = "nr_trim_pages",
399+
.data = &sysctl_nr_trim_pages,
400+
.maxlen = sizeof(sysctl_nr_trim_pages),
401+
.mode = 0644,
402+
.proc_handler = proc_dointvec_minmax,
403+
.extra1 = SYSCTL_ZERO,
404+
},
405+
};
406+
395407
/*
396408
* initialise the percpu counter for VM and region record slabs
397409
*/
@@ -402,6 +414,7 @@ void __init mmap_init(void)
402414
ret = percpu_counter_init(&vm_committed_as, 0, GFP_KERNEL);
403415
VM_BUG_ON(ret);
404416
vm_region_jar = KMEM_CACHE(vm_region, SLAB_PANIC|SLAB_ACCOUNT);
417+
register_sysctl_init("vm", nommu_table);
405418
}
406419

407420
/*

0 commit comments

Comments
 (0)