* [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 01/15] mm: vmstat: move sysctls to " Kaixiong Yu
` (16 more replies)
0 siblings, 17 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
This patch series moves sysctls of vm_table in kernel/sysctl.c to
places where they actually belong, and do some related code clean-ups.
After this patch series, all sysctls in vm_table have been moved into its
own files, meanwhile, delete vm_table.
All the modifications of this patch series base on
linux-next(tags/next-20240823). To test this patch series, the code was
compiled with both the CONFIG_SYSCTL enabled and disabled on arm64 and
x86_64 architectures. After this patch series is applied, all files
under /proc/sys/vm can be read or written normally.
Kaixiong Yu (15):
mm: vmstat: move sysctls to its own files
mm: filemap: move sysctl to its own file
mm: swap: move sysctl to its own file
mm: vmscan: move vmscan sysctls to its own file
mm: util: move sysctls into it own files
mm: mmap: move sysctl into its own file
security: min_addr: move sysctl into its own file
mm: nommu: move sysctl to its own file
fs: fs-writeback: move sysctl to its own file
fs: drop_caches: move sysctl to its own file
sunrpc: use vfs_pressure_ratio() helper
fs: dcache: move the sysctl into its own file
x86: vdso: move the sysctl into its own file
sh: vdso: move the sysctl into its own file
sysctl: remove unneeded include
arch/sh/kernel/vsyscall/vsyscall.c | 14 ++
arch/x86/entry/vdso/vdso32-setup.c | 16 ++-
fs/dcache.c | 21 ++-
fs/drop_caches.c | 23 ++-
fs/fs-writeback.c | 28 ++--
include/linux/dcache.h | 7 +-
include/linux/mm.h | 42 ------
include/linux/mman.h | 2 -
include/linux/swap.h | 9 --
include/linux/vmstat.h | 11 --
include/linux/writeback.h | 4 -
kernel/sysctl.c | 221 -----------------------------
mm/filemap.c | 18 ++-
mm/internal.h | 10 ++
mm/mmap.c | 75 ++++++++++
mm/nommu.c | 15 +-
mm/swap.c | 16 ++-
mm/swap.h | 1 +
mm/util.c | 68 +++++++--
mm/vmscan.c | 23 +++
mm/vmstat.c | 42 +++++-
net/sunrpc/auth.c | 2 +-
security/min_addr.c | 11 ++
23 files changed, 349 insertions(+), 330 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH -next 01/15] mm: vmstat: move sysctls to its own files
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 02/15] mm: filemap: move sysctl to its own file Kaixiong Yu
` (15 subsequent siblings)
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
This moves all vmstat related sysctls to its own file, removes useless
extern variable declarations, and do some related clean-ups. To avoid
compiler warnings when CONFIG_PROC_FS is not defined, add the macro
definition CONFIG_PROC_FS ahead CONFIG_NUMA in vmstat.c.
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
include/linux/vmstat.h | 11 -----------
kernel/sysctl.c | 28 ----------------------------
mm/vmstat.c | 42 +++++++++++++++++++++++++++++++++++++++---
3 files changed, 39 insertions(+), 42 deletions(-)
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index d2761bf8ff32..b2ccb6845595 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -10,15 +10,8 @@
#include <linux/static_key.h>
#include <linux/mmdebug.h>
-extern int sysctl_stat_interval;
-
#ifdef CONFIG_NUMA
-#define ENABLE_NUMA_STAT 1
-#define DISABLE_NUMA_STAT 0
-extern int sysctl_vm_numa_stat;
DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key);
-int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write,
- void *buffer, size_t *length, loff_t *ppos);
#endif
struct reclaim_stat {
@@ -304,10 +297,6 @@ void quiet_vmstat(void);
void cpu_vm_stats_fold(int cpu);
void refresh_zone_stat_thresholds(void);
-struct ctl_table;
-int vmstat_refresh(const struct ctl_table *, int write, void *buffer, size_t *lenp,
- loff_t *ppos);
-
void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *);
int calculate_pressure_threshold(struct zone *zone);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 79e6cb1d5c48..726b866af57b 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -49,7 +49,6 @@
#include <linux/limits.h>
#include <linux/dcache.h>
#include <linux/syscalls.h>
-#include <linux/vmstat.h>
#include <linux/nfs_fs.h>
#include <linux/acpi.h>
#include <linux/reboot.h>
@@ -2081,17 +2080,6 @@ static struct ctl_table vm_table[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_TWO_HUNDRED,
},
-#ifdef CONFIG_NUMA
- {
- .procname = "numa_stat",
- .data = &sysctl_vm_numa_stat,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = sysctl_vm_numa_stat_handler,
- .extra1 = SYSCTL_ZERO,
- .extra2 = SYSCTL_ONE,
- },
-#endif
{
.procname = "drop_caches",
.data = &sysctl_drop_caches,
@@ -2157,22 +2145,6 @@ static struct ctl_table vm_table[] = {
.extra1 = SYSCTL_ZERO,
},
#endif
-#ifdef CONFIG_SMP
- {
- .procname = "stat_interval",
- .data = &sysctl_stat_interval,
- .maxlen = sizeof(sysctl_stat_interval),
- .mode = 0644,
- .proc_handler = proc_dointvec_jiffies,
- },
- {
- .procname = "stat_refresh",
- .data = NULL,
- .maxlen = 0,
- .mode = 0600,
- .proc_handler = vmstat_refresh,
- },
-#endif
#ifdef CONFIG_MMU
{
.procname = "mmap_min_addr",
diff --git a/mm/vmstat.c b/mm/vmstat.c
index f41984dc856f..9f9d6a92b98f 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -31,8 +31,10 @@
#include "internal.h"
+#ifdef CONFIG_PROC_FS
#ifdef CONFIG_NUMA
-int sysctl_vm_numa_stat = ENABLE_NUMA_STAT;
+#define ENABLE_NUMA_STAT 1
+static int sysctl_vm_numa_stat = ENABLE_NUMA_STAT;
/* zero numa counters within a zone */
static void zero_zone_numa_counters(struct zone *zone)
@@ -74,7 +76,7 @@ static void invalid_numa_statistics(void)
static DEFINE_MUTEX(vm_numa_stat_lock);
-int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write,
+static int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write,
void *buffer, size_t *length, loff_t *ppos)
{
int ret, oldval;
@@ -102,6 +104,7 @@ int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write,
return ret;
}
#endif
+#endif /* CONFIG_PROC_FS */
#ifdef CONFIG_VM_EVENT_COUNTERS
DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}};
@@ -1936,7 +1939,7 @@ static void refresh_vm_stats(struct work_struct *work)
refresh_cpu_vm_stats(true);
}
-int vmstat_refresh(const struct ctl_table *table, int write,
+static int vmstat_refresh(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
long val;
@@ -2174,6 +2177,38 @@ static int __init vmstat_late_init(void)
late_initcall(vmstat_late_init);
#endif
+#ifdef CONFIG_PROC_FS
+static struct ctl_table vmstat_table[] = {
+#ifdef CONFIG_SMP
+ {
+ .procname = "stat_interval",
+ .data = &sysctl_stat_interval,
+ .maxlen = sizeof(sysctl_stat_interval),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_jiffies,
+ },
+ {
+ .procname = "stat_refresh",
+ .data = NULL,
+ .maxlen = 0,
+ .mode = 0600,
+ .proc_handler = vmstat_refresh,
+ },
+#endif
+#ifdef CONFIG_NUMA
+ {
+ .procname = "numa_stat",
+ .data = &sysctl_vm_numa_stat,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = sysctl_vm_numa_stat_handler,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = SYSCTL_ONE,
+ },
+#endif
+};
+#endif
+
struct workqueue_struct *mm_percpu_wq;
void __init init_mm_internals(void)
@@ -2205,6 +2240,7 @@ void __init init_mm_internals(void)
proc_create_seq("pagetypeinfo", 0400, NULL, &pagetypeinfo_op);
proc_create_seq("vmstat", 0444, NULL, &vmstat_op);
proc_create_seq("zoneinfo", 0444, NULL, &zoneinfo_op);
+ register_sysctl_init("vm", vmstat_table);
#endif
}
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 02/15] mm: filemap: move sysctl to its own file
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 01/15] mm: vmstat: move sysctls to " Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 03/15] mm: swap: " Kaixiong Yu
` (14 subsequent siblings)
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
This moves the filemap related sysctl to its own file, and
removes the redundant external variable declaration.
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
include/linux/mm.h | 2 --
kernel/sysctl.c | 8 --------
mm/filemap.c | 18 +++++++++++++++---
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index fc111a0a5375..1db4cd7136ff 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -39,8 +39,6 @@ struct user_struct;
struct pt_regs;
struct folio_batch;
-extern int sysctl_page_lock_unfairness;
-
void mm_core_init(void);
void init_mm_internals(void);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 726b866af57b..2a875b739054 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2089,14 +2089,6 @@ static struct ctl_table vm_table[] = {
.extra1 = SYSCTL_ONE,
.extra2 = SYSCTL_FOUR,
},
- {
- .procname = "page_lock_unfairness",
- .data = &sysctl_page_lock_unfairness,
- .maxlen = sizeof(sysctl_page_lock_unfairness),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- },
#ifdef CONFIG_MMU
{
.procname = "max_map_count",
diff --git a/mm/filemap.c b/mm/filemap.c
index 0f13126b43b0..72695ccacb86 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -47,6 +47,7 @@
#include <linux/splice.h>
#include <linux/rcupdate_wait.h>
#include <linux/sched/mm.h>
+#include <linux/sysctl.h>
#include <asm/pgalloc.h>
#include <asm/tlbflush.h>
#include "internal.h"
@@ -1067,6 +1068,19 @@ static wait_queue_head_t *folio_waitqueue(struct folio *folio)
return &folio_wait_table[hash_ptr(folio, PAGE_WAIT_TABLE_BITS)];
}
+/* How many times do we accept lock stealing from under a waiter? */
+static int sysctl_page_lock_unfairness = 5;
+static struct ctl_table filemap_sysctl_table[] = {
+ {
+ .procname = "page_lock_unfairness",
+ .data = &sysctl_page_lock_unfairness,
+ .maxlen = sizeof(sysctl_page_lock_unfairness),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ }
+};
+
void __init pagecache_init(void)
{
int i;
@@ -1075,6 +1089,7 @@ void __init pagecache_init(void)
init_waitqueue_head(&folio_wait_table[i]);
page_writeback_init();
+ register_sysctl_init("vm", filemap_sysctl_table);
}
/*
@@ -1222,9 +1237,6 @@ static inline bool folio_trylock_flag(struct folio *folio, int bit_nr,
return true;
}
-/* How many times do we accept lock stealing from under a waiter? */
-int sysctl_page_lock_unfairness = 5;
-
static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,
int state, enum behavior behavior)
{
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 03/15] mm: swap: move sysctl to its own file
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 01/15] mm: vmstat: move sysctls to " Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 02/15] mm: filemap: move sysctl to its own file Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 04/15] mm: vmscan: move vmscan sysctls " Kaixiong Yu
` (13 subsequent siblings)
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
The page-cluster belongs to mm/swap.c, move it into its own file.
Removes the redundant external variable declaration and unneeded
include(linux/swap.h).
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
include/linux/mm.h | 2 --
kernel/sysctl.c | 10 ----------
mm/swap.c | 16 +++++++++++++++-
mm/swap.h | 1 +
4 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 1db4cd7136ff..ae41092f4328 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -75,8 +75,6 @@ static inline void totalram_pages_add(long count)
}
extern void * high_memory;
-extern int page_cluster;
-extern const int page_cluster_max;
#ifdef CONFIG_SYSCTL
extern int sysctl_legacy_va_layout;
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 2a875b739054..9fad501311a1 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -21,7 +21,6 @@
#include <linux/module.h>
#include <linux/mm.h>
-#include <linux/swap.h>
#include <linux/slab.h>
#include <linux/sysctl.h>
#include <linux/bitmap.h>
@@ -2054,15 +2053,6 @@ static struct ctl_table vm_table[] = {
.mode = 0644,
.proc_handler = overcommit_kbytes_handler,
},
- {
- .procname = "page-cluster",
- .data = &page_cluster,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- .extra2 = (void *)&page_cluster_max,
- },
{
.procname = "dirtytime_expire_seconds",
.data = &dirtytime_expire_interval,
diff --git a/mm/swap.c b/mm/swap.c
index e0dbfc98318e..f2689ad02ba4 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -45,7 +45,7 @@
/* How many pages do we try to swap or page in/out together? As a power of 2 */
int page_cluster;
-const int page_cluster_max = 31;
+static const int page_cluster_max = 31;
struct cpu_fbatches {
/*
@@ -1089,6 +1089,18 @@ void folio_batch_remove_exceptionals(struct folio_batch *fbatch)
fbatch->nr = j;
}
+static struct ctl_table swap_sysctl_table[] = {
+ {
+ .procname = "page-cluster",
+ .data = &page_cluster,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = (void *)&page_cluster_max,
+ }
+};
+
/*
* Perform any setup for the swap system
*/
@@ -1105,4 +1117,6 @@ void __init swap_setup(void)
* Right now other parts of the system means that we
* _really_ don't want to cluster much more
*/
+
+ register_sysctl_init("vm", swap_sysctl_table);
}
diff --git a/mm/swap.h b/mm/swap.h
index f8711ff82f84..7283593a0d4a 100644
--- a/mm/swap.h
+++ b/mm/swap.h
@@ -3,6 +3,7 @@
#define _MM_SWAP_H
struct mempolicy;
+extern int page_cluster;
#ifdef CONFIG_SWAP
#include <linux/swapops.h> /* for swp_offset */
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 04/15] mm: vmscan: move vmscan sysctls to its own file
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (2 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 03/15] mm: swap: " Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 05/15] mm: util: move sysctls into it own files Kaixiong Yu
` (12 subsequent siblings)
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
This moves vm_swappiness and zone_reclaim_mode to its own file,
as part of the kernel/sysctl.c cleaning, also moves some external
variable declarations and function declarations from include/linux/swap.h
into mm/internal.h.
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
include/linux/swap.h | 9 ---------
kernel/sysctl.c | 19 -------------------
mm/internal.h | 10 ++++++++++
mm/vmscan.c | 23 +++++++++++++++++++++++
4 files changed, 33 insertions(+), 28 deletions(-)
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 248db1dd7812..7e6287e64118 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -424,19 +424,10 @@ extern int vm_swappiness;
long remove_mapping(struct address_space *mapping, struct folio *folio);
#ifdef CONFIG_NUMA
-extern int node_reclaim_mode;
extern int sysctl_min_unmapped_ratio;
extern int sysctl_min_slab_ratio;
-#else
-#define node_reclaim_mode 0
#endif
-static inline bool node_reclaim_enabled(void)
-{
- /* Is any node_reclaim_mode bit set? */
- return node_reclaim_mode & (RECLAIM_ZONE|RECLAIM_WRITE|RECLAIM_UNMAP);
-}
-
void check_move_unevictable_folios(struct folio_batch *fbatch);
extern void __meminit kswapd_run(int nid);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 9fad501311a1..184d39944e16 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2061,15 +2061,6 @@ static struct ctl_table vm_table[] = {
.proc_handler = dirtytime_interval_handler,
.extra1 = SYSCTL_ZERO,
},
- {
- .procname = "swappiness",
- .data = &vm_swappiness,
- .maxlen = sizeof(vm_swappiness),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- .extra2 = SYSCTL_TWO_HUNDRED,
- },
{
.procname = "drop_caches",
.data = &sysctl_drop_caches,
@@ -2117,16 +2108,6 @@ static struct ctl_table vm_table[] = {
.extra1 = SYSCTL_ZERO,
},
#endif
-#ifdef CONFIG_NUMA
- {
- .procname = "zone_reclaim_mode",
- .data = &node_reclaim_mode,
- .maxlen = sizeof(node_reclaim_mode),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- },
-#endif
#ifdef CONFIG_MMU
{
.procname = "mmap_min_addr",
diff --git a/mm/internal.h b/mm/internal.h
index e1e139e412d1..d396b201e636 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -1031,9 +1031,13 @@ static inline void mminit_verify_zonelist(void)
#define NODE_RECLAIM_SUCCESS 1
#ifdef CONFIG_NUMA
+extern int node_reclaim_mode;
+
extern int node_reclaim(struct pglist_data *, gfp_t, unsigned int);
extern int find_next_best_node(int node, nodemask_t *used_node_mask);
#else
+#define node_reclaim_mode 0
+
static inline int node_reclaim(struct pglist_data *pgdat, gfp_t mask,
unsigned int order)
{
@@ -1045,6 +1049,12 @@ static inline int find_next_best_node(int node, nodemask_t *used_node_mask)
}
#endif
+static inline bool node_reclaim_enabled(void)
+{
+ /* Is any node_reclaim_mode bit set? */
+ return node_reclaim_mode & (RECLAIM_ZONE|RECLAIM_WRITE|RECLAIM_UNMAP);
+}
+
/*
* mm/memory-failure.c
*/
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 283e3f9d652b..38b58a40d25b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -7365,6 +7365,28 @@ void __meminit kswapd_stop(int nid)
pgdat_kswapd_unlock(pgdat);
}
+static struct ctl_table vmscan_sysctl_table[] = {
+ {
+ .procname = "swappiness",
+ .data = &vm_swappiness,
+ .maxlen = sizeof(vm_swappiness),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = SYSCTL_TWO_HUNDRED,
+ },
+#ifdef CONFIG_NUMA
+ {
+ .procname = "zone_reclaim_mode",
+ .data = &node_reclaim_mode,
+ .maxlen = sizeof(node_reclaim_mode),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ }
+#endif
+};
+
static int __init kswapd_init(void)
{
int nid;
@@ -7372,6 +7394,7 @@ static int __init kswapd_init(void)
swap_setup();
for_each_node_state(nid, N_MEMORY)
kswapd_run(nid);
+ register_sysctl_init("vm", vmscan_sysctl_table);
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 05/15] mm: util: move sysctls into it own files
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (3 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 04/15] mm: vmscan: move vmscan sysctls " Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 06/15] mm: mmap: move sysctl into its own file Kaixiong Yu
` (11 subsequent siblings)
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
This moves all util related sysctls to its own file, as part of the
kernel/sysctl.c cleaning, also removes redundant external
variable declarations and function declarations.
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
include/linux/mm.h | 11 --------
include/linux/mman.h | 2 --
kernel/sysctl.c | 37 ------------------------
mm/util.c | 67 ++++++++++++++++++++++++++++++++++++++------
4 files changed, 59 insertions(+), 58 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index ae41092f4328..a04543984a46 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -200,17 +200,6 @@ extern int sysctl_max_map_count;
extern unsigned long sysctl_user_reserve_kbytes;
extern unsigned long sysctl_admin_reserve_kbytes;
-extern int sysctl_overcommit_memory;
-extern int sysctl_overcommit_ratio;
-extern unsigned long sysctl_overcommit_kbytes;
-
-int overcommit_ratio_handler(const struct ctl_table *, int, void *, size_t *,
- loff_t *);
-int overcommit_kbytes_handler(const struct ctl_table *, int, void *, size_t *,
- loff_t *);
-int overcommit_policy_handler(const struct ctl_table *, int, void *, size_t *,
- loff_t *);
-
#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
#define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
#define folio_page_idx(folio, p) (page_to_pfn(p) - folio_pfn(folio))
diff --git a/include/linux/mman.h b/include/linux/mman.h
index bcb201ab7a41..e62ef272d140 100644
--- a/include/linux/mman.h
+++ b/include/linux/mman.h
@@ -58,8 +58,6 @@
| MAP_HUGE_1GB)
extern int sysctl_overcommit_memory;
-extern int sysctl_overcommit_ratio;
-extern unsigned long sysctl_overcommit_kbytes;
extern struct percpu_counter vm_committed_as;
#ifdef CONFIG_SMP
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 184d39944e16..ad3ac6f6c808 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2030,29 +2030,6 @@ static struct ctl_table kern_table[] = {
};
static struct ctl_table vm_table[] = {
- {
- .procname = "overcommit_memory",
- .data = &sysctl_overcommit_memory,
- .maxlen = sizeof(sysctl_overcommit_memory),
- .mode = 0644,
- .proc_handler = overcommit_policy_handler,
- .extra1 = SYSCTL_ZERO,
- .extra2 = SYSCTL_TWO,
- },
- {
- .procname = "overcommit_ratio",
- .data = &sysctl_overcommit_ratio,
- .maxlen = sizeof(sysctl_overcommit_ratio),
- .mode = 0644,
- .proc_handler = overcommit_ratio_handler,
- },
- {
- .procname = "overcommit_kbytes",
- .data = &sysctl_overcommit_kbytes,
- .maxlen = sizeof(sysctl_overcommit_kbytes),
- .mode = 0644,
- .proc_handler = overcommit_kbytes_handler,
- },
{
.procname = "dirtytime_expire_seconds",
.data = &dirtytime_expire_interval,
@@ -2133,20 +2110,6 @@ static struct ctl_table vm_table[] = {
.extra1 = SYSCTL_ZERO,
},
#endif
- {
- .procname = "user_reserve_kbytes",
- .data = &sysctl_user_reserve_kbytes,
- .maxlen = sizeof(sysctl_user_reserve_kbytes),
- .mode = 0644,
- .proc_handler = proc_doulongvec_minmax,
- },
- {
- .procname = "admin_reserve_kbytes",
- .data = &sysctl_admin_reserve_kbytes,
- .maxlen = sizeof(sysctl_admin_reserve_kbytes),
- .mode = 0644,
- .proc_handler = proc_doulongvec_minmax,
- },
#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
{
.procname = "mmap_rnd_bits",
diff --git a/mm/util.c b/mm/util.c
index 2bfae12ade7e..04a677f04ca9 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -12,6 +12,7 @@
#include <linux/security.h>
#include <linux/swap.h>
#include <linux/swapops.h>
+#include <linux/sysctl.h>
#include <linux/mman.h>
#include <linux/hugetlb.h>
#include <linux/vmalloc.h>
@@ -903,14 +904,16 @@ int folio_mc_copy(struct folio *dst, struct folio *src)
EXPORT_SYMBOL(folio_mc_copy);
int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS;
-int sysctl_overcommit_ratio __read_mostly = 50;
-unsigned long sysctl_overcommit_kbytes __read_mostly;
+static int sysctl_overcommit_ratio __read_mostly = 50;
+static unsigned long sysctl_overcommit_kbytes __read_mostly;
int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
-int overcommit_ratio_handler(const struct ctl_table *table, int write, void *buffer,
- size_t *lenp, loff_t *ppos)
+#ifdef CONFIG_SYSCTL
+
+static int overcommit_ratio_handler(const struct ctl_table *table, int write,
+ void *buffer, size_t *lenp, loff_t *ppos)
{
int ret;
@@ -925,8 +928,8 @@ static void sync_overcommit_as(struct work_struct *dummy)
percpu_counter_sync(&vm_committed_as);
}
-int overcommit_policy_handler(const struct ctl_table *table, int write, void *buffer,
- size_t *lenp, loff_t *ppos)
+static int overcommit_policy_handler(const struct ctl_table *table, int write,
+ void *buffer, size_t *lenp, loff_t *ppos)
{
struct ctl_table t;
int new_policy = -1;
@@ -961,8 +964,8 @@ int overcommit_policy_handler(const struct ctl_table *table, int write, void *bu
return ret;
}
-int overcommit_kbytes_handler(const struct ctl_table *table, int write, void *buffer,
- size_t *lenp, loff_t *ppos)
+static int overcommit_kbytes_handler(const struct ctl_table *table, int write,
+ void *buffer, size_t *lenp, loff_t *ppos)
{
int ret;
@@ -972,6 +975,54 @@ int overcommit_kbytes_handler(const struct ctl_table *table, int write, void *bu
return ret;
}
+static struct ctl_table util_sysctl_table[] = {
+ {
+ .procname = "overcommit_memory",
+ .data = &sysctl_overcommit_memory,
+ .maxlen = sizeof(sysctl_overcommit_memory),
+ .mode = 0644,
+ .proc_handler = overcommit_policy_handler,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = SYSCTL_TWO,
+ },
+ {
+ .procname = "overcommit_ratio",
+ .data = &sysctl_overcommit_ratio,
+ .maxlen = sizeof(sysctl_overcommit_ratio),
+ .mode = 0644,
+ .proc_handler = overcommit_ratio_handler,
+ },
+ {
+ .procname = "overcommit_kbytes",
+ .data = &sysctl_overcommit_kbytes,
+ .maxlen = sizeof(sysctl_overcommit_kbytes),
+ .mode = 0644,
+ .proc_handler = overcommit_kbytes_handler,
+ },
+ {
+ .procname = "user_reserve_kbytes",
+ .data = &sysctl_user_reserve_kbytes,
+ .maxlen = sizeof(sysctl_user_reserve_kbytes),
+ .mode = 0644,
+ .proc_handler = proc_doulongvec_minmax,
+ },
+ {
+ .procname = "admin_reserve_kbytes",
+ .data = &sysctl_admin_reserve_kbytes,
+ .maxlen = sizeof(sysctl_admin_reserve_kbytes),
+ .mode = 0644,
+ .proc_handler = proc_doulongvec_minmax,
+ },
+};
+
+static int __init init_vm_util_sysctls(void)
+{
+ register_sysctl_init("vm", util_sysctl_table);
+ return 0;
+}
+subsys_initcall(init_vm_util_sysctls);
+#endif /* CONFIG_SYSCTL */
+
/*
* Committed memory limit enforced when OVERCOMMIT_NEVER policy is used
*/
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 06/15] mm: mmap: move sysctl into its own file
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (4 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 05/15] mm: util: move sysctls into it own files Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 07/15] security: min_addr: " Kaixiong Yu
` (10 subsequent siblings)
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
This moves all mmap related sysctls to its own file, as part of the
kernel/sysctl.c cleaning, also move the variable declaration from
kernel/sysctl.c into mm/mmap.c. Besides, move MAPCOUNT_ELF_CORE_MARGIN
and DEFAULT_MAX_MAP_COUNT into mmap.c from mm.h.
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
include/linux/mm.h | 19 ------------
kernel/sysctl.c | 50 +------------------------------
mm/mmap.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++
mm/util.c | 1 -
4 files changed, 76 insertions(+), 69 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index a04543984a46..9400c92b4522 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -176,25 +176,6 @@ static inline void __mm_zero_struct_page(struct page *page)
#define mm_zero_struct_page(pp) ((void)memset((pp), 0, sizeof(struct page)))
#endif
-/*
- * Default maximum number of active map areas, this limits the number of vmas
- * per mm struct. Users can overwrite this number by sysctl but there is a
- * problem.
- *
- * When a program's coredump is generated as ELF format, a section is created
- * per a vma. In ELF, the number of sections is represented in unsigned short.
- * This means the number of sections should be smaller than 65535 at coredump.
- * Because the kernel adds some informative sections to a image of program at
- * generating coredump, we need some margin. The number of extra sections is
- * 1-3 now and depends on arch. We use "5" as safe margin, here.
- *
- * ELF extended numbering allows more than 65535 sections, so 16-bit bound is
- * not a hard limit any more. Although some userspace tools can be surprised by
- * that.
- */
-#define MAPCOUNT_ELF_CORE_MARGIN (5)
-#define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
-
extern int sysctl_max_map_count;
extern unsigned long sysctl_user_reserve_kbytes;
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ad3ac6f6c808..41d4afc978e6 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -127,12 +127,6 @@ enum sysctl_writes_mode {
static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
#endif /* CONFIG_PROC_SYSCTL */
-
-#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
- defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
-int sysctl_legacy_va_layout;
-#endif
-
#endif /* CONFIG_SYSCTL */
/*
@@ -2047,16 +2041,7 @@ static struct ctl_table vm_table[] = {
.extra1 = SYSCTL_ONE,
.extra2 = SYSCTL_FOUR,
},
-#ifdef CONFIG_MMU
- {
- .procname = "max_map_count",
- .data = &sysctl_max_map_count,
- .maxlen = sizeof(sysctl_max_map_count),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- },
-#else
+#ifndef CONFIG_MMU
{
.procname = "nr_trim_pages",
.data = &sysctl_nr_trim_pages,
@@ -2074,17 +2059,6 @@ static struct ctl_table vm_table[] = {
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
},
-#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
- defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
- {
- .procname = "legacy_va_layout",
- .data = &sysctl_legacy_va_layout,
- .maxlen = sizeof(sysctl_legacy_va_layout),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- },
-#endif
#ifdef CONFIG_MMU
{
.procname = "mmap_min_addr",
@@ -2110,28 +2084,6 @@ static struct ctl_table vm_table[] = {
.extra1 = SYSCTL_ZERO,
},
#endif
-#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
- {
- .procname = "mmap_rnd_bits",
- .data = &mmap_rnd_bits,
- .maxlen = sizeof(mmap_rnd_bits),
- .mode = 0600,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = (void *)&mmap_rnd_bits_min,
- .extra2 = (void *)&mmap_rnd_bits_max,
- },
-#endif
-#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
- {
- .procname = "mmap_rnd_compat_bits",
- .data = &mmap_rnd_compat_bits,
- .maxlen = sizeof(mmap_rnd_compat_bits),
- .mode = 0600,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = (void *)&mmap_rnd_compat_bits_min,
- .extra2 = (void *)&mmap_rnd_compat_bits_max,
- },
-#endif
};
int __init sysctl_init_bases(void)
diff --git a/mm/mmap.c b/mm/mmap.c
index 88524a3768f6..2b37d8fb997f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -62,6 +62,27 @@
#define arch_mmap_check(addr, len, flags) (0)
#endif
+/*
+ * Default maximum number of active map areas, this limits the number of vmas
+ * per mm struct. Users can overwrite this number by sysctl but there is a
+ * problem.
+ *
+ * When a program's coredump is generated as ELF format, a section is created
+ * per a vma. In ELF, the number of sections is represented in unsigned short.
+ * This means the number of sections should be smaller than 65535 at coredump.
+ * Because the kernel adds some informative sections to a image of program at
+ * generating coredump, we need some margin. The number of extra sections is
+ * 1-3 now and depends on arch. We use "5" as safe margin, here.
+ *
+ * ELF extended numbering allows more than 65535 sections, so 16-bit bound is
+ * not a hard limit any more. Although some userspace tools can be surprised by
+ * that.
+ */
+#define MAPCOUNT_ELF_CORE_MARGIN (5)
+#define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
+
+int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
+
#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
const int mmap_rnd_bits_min = CONFIG_ARCH_MMAP_RND_BITS_MIN;
int mmap_rnd_bits_max __ro_after_init = CONFIG_ARCH_MMAP_RND_BITS_MAX;
@@ -2171,6 +2192,57 @@ struct vm_area_struct *_install_special_mapping(
&special_mapping_vmops);
}
+#ifdef CONFIG_SYSCTL
+#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
+ defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
+int sysctl_legacy_va_layout;
+#endif
+
+static struct ctl_table mmap_table[] = {
+ {
+ .procname = "max_map_count",
+ .data = &sysctl_max_map_count,
+ .maxlen = sizeof(sysctl_max_map_count),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ },
+#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
+ defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
+ {
+ .procname = "legacy_va_layout",
+ .data = &sysctl_legacy_va_layout,
+ .maxlen = sizeof(sysctl_legacy_va_layout),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ },
+#endif
+#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
+ {
+ .procname = "mmap_rnd_bits",
+ .data = &mmap_rnd_bits,
+ .maxlen = sizeof(mmap_rnd_bits),
+ .mode = 0600,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = (void *)&mmap_rnd_bits_min,
+ .extra2 = (void *)&mmap_rnd_bits_max,
+ },
+#endif
+#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
+ {
+ .procname = "mmap_rnd_compat_bits",
+ .data = &mmap_rnd_compat_bits,
+ .maxlen = sizeof(mmap_rnd_compat_bits),
+ .mode = 0600,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = (void *)&mmap_rnd_compat_bits_min,
+ .extra2 = (void *)&mmap_rnd_compat_bits_max,
+ },
+#endif
+};
+#endif /* CONFIG_SYSCTL */
+
/*
* initialise the percpu counter for VM
*/
@@ -2180,6 +2252,9 @@ void __init mmap_init(void)
ret = percpu_counter_init(&vm_committed_as, 0, GFP_KERNEL);
VM_BUG_ON(ret);
+#ifdef CONFIG_SYSCTL
+ register_sysctl_init("vm", mmap_table);
+#endif
}
/*
diff --git a/mm/util.c b/mm/util.c
index 04a677f04ca9..7f687563b8c7 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -906,7 +906,6 @@ EXPORT_SYMBOL(folio_mc_copy);
int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS;
static int sysctl_overcommit_ratio __read_mostly = 50;
static unsigned long sysctl_overcommit_kbytes __read_mostly;
-int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 07/15] security: min_addr: move sysctl into its own file
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (5 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 06/15] mm: mmap: move sysctl into its own file Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 22:49 ` Paul Moore
2024-08-26 12:04 ` [PATCH -next 08/15] mm: nommu: move sysctl to " Kaixiong Yu
` (9 subsequent siblings)
16 siblings, 1 reply; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
The dac_mmap_min_addr belongs to min_addr.c, move it into
its own file from /kernel/sysctl.c. In the previous Linux kernel
boot process, sysctl_init_bases needs to be executed before
init_mmap_min_addr, So, register_sysctl_init should be executed
before update_mmap_min_addr in init_mmap_min_addr.
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
kernel/sysctl.c | 9 ---------
security/min_addr.c | 11 +++++++++++
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 41d4afc978e6..0c0bab3dad7d 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2059,15 +2059,6 @@ static struct ctl_table vm_table[] = {
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
},
-#ifdef CONFIG_MMU
- {
- .procname = "mmap_min_addr",
- .data = &dac_mmap_min_addr,
- .maxlen = sizeof(unsigned long),
- .mode = 0644,
- .proc_handler = mmap_min_addr_handler,
- },
-#endif
#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
(defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
{
diff --git a/security/min_addr.c b/security/min_addr.c
index 0ce267c041ab..b2f61649e110 100644
--- a/security/min_addr.c
+++ b/security/min_addr.c
@@ -44,8 +44,19 @@ int mmap_min_addr_handler(const struct ctl_table *table, int write,
return ret;
}
+static struct ctl_table min_addr_sysctl_table[] = {
+ {
+ .procname = "mmap_min_addr",
+ .data = &dac_mmap_min_addr,
+ .maxlen = sizeof(unsigned long),
+ .mode = 0644,
+ .proc_handler = mmap_min_addr_handler,
+ },
+};
+
static int __init init_mmap_min_addr(void)
{
+ register_sysctl_init("vm", min_addr_sysctl_table);
update_mmap_min_addr();
return 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 08/15] mm: nommu: move sysctl to its own file
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (6 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 07/15] security: min_addr: " Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 09/15] fs: fs-writeback: " Kaixiong Yu
` (8 subsequent siblings)
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
The sysctl_nr_trim_pages belongs to nommu.c, move it into its own file
from /kernel/sysctl.c. And remove the useless extern variable declaration
from include/linux/mm.h
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
include/linux/mm.h | 2 --
kernel/sysctl.c | 10 ----------
mm/nommu.c | 15 ++++++++++++++-
3 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 9400c92b4522..9e37d46fa666 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3972,8 +3972,6 @@ unsigned long wp_shared_mapping_range(struct address_space *mapping,
pgoff_t first_index, pgoff_t nr);
#endif
-extern int sysctl_nr_trim_pages;
-
#ifdef CONFIG_PRINTK
void mem_dump_obj(void *object);
#else
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 0c0bab3dad7d..d3de31ec74bf 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2041,16 +2041,6 @@ static struct ctl_table vm_table[] = {
.extra1 = SYSCTL_ONE,
.extra2 = SYSCTL_FOUR,
},
-#ifndef CONFIG_MMU
- {
- .procname = "nr_trim_pages",
- .data = &sysctl_nr_trim_pages,
- .maxlen = sizeof(sysctl_nr_trim_pages),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- },
-#endif
{
.procname = "vfs_cache_pressure",
.data = &sysctl_vfs_cache_pressure,
diff --git a/mm/nommu.c b/mm/nommu.c
index 385b0c15add8..983ee961dd67 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -48,7 +48,6 @@ struct page *mem_map;
unsigned long max_mapnr;
EXPORT_SYMBOL(max_mapnr);
unsigned long highest_memmap_pfn;
-int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
int heap_stack_gap = 0;
atomic_long_t mmap_pages_allocated;
@@ -392,6 +391,19 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
return mm->brk = brk;
}
+static int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
+
+static struct ctl_table nommu_table[] = {
+ {
+ .procname = "nr_trim_pages",
+ .data = &sysctl_nr_trim_pages,
+ .maxlen = sizeof(sysctl_nr_trim_pages),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ },
+}
+
/*
* initialise the percpu counter for VM and region record slabs
*/
@@ -402,6 +414,7 @@ void __init mmap_init(void)
ret = percpu_counter_init(&vm_committed_as, 0, GFP_KERNEL);
VM_BUG_ON(ret);
vm_region_jar = KMEM_CACHE(vm_region, SLAB_PANIC|SLAB_ACCOUNT);
+ register_syscall_init("vm", nommu_table);
}
/*
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 09/15] fs: fs-writeback: move sysctl to its own file
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (7 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 08/15] mm: nommu: move sysctl to " Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 10/15] fs: drop_caches: " Kaixiong Yu
` (7 subsequent siblings)
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
The dirtytime_expire_interval belongs to fs/fs-writeback.c, move it into
its own file from /kernel/sysctl.c. And remove the useless extern variable
declaration and the function declaration from include/linux/writeback.h
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
fs/fs-writeback.c | 28 ++++++++++++++++++++--------
include/linux/writeback.h | 4 ----
kernel/sysctl.c | 8 --------
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 1a5006329f6f..71ff73552323 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -2400,14 +2400,7 @@ static void wakeup_dirtytime_writeback(struct work_struct *w)
schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ);
}
-static int __init start_dirtytime_writeback(void)
-{
- schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ);
- return 0;
-}
-__initcall(start_dirtytime_writeback);
-
-int dirtytime_interval_handler(const struct ctl_table *table, int write,
+static int dirtytime_interval_handler(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
int ret;
@@ -2418,6 +2411,25 @@ int dirtytime_interval_handler(const struct ctl_table *table, int write,
return ret;
}
+static struct ctl_table vm_fs_writeback_table[] = {
+ {
+ .procname = "dirtytime_expire_seconds",
+ .data = &dirtytime_expire_interval,
+ .maxlen = sizeof(dirtytime_expire_interval),
+ .mode = 0644,
+ .proc_handler = dirtytime_interval_handler,
+ .extra1 = SYSCTL_ZERO,
+ },
+};
+
+static int __init start_dirtytime_writeback(void)
+{
+ schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ);
+ register_sysctl_init("vm", vm_fs_writeback_table);
+ return 0;
+}
+__initcall(start_dirtytime_writeback);
+
/**
* __mark_inode_dirty - internal function to mark an inode dirty
*
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index 21dac644d325..22bc047ed91e 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -351,12 +351,8 @@ extern struct wb_domain global_wb_domain;
/* These are exported to sysctl. */
extern unsigned int dirty_writeback_interval;
extern unsigned int dirty_expire_interval;
-extern unsigned int dirtytime_expire_interval;
extern int laptop_mode;
-int dirtytime_interval_handler(const struct ctl_table *table, int write,
- void *buffer, size_t *lenp, loff_t *ppos);
-
void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh);
unsigned long cgwb_calc_thresh(struct bdi_writeback *wb);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index d3de31ec74bf..373e018b950c 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2024,14 +2024,6 @@ static struct ctl_table kern_table[] = {
};
static struct ctl_table vm_table[] = {
- {
- .procname = "dirtytime_expire_seconds",
- .data = &dirtytime_expire_interval,
- .maxlen = sizeof(dirtytime_expire_interval),
- .mode = 0644,
- .proc_handler = dirtytime_interval_handler,
- .extra1 = SYSCTL_ZERO,
- },
{
.procname = "drop_caches",
.data = &sysctl_drop_caches,
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 10/15] fs: drop_caches: move sysctl to its own file
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (8 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 09/15] fs: fs-writeback: " Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 11/15] sunrpc: use vfs_pressure_ratio() helper Kaixiong Yu
` (6 subsequent siblings)
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
The sysctl_drop_caches to fs/drop_caches.c, move it into
its own file from /kernel/sysctl.c. And remove the useless
extern variable declaration from include/linux/mm.h
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
fs/drop_caches.c | 23 +++++++++++++++++++++--
include/linux/mm.h | 6 ------
kernel/sysctl.c | 9 ---------
3 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index d45ef541d848..f2551ace800f 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -14,7 +14,7 @@
#include "internal.h"
/* A global variable is a bit ugly, but it keeps the code simple */
-int sysctl_drop_caches;
+static int sysctl_drop_caches;
static void drop_pagecache_sb(struct super_block *sb, void *unused)
{
@@ -48,7 +48,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
iput(toput_inode);
}
-int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
+static int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
void *buffer, size_t *length, loff_t *ppos)
{
int ret;
@@ -77,3 +77,22 @@ int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
}
return 0;
}
+
+static struct ctl_table drop_caches_table[] = {
+ {
+ .procname = "drop_caches",
+ .data = &sysctl_drop_caches,
+ .maxlen = sizeof(int),
+ .mode = 0200,
+ .proc_handler = drop_caches_sysctl_handler,
+ .extra1 = SYSCTL_ONE,
+ .extra2 = SYSCTL_FOUR,
+ },
+};
+
+static int __init init_vm_drop_caches_sysctls(void)
+{
+ register_sysctl_init("vm", drop_caches_table);
+ return 0;
+}
+fs_initcall(init_vm_drop_caches_sysctls);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 9e37d46fa666..a297a298542c 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3693,12 +3693,6 @@ static inline int in_gate_area(struct mm_struct *mm, unsigned long addr)
extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm);
-#ifdef CONFIG_SYSCTL
-extern int sysctl_drop_caches;
-int drop_caches_sysctl_handler(const struct ctl_table *, int, void *, size_t *,
- loff_t *);
-#endif
-
void drop_slab(void);
#ifndef CONFIG_MMU
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 373e018b950c..d638a1bac9af 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2024,15 +2024,6 @@ static struct ctl_table kern_table[] = {
};
static struct ctl_table vm_table[] = {
- {
- .procname = "drop_caches",
- .data = &sysctl_drop_caches,
- .maxlen = sizeof(int),
- .mode = 0200,
- .proc_handler = drop_caches_sysctl_handler,
- .extra1 = SYSCTL_ONE,
- .extra2 = SYSCTL_FOUR,
- },
{
.procname = "vfs_cache_pressure",
.data = &sysctl_vfs_cache_pressure,
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 11/15] sunrpc: use vfs_pressure_ratio() helper
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (9 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 10/15] fs: drop_caches: " Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 12/15] fs: dcache: move the sysctl into its own file Kaixiong Yu
` (5 subsequent siblings)
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
Use vfs_pressure_ratio() to simplify code.
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
net/sunrpc/auth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 04534ea537c8..3d2b51d7e934 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -489,7 +489,7 @@ static unsigned long
rpcauth_cache_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
{
- return number_cred_unused * sysctl_vfs_cache_pressure / 100;
+ return vfs_pressure_ratio(number_cred_unused);
}
static void
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 12/15] fs: dcache: move the sysctl into its own file
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (10 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 11/15] sunrpc: use vfs_pressure_ratio() helper Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 19:56 ` Kees Cook
2024-09-02 11:17 ` Christian Brauner
2024-08-26 12:04 ` [PATCH -next 13/15] x86: vdso: " Kaixiong Yu
` (4 subsequent siblings)
16 siblings, 2 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
The sysctl_vfs_cache_pressure belongs to fs/dcache.c, move it to
its own file from kernel/sysctl.c. As a part of fs/dcache.c cleaning,
sysctl_vfs_cache_pressure is changed to a static variable, and export
vfs_pressure_ratio with EXPORT_SYMBOL_GPL to be used by other files.
And move the unneeded include(linux/dcache.h).
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
fs/dcache.c | 21 +++++++++++++++++++--
include/linux/dcache.h | 7 +------
kernel/sysctl.c | 9 ---------
3 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index 1af75fa68638..8717d5026cda 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -73,8 +73,13 @@
* If no ancestor relationship:
* arbitrary, since it's serialized on rename_lock
*/
-int sysctl_vfs_cache_pressure __read_mostly = 100;
-EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure);
+static int sysctl_vfs_cache_pressure __read_mostly = 100;
+
+unsigned long vfs_pressure_ratio(unsigned long val)
+{
+ return mult_frac(val, sysctl_vfs_cache_pressure, 100);
+}
+EXPORT_SYMBOL_GPL(vfs_pressure_ratio);
__cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock);
@@ -196,8 +201,20 @@ static struct ctl_table fs_dcache_sysctls[] = {
},
};
+static struct ctl_table vm_dcache_sysctls[] = {
+ {
+ .procname = "vfs_cache_pressure",
+ .data = &sysctl_vfs_cache_pressure,
+ .maxlen = sizeof(sysctl_vfs_cache_pressure),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ },
+};
+
static int __init init_fs_dcache_sysctls(void)
{
+ register_sysctl_init("vm", vm_dcache_sysctls);
register_sysctl_init("fs", fs_dcache_sysctls);
return 0;
}
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index bff956f7b2b9..c81c2e9e13df 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -508,12 +508,7 @@ static inline int simple_positive(const struct dentry *dentry)
return d_really_is_positive(dentry) && !d_unhashed(dentry);
}
-extern int sysctl_vfs_cache_pressure;
-
-static inline unsigned long vfs_pressure_ratio(unsigned long val)
-{
- return mult_frac(val, sysctl_vfs_cache_pressure, 100);
-}
+unsigned long vfs_pressure_ratio(unsigned long val);
/**
* d_inode - Get the actual inode of this dentry
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index d638a1bac9af..6f03fc749794 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -46,7 +46,6 @@
#include <linux/key.h>
#include <linux/times.h>
#include <linux/limits.h>
-#include <linux/dcache.h>
#include <linux/syscalls.h>
#include <linux/nfs_fs.h>
#include <linux/acpi.h>
@@ -2024,14 +2023,6 @@ static struct ctl_table kern_table[] = {
};
static struct ctl_table vm_table[] = {
- {
- .procname = "vfs_cache_pressure",
- .data = &sysctl_vfs_cache_pressure,
- .maxlen = sizeof(sysctl_vfs_cache_pressure),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- },
#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
(defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
{
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 13/15] x86: vdso: move the sysctl into its own file
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (11 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 12/15] fs: dcache: move the sysctl into its own file Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 14/15] sh: " Kaixiong Yu
` (3 subsequent siblings)
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
When CONFIG_X86_32 is defined and CONFIG_UML is not defined,
vdso_enabled belongs to arch/x86/entry/vdso/vdso32-setup.c.
So, move it into its own file.
Before this patch, vdso_enabled was allowed to be set to
a value exceeding 1 on x86_32 architecture. After this patch is
applied, vdso_enabled is not permitted to set the value more than 1.
It does not matter, because according to the function load_vdso32(),
only vdso_enabled is set to 1, VDSO would be enabled. Other values
all mean "disabled". The same limitation could be seen in the
function vdso32_setup().
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
arch/x86/entry/vdso/vdso32-setup.c | 16 +++++++++++-----
kernel/sysctl.c | 8 +-------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/arch/x86/entry/vdso/vdso32-setup.c b/arch/x86/entry/vdso/vdso32-setup.c
index 76e4e74f35b5..5a6886a006ab 100644
--- a/arch/x86/entry/vdso/vdso32-setup.c
+++ b/arch/x86/entry/vdso/vdso32-setup.c
@@ -51,15 +51,17 @@ __setup("vdso32=", vdso32_setup);
__setup_param("vdso=", vdso_setup, vdso32_setup, 0);
#endif
-#ifdef CONFIG_X86_64
#ifdef CONFIG_SYSCTL
-/* Register vsyscall32 into the ABI table */
#include <linux/sysctl.h>
-static struct ctl_table abi_table2[] = {
+static struct ctl_table vdso_table[] = {
{
+#ifdef CONFIG_X86_64
.procname = "vsyscall32",
+#elif (defined(CONFIG_X86_32) && !defined(CONFIG_UML))
+ .procname = "vdso_enabled",
+#endif
.data = &vdso32_enabled,
.maxlen = sizeof(int),
.mode = 0644,
@@ -71,10 +73,14 @@ static struct ctl_table abi_table2[] = {
static __init int ia32_binfmt_init(void)
{
- register_sysctl("abi", abi_table2);
+#ifdef CONFIG_X86_64
+ /* Register vsyscall32 into the ABI table */
+ register_sysctl("abi", vdso_table);
+#elif (defined(CONFIG_X86_32) && !defined(CONFIG_UML))
+ register_sysctl_init("vm", vdso_table);
+#endif
return 0;
}
__initcall(ia32_binfmt_init);
#endif /* CONFIG_SYSCTL */
-#endif /* CONFIG_X86_64 */
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 6f03fc749794..24617be93119 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2023,17 +2023,11 @@ static struct ctl_table kern_table[] = {
};
static struct ctl_table vm_table[] = {
-#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
- (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
+#if defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)
{
.procname = "vdso_enabled",
-#ifdef CONFIG_X86_32
- .data = &vdso32_enabled,
- .maxlen = sizeof(vdso32_enabled),
-#else
.data = &vdso_enabled,
.maxlen = sizeof(vdso_enabled),
-#endif
.mode = 0644,
.proc_handler = proc_dointvec,
.extra1 = SYSCTL_ZERO,
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 14/15] sh: vdso: move the sysctl into its own file
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (12 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 13/15] x86: vdso: " Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 15/15] sysctl: remove unneeded include Kaixiong Yu
` (2 subsequent siblings)
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
When CONFIG_SUPERH and CONFIG_VSYSCALL are defined,
vdso_enabled belongs to arch/sh/kernel/vsyscall/vsyscall.c.
So, move it into its own file. After this patch is applied,
all sysctls of vm_table would be moved. So, delete vm_table.
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
arch/sh/kernel/vsyscall/vsyscall.c | 14 ++++++++++++++
kernel/sysctl.c | 14 --------------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/arch/sh/kernel/vsyscall/vsyscall.c b/arch/sh/kernel/vsyscall/vsyscall.c
index add35c51e017..43bc3715e38c 100644
--- a/arch/sh/kernel/vsyscall/vsyscall.c
+++ b/arch/sh/kernel/vsyscall/vsyscall.c
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/elf.h>
#include <linux/sched.h>
+#include <linux/sysctl.h>
#include <linux/err.h>
/*
@@ -30,6 +31,17 @@ static int __init vdso_setup(char *s)
}
__setup("vdso=", vdso_setup);
+static struct ctl_table vdso_table[] = {
+ {
+ .procname = "vdso_enabled",
+ .data = &vdso_enabled,
+ .maxlen = sizeof(vdso_enabled),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ .extra1 = SYSCTL_ZERO,
+ },
+};
+
/*
* These symbols are defined by vsyscall.o to mark the bounds
* of the ELF DSO images included therein.
@@ -55,6 +67,8 @@ int __init vsyscall_init(void)
&vsyscall_trapa_start,
&vsyscall_trapa_end - &vsyscall_trapa_start);
+ register_sysctl_init("vm", vdso_table);
+
return 0;
}
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 24617be93119..f04da9f3abc6 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2022,23 +2022,9 @@ static struct ctl_table kern_table[] = {
#endif
};
-static struct ctl_table vm_table[] = {
-#if defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)
- {
- .procname = "vdso_enabled",
- .data = &vdso_enabled,
- .maxlen = sizeof(vdso_enabled),
- .mode = 0644,
- .proc_handler = proc_dointvec,
- .extra1 = SYSCTL_ZERO,
- },
-#endif
-};
-
int __init sysctl_init_bases(void)
{
register_sysctl_init("kernel", kern_table);
- register_sysctl_init("vm", vm_table);
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH -next 15/15] sysctl: remove unneeded include
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (13 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 14/15] sh: " Kaixiong Yu
@ 2024-08-26 12:04 ` Kaixiong Yu
2024-08-26 19:57 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kees Cook
2024-09-02 7:17 ` Joel Granados
16 siblings, 0 replies; 27+ messages in thread
From: Kaixiong Yu @ 2024-08-26 12:04 UTC (permalink / raw)
To: akpm, mcgrof
Cc: ysato, dalias, glaubitz, luto, tglx, bp, dave.hansen, hpa, viro,
brauner, jack, kees, j.granados, willy, Liam.Howlett, vbabka,
lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton, neilb,
okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni, paul,
jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
Removing unneeded mm includes in kernel/sysctl.c.
Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
---
kernel/sysctl.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index f04da9f3abc6..6e3e0ce4da79 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -20,8 +20,6 @@
*/
#include <linux/module.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
#include <linux/sysctl.h>
#include <linux/bitmap.h>
#include <linux/signal.h>
@@ -30,7 +28,6 @@
#include <linux/proc_fs.h>
#include <linux/security.h>
#include <linux/ctype.h>
-#include <linux/kmemleak.h>
#include <linux/filter.h>
#include <linux/fs.h>
#include <linux/init.h>
@@ -41,7 +38,6 @@
#include <linux/highuid.h>
#include <linux/writeback.h>
#include <linux/ratelimit.h>
-#include <linux/hugetlb.h>
#include <linux/initrd.h>
#include <linux/key.h>
#include <linux/times.h>
@@ -52,13 +48,11 @@
#include <linux/reboot.h>
#include <linux/ftrace.h>
#include <linux/perf_event.h>
-#include <linux/oom.h>
#include <linux/kmod.h>
#include <linux/capability.h>
#include <linux/binfmts.h>
#include <linux/sched/sysctl.h>
#include <linux/mount.h>
-#include <linux/userfaultfd_k.h>
#include <linux/pid.h>
#include "../lib/kstrtox.h"
--
2.25.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH -next 12/15] fs: dcache: move the sysctl into its own file
2024-08-26 12:04 ` [PATCH -next 12/15] fs: dcache: move the sysctl into its own file Kaixiong Yu
@ 2024-08-26 19:56 ` Kees Cook
2024-09-02 11:04 ` Jan Kara
2024-09-02 11:17 ` Christian Brauner
1 sibling, 1 reply; 27+ messages in thread
From: Kees Cook @ 2024-08-26 19:56 UTC (permalink / raw)
To: Kaixiong Yu
Cc: akpm, mcgrof, ysato, dalias, glaubitz, luto, tglx, bp,
dave.hansen, hpa, viro, brauner, jack, j.granados, willy,
Liam.Howlett, vbabka, lorenzo.stoakes, trondmy, anna, chuck.lever,
jlayton, neilb, okorniev, Dai.Ngo, tom, davem, edumazet, kuba,
pabeni, paul, jmorris, linux-sh, linux-kernel, linux-fsdevel,
linux-mm, linux-nfs, netdev, linux-security-module,
wangkefeng.wang
On Mon, Aug 26, 2024 at 08:04:46PM +0800, Kaixiong Yu wrote:
> The sysctl_vfs_cache_pressure belongs to fs/dcache.c, move it to
> its own file from kernel/sysctl.c. As a part of fs/dcache.c cleaning,
> sysctl_vfs_cache_pressure is changed to a static variable, and export
> vfs_pressure_ratio with EXPORT_SYMBOL_GPL to be used by other files.
> And move the unneeded include(linux/dcache.h).
>
> Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
> ---
> fs/dcache.c | 21 +++++++++++++++++++--
> include/linux/dcache.h | 7 +------
> kernel/sysctl.c | 9 ---------
> 3 files changed, 20 insertions(+), 17 deletions(-)
>
> diff --git a/fs/dcache.c b/fs/dcache.c
> index 1af75fa68638..8717d5026cda 100644
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -73,8 +73,13 @@
> * If no ancestor relationship:
> * arbitrary, since it's serialized on rename_lock
> */
> -int sysctl_vfs_cache_pressure __read_mostly = 100;
> -EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure);
> +static int sysctl_vfs_cache_pressure __read_mostly = 100;
> +
> +unsigned long vfs_pressure_ratio(unsigned long val)
> +{
> + return mult_frac(val, sysctl_vfs_cache_pressure, 100);
> +}
> +EXPORT_SYMBOL_GPL(vfs_pressure_ratio);
This was a static inline, but AFAICT it's only called through
alloc_super() which is hardly "fast path". If this series gets another
version it may be worth calling out this inline->out-of-line change in
the commit log.
I don't think it's a blocker, but I'm not a VFS maintainer. :)
--
Kees Cook
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (14 preceding siblings ...)
2024-08-26 12:04 ` [PATCH -next 15/15] sysctl: remove unneeded include Kaixiong Yu
@ 2024-08-26 19:57 ` Kees Cook
2024-08-27 2:03 ` yukaixiong
2024-09-02 7:17 ` Joel Granados
16 siblings, 1 reply; 27+ messages in thread
From: Kees Cook @ 2024-08-26 19:57 UTC (permalink / raw)
To: Kaixiong Yu
Cc: akpm, mcgrof, ysato, dalias, glaubitz, luto, tglx, bp,
dave.hansen, hpa, viro, brauner, jack, j.granados, willy,
Liam.Howlett, vbabka, lorenzo.stoakes, trondmy, anna, chuck.lever,
jlayton, neilb, okorniev, Dai.Ngo, tom, davem, edumazet, kuba,
pabeni, paul, jmorris, linux-sh, linux-kernel, linux-fsdevel,
linux-mm, linux-nfs, netdev, linux-security-module,
wangkefeng.wang
On Mon, Aug 26, 2024 at 08:04:34PM +0800, Kaixiong Yu wrote:
> This patch series moves sysctls of vm_table in kernel/sysctl.c to
> places where they actually belong, and do some related code clean-ups.
> After this patch series, all sysctls in vm_table have been moved into its
> own files, meanwhile, delete vm_table.
This is really nice! Thanks for doing this migration. I sent a note
about the "fs: dcache: ..." patch that I don't think will be a problem.
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH -next 07/15] security: min_addr: move sysctl into its own file
2024-08-26 12:04 ` [PATCH -next 07/15] security: min_addr: " Kaixiong Yu
@ 2024-08-26 22:49 ` Paul Moore
2024-08-27 1:38 ` yukaixiong
0 siblings, 1 reply; 27+ messages in thread
From: Paul Moore @ 2024-08-26 22:49 UTC (permalink / raw)
To: Kaixiong Yu
Cc: akpm, mcgrof, ysato, dalias, glaubitz, luto, tglx, bp,
dave.hansen, hpa, viro, brauner, jack, kees, j.granados, willy,
Liam.Howlett, vbabka, lorenzo.stoakes, trondmy, anna, chuck.lever,
jlayton, neilb, okorniev, Dai.Ngo, tom, davem, edumazet, kuba,
pabeni, jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
On Mon, Aug 26, 2024 at 8:05 AM Kaixiong Yu <yukaixiong@huawei.com> wrote:
>
> The dac_mmap_min_addr belongs to min_addr.c, move it into
> its own file from /kernel/sysctl.c. In the previous Linux kernel
> boot process, sysctl_init_bases needs to be executed before
> init_mmap_min_addr, So, register_sysctl_init should be executed
> before update_mmap_min_addr in init_mmap_min_addr.
>
> Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
> ---
> kernel/sysctl.c | 9 ---------
> security/min_addr.c | 11 +++++++++++
> 2 files changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 41d4afc978e6..0c0bab3dad7d 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -2059,15 +2059,6 @@ static struct ctl_table vm_table[] = {
> .proc_handler = proc_dointvec_minmax,
> .extra1 = SYSCTL_ZERO,
> },
> -#ifdef CONFIG_MMU
> - {
> - .procname = "mmap_min_addr",
> - .data = &dac_mmap_min_addr,
> - .maxlen = sizeof(unsigned long),
> - .mode = 0644,
> - .proc_handler = mmap_min_addr_handler,
> - },
> -#endif
> #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
> (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
> {
> diff --git a/security/min_addr.c b/security/min_addr.c
> index 0ce267c041ab..b2f61649e110 100644
> --- a/security/min_addr.c
> +++ b/security/min_addr.c
> @@ -44,8 +44,19 @@ int mmap_min_addr_handler(const struct ctl_table *table, int write,
> return ret;
> }
>
> +static struct ctl_table min_addr_sysctl_table[] = {
> + {
> + .procname = "mmap_min_addr",
> + .data = &dac_mmap_min_addr,
> + .maxlen = sizeof(unsigned long),
> + .mode = 0644,
> + .proc_handler = mmap_min_addr_handler,
> + },
> +};
I haven't chased all of the Kconfig deps to see if there is a problem,
but please provide a quick explanation in the commit description about
why it is okay to drop the CONFIG_MMU check.
> static int __init init_mmap_min_addr(void)
> {
> + register_sysctl_init("vm", min_addr_sysctl_table);
> update_mmap_min_addr();
>
> return 0;
> --
> 2.25.1
--
paul-moore.com
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH -next 07/15] security: min_addr: move sysctl into its own file
2024-08-26 22:49 ` Paul Moore
@ 2024-08-27 1:38 ` yukaixiong
2024-08-27 1:56 ` Paul Moore
0 siblings, 1 reply; 27+ messages in thread
From: yukaixiong @ 2024-08-27 1:38 UTC (permalink / raw)
To: Paul Moore
Cc: akpm, mcgrof, ysato, dalias, glaubitz, luto, tglx, bp,
dave.hansen, hpa, viro, brauner, jack, kees, j.granados, willy,
Liam.Howlett, vbabka, lorenzo.stoakes, trondmy, anna, chuck.lever,
jlayton, neilb, okorniev, Dai.Ngo, tom, davem, edumazet, kuba,
pabeni, jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
On 2024/8/27 6:49, Paul Moore wrote:
> On Mon, Aug 26, 2024 at 8:05 AM Kaixiong Yu <yukaixiong@huawei.com> wrote:
>> The dac_mmap_min_addr belongs to min_addr.c, move it into
>> its own file from /kernel/sysctl.c. In the previous Linux kernel
>> boot process, sysctl_init_bases needs to be executed before
>> init_mmap_min_addr, So, register_sysctl_init should be executed
>> before update_mmap_min_addr in init_mmap_min_addr.
>>
>> Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
>> ---
>> kernel/sysctl.c | 9 ---------
>> security/min_addr.c | 11 +++++++++++
>> 2 files changed, 11 insertions(+), 9 deletions(-)
>>
>> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
>> index 41d4afc978e6..0c0bab3dad7d 100644
>> --- a/kernel/sysctl.c
>> +++ b/kernel/sysctl.c
>> @@ -2059,15 +2059,6 @@ static struct ctl_table vm_table[] = {
>> .proc_handler = proc_dointvec_minmax,
>> .extra1 = SYSCTL_ZERO,
>> },
>> -#ifdef CONFIG_MMU
>> - {
>> - .procname = "mmap_min_addr",
>> - .data = &dac_mmap_min_addr,
>> - .maxlen = sizeof(unsigned long),
>> - .mode = 0644,
>> - .proc_handler = mmap_min_addr_handler,
>> - },
>> -#endif
>> #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
>> (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
>> {
>> diff --git a/security/min_addr.c b/security/min_addr.c
>> index 0ce267c041ab..b2f61649e110 100644
>> --- a/security/min_addr.c
>> +++ b/security/min_addr.c
>> @@ -44,8 +44,19 @@ int mmap_min_addr_handler(const struct ctl_table *table, int write,
>> return ret;
>> }
>>
>> +static struct ctl_table min_addr_sysctl_table[] = {
>> + {
>> + .procname = "mmap_min_addr",
>> + .data = &dac_mmap_min_addr,
>> + .maxlen = sizeof(unsigned long),
>> + .mode = 0644,
>> + .proc_handler = mmap_min_addr_handler,
>> + },
>> +};
> I haven't chased all of the Kconfig deps to see if there is a problem,
> but please provide a quick explanation in the commit description about
> why it is okay to drop the CONFIG_MMU check.
According to the compilation condition in security/Makefile:
obj-$(CONFIG_MMU) += min_addr.o
if CONFIG_MMU is not defined, min_addr.c would not be included in the
compilation process.
So,it is okay to drop the CONFIG_MMU check.
>> static int __init init_mmap_min_addr(void)
>> {
>> + register_sysctl_init("vm", min_addr_sysctl_table);
>> update_mmap_min_addr();
>>
>> return 0;
>> --
>> 2.25.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH -next 07/15] security: min_addr: move sysctl into its own file
2024-08-27 1:38 ` yukaixiong
@ 2024-08-27 1:56 ` Paul Moore
2024-08-27 2:43 ` yukaixiong
0 siblings, 1 reply; 27+ messages in thread
From: Paul Moore @ 2024-08-27 1:56 UTC (permalink / raw)
To: yukaixiong
Cc: akpm, mcgrof, ysato, dalias, glaubitz, luto, tglx, bp,
dave.hansen, hpa, viro, brauner, jack, kees, j.granados, willy,
Liam.Howlett, vbabka, lorenzo.stoakes, trondmy, anna, chuck.lever,
jlayton, neilb, okorniev, Dai.Ngo, tom, davem, edumazet, kuba,
pabeni, jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
On Mon, Aug 26, 2024 at 9:38 PM yukaixiong <yukaixiong@huawei.com> wrote:
> On 2024/8/27 6:49, Paul Moore wrote:
> > On Mon, Aug 26, 2024 at 8:05 AM Kaixiong Yu <yukaixiong@huawei.com> wrote:
> >> The dac_mmap_min_addr belongs to min_addr.c, move it into
> >> its own file from /kernel/sysctl.c. In the previous Linux kernel
> >> boot process, sysctl_init_bases needs to be executed before
> >> init_mmap_min_addr, So, register_sysctl_init should be executed
> >> before update_mmap_min_addr in init_mmap_min_addr.
> >>
> >> Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
> >> ---
> >> kernel/sysctl.c | 9 ---------
> >> security/min_addr.c | 11 +++++++++++
> >> 2 files changed, 11 insertions(+), 9 deletions(-)
> >>
> >> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> >> index 41d4afc978e6..0c0bab3dad7d 100644
> >> --- a/kernel/sysctl.c
> >> +++ b/kernel/sysctl.c
> >> @@ -2059,15 +2059,6 @@ static struct ctl_table vm_table[] = {
> >> .proc_handler = proc_dointvec_minmax,
> >> .extra1 = SYSCTL_ZERO,
> >> },
> >> -#ifdef CONFIG_MMU
> >> - {
> >> - .procname = "mmap_min_addr",
> >> - .data = &dac_mmap_min_addr,
> >> - .maxlen = sizeof(unsigned long),
> >> - .mode = 0644,
> >> - .proc_handler = mmap_min_addr_handler,
> >> - },
> >> -#endif
> >> #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
> >> (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
> >> {
> >> diff --git a/security/min_addr.c b/security/min_addr.c
> >> index 0ce267c041ab..b2f61649e110 100644
> >> --- a/security/min_addr.c
> >> +++ b/security/min_addr.c
> >> @@ -44,8 +44,19 @@ int mmap_min_addr_handler(const struct ctl_table *table, int write,
> >> return ret;
> >> }
> >>
> >> +static struct ctl_table min_addr_sysctl_table[] = {
> >> + {
> >> + .procname = "mmap_min_addr",
> >> + .data = &dac_mmap_min_addr,
> >> + .maxlen = sizeof(unsigned long),
> >> + .mode = 0644,
> >> + .proc_handler = mmap_min_addr_handler,
> >> + },
> >> +};
> >
> > I haven't chased all of the Kconfig deps to see if there is a problem,
> > but please provide a quick explanation in the commit description about
> > why it is okay to drop the CONFIG_MMU check.
>
> According to the compilation condition in security/Makefile:
>
> obj-$(CONFIG_MMU) += min_addr.o
>
> if CONFIG_MMU is not defined, min_addr.c would not be included in the
> compilation process.
> So,it is okay to drop the CONFIG_MMU check.
Great, please add some text about that in the commit description as it
is an important difference in the code changes that isn't currently
documented in the patch.
--
paul-moore.com
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files
2024-08-26 19:57 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kees Cook
@ 2024-08-27 2:03 ` yukaixiong
0 siblings, 0 replies; 27+ messages in thread
From: yukaixiong @ 2024-08-27 2:03 UTC (permalink / raw)
To: Kees Cook
Cc: akpm, mcgrof, ysato, dalias, glaubitz, luto, tglx, bp,
dave.hansen, hpa, viro, brauner, jack, j.granados, willy,
Liam.Howlett, vbabka, lorenzo.stoakes, trondmy, anna, chuck.lever,
jlayton, neilb, okorniev, Dai.Ngo, tom, davem, edumazet, kuba,
pabeni, paul, jmorris, linux-sh, linux-kernel, linux-fsdevel,
linux-mm, linux-nfs, netdev, linux-security-module,
wangkefeng.wang
On 2024/8/27 3:57, Kees Cook wrote:
> On Mon, Aug 26, 2024 at 08:04:34PM +0800, Kaixiong Yu wrote:
>> This patch series moves sysctls of vm_table in kernel/sysctl.c to
>> places where they actually belong, and do some related code clean-ups.
>> After this patch series, all sysctls in vm_table have been moved into its
>> own files, meanwhile, delete vm_table.
> This is really nice! Thanks for doing this migration. I sent a note
> about the "fs: dcache: ..." patch that I don't think will be a problem.
>
> Reviewed-by: Kees Cook <kees@kernel.org>
>
Thanks for your review !:-) Looking forward to future opportunities for
further discussion and collaboration.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH -next 07/15] security: min_addr: move sysctl into its own file
2024-08-27 1:56 ` Paul Moore
@ 2024-08-27 2:43 ` yukaixiong
0 siblings, 0 replies; 27+ messages in thread
From: yukaixiong @ 2024-08-27 2:43 UTC (permalink / raw)
To: Paul Moore
Cc: akpm, mcgrof, ysato, dalias, glaubitz, luto, tglx, bp,
dave.hansen, hpa, viro, brauner, jack, kees, j.granados, willy,
Liam.Howlett, vbabka, lorenzo.stoakes, trondmy, anna, chuck.lever,
jlayton, neilb, okorniev, Dai.Ngo, tom, davem, edumazet, kuba,
pabeni, jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
On 2024/8/27 9:56, Paul Moore wrote:
> On Mon, Aug 26, 2024 at 9:38 PM yukaixiong <yukaixiong@huawei.com> wrote:
>> On 2024/8/27 6:49, Paul Moore wrote:
>>> On Mon, Aug 26, 2024 at 8:05 AM Kaixiong Yu <yukaixiong@huawei.com> wrote:
>>>> The dac_mmap_min_addr belongs to min_addr.c, move it into
>>>> its own file from /kernel/sysctl.c. In the previous Linux kernel
>>>> boot process, sysctl_init_bases needs to be executed before
>>>> init_mmap_min_addr, So, register_sysctl_init should be executed
>>>> before update_mmap_min_addr in init_mmap_min_addr.
>>>>
>>>> Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
>>>> ---
>>>> kernel/sysctl.c | 9 ---------
>>>> security/min_addr.c | 11 +++++++++++
>>>> 2 files changed, 11 insertions(+), 9 deletions(-)
>>>>
>>>> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
>>>> index 41d4afc978e6..0c0bab3dad7d 100644
>>>> --- a/kernel/sysctl.c
>>>> +++ b/kernel/sysctl.c
>>>> @@ -2059,15 +2059,6 @@ static struct ctl_table vm_table[] = {
>>>> .proc_handler = proc_dointvec_minmax,
>>>> .extra1 = SYSCTL_ZERO,
>>>> },
>>>> -#ifdef CONFIG_MMU
>>>> - {
>>>> - .procname = "mmap_min_addr",
>>>> - .data = &dac_mmap_min_addr,
>>>> - .maxlen = sizeof(unsigned long),
>>>> - .mode = 0644,
>>>> - .proc_handler = mmap_min_addr_handler,
>>>> - },
>>>> -#endif
>>>> #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
>>>> (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
>>>> {
>>>> diff --git a/security/min_addr.c b/security/min_addr.c
>>>> index 0ce267c041ab..b2f61649e110 100644
>>>> --- a/security/min_addr.c
>>>> +++ b/security/min_addr.c
>>>> @@ -44,8 +44,19 @@ int mmap_min_addr_handler(const struct ctl_table *table, int write,
>>>> return ret;
>>>> }
>>>>
>>>> +static struct ctl_table min_addr_sysctl_table[] = {
>>>> + {
>>>> + .procname = "mmap_min_addr",
>>>> + .data = &dac_mmap_min_addr,
>>>> + .maxlen = sizeof(unsigned long),
>>>> + .mode = 0644,
>>>> + .proc_handler = mmap_min_addr_handler,
>>>> + },
>>>> +};
>>> I haven't chased all of the Kconfig deps to see if there is a problem,
>>> but please provide a quick explanation in the commit description about
>>> why it is okay to drop the CONFIG_MMU check.
>> According to the compilation condition in security/Makefile:
>>
>> obj-$(CONFIG_MMU) += min_addr.o
>>
>> if CONFIG_MMU is not defined, min_addr.c would not be included in the
>> compilation process.
>> So,it is okay to drop the CONFIG_MMU check.
> Great, please add some text about that in the commit description as it
> is an important difference in the code changes that isn't currently
> documented in the patch.
ok, I will add the related text in this patch series v2.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
` (15 preceding siblings ...)
2024-08-26 19:57 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kees Cook
@ 2024-09-02 7:17 ` Joel Granados
2024-09-02 10:55 ` yukaixiong
16 siblings, 1 reply; 27+ messages in thread
From: Joel Granados @ 2024-09-02 7:17 UTC (permalink / raw)
To: Kaixiong Yu
Cc: akpm, mcgrof, ysato, dalias, glaubitz, luto, tglx, bp,
dave.hansen, hpa, viro, brauner, jack, kees, willy, Liam.Howlett,
vbabka, lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton,
neilb, okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni,
paul, jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
On Mon, Aug 26, 2024 at 08:04:34PM +0800, Kaixiong Yu wrote:
> This patch series moves sysctls of vm_table in kernel/sysctl.c to
> places where they actually belong, and do some related code clean-ups.
> After this patch series, all sysctls in vm_table have been moved into its
> own files, meanwhile, delete vm_table.
>
> All the modifications of this patch series base on
> linux-next(tags/next-20240823). To test this patch series, the code was
> compiled with both the CONFIG_SYSCTL enabled and disabled on arm64 and
> x86_64 architectures. After this patch series is applied, all files
> under /proc/sys/vm can be read or written normally.
>
> Kaixiong Yu (15):
> mm: vmstat: move sysctls to its own files
> mm: filemap: move sysctl to its own file
> mm: swap: move sysctl to its own file
> mm: vmscan: move vmscan sysctls to its own file
> mm: util: move sysctls into it own files
> mm: mmap: move sysctl into its own file
> security: min_addr: move sysctl into its own file
> mm: nommu: move sysctl to its own file
> fs: fs-writeback: move sysctl to its own file
> fs: drop_caches: move sysctl to its own file
> sunrpc: use vfs_pressure_ratio() helper
> fs: dcache: move the sysctl into its own file
> x86: vdso: move the sysctl into its own file
> sh: vdso: move the sysctl into its own file
> sysctl: remove unneeded include
>
Thx for this.
I passed this through 0-day testing and it return some errors. Please
address those build errors/regrssions before you send V2.
Best
--
Joel Granados
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files
2024-09-02 7:17 ` Joel Granados
@ 2024-09-02 10:55 ` yukaixiong
0 siblings, 0 replies; 27+ messages in thread
From: yukaixiong @ 2024-09-02 10:55 UTC (permalink / raw)
To: Joel Granados
Cc: akpm, mcgrof, ysato, dalias, glaubitz, luto, tglx, bp,
dave.hansen, hpa, viro, brauner, jack, kees, willy, Liam.Howlett,
vbabka, lorenzo.stoakes, trondmy, anna, chuck.lever, jlayton,
neilb, okorniev, Dai.Ngo, tom, davem, edumazet, kuba, pabeni,
paul, jmorris, linux-sh, linux-kernel, linux-fsdevel, linux-mm,
linux-nfs, netdev, linux-security-module, wangkefeng.wang
On 2024/9/2 15:17, Joel Granados wrote:
> On Mon, Aug 26, 2024 at 08:04:34PM +0800, Kaixiong Yu wrote:
>> This patch series moves sysctls of vm_table in kernel/sysctl.c to
>> places where they actually belong, and do some related code clean-ups.
>> After this patch series, all sysctls in vm_table have been moved into its
>> own files, meanwhile, delete vm_table.
>>
>> All the modifications of this patch series base on
>> linux-next(tags/next-20240823). To test this patch series, the code was
>> compiled with both the CONFIG_SYSCTL enabled and disabled on arm64 and
>> x86_64 architectures. After this patch series is applied, all files
>> under /proc/sys/vm can be read or written normally.
>>
>> Kaixiong Yu (15):
>> mm: vmstat: move sysctls to its own files
>> mm: filemap: move sysctl to its own file
>> mm: swap: move sysctl to its own file
>> mm: vmscan: move vmscan sysctls to its own file
>> mm: util: move sysctls into it own files
>> mm: mmap: move sysctl into its own file
>> security: min_addr: move sysctl into its own file
>> mm: nommu: move sysctl to its own file
>> fs: fs-writeback: move sysctl to its own file
>> fs: drop_caches: move sysctl to its own file
>> sunrpc: use vfs_pressure_ratio() helper
>> fs: dcache: move the sysctl into its own file
>> x86: vdso: move the sysctl into its own file
>> sh: vdso: move the sysctl into its own file
>> sysctl: remove unneeded include
>>
> Thx for this.
>
> I passed this through 0-day testing and it return some errors. Please
> address those build errors/regrssions before you send V2.
>
> Best
ok,I will fix those errors/warnings in v2
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH -next 12/15] fs: dcache: move the sysctl into its own file
2024-08-26 19:56 ` Kees Cook
@ 2024-09-02 11:04 ` Jan Kara
0 siblings, 0 replies; 27+ messages in thread
From: Jan Kara @ 2024-09-02 11:04 UTC (permalink / raw)
To: Kees Cook
Cc: Kaixiong Yu, akpm, mcgrof, ysato, dalias, glaubitz, luto, tglx,
bp, dave.hansen, hpa, viro, brauner, jack, j.granados, willy,
Liam.Howlett, vbabka, lorenzo.stoakes, trondmy, anna, chuck.lever,
jlayton, neilb, okorniev, Dai.Ngo, tom, davem, edumazet, kuba,
pabeni, paul, jmorris, linux-sh, linux-kernel, linux-fsdevel,
linux-mm, linux-nfs, netdev, linux-security-module,
wangkefeng.wang
On Mon 26-08-24 12:56:00, Kees Cook wrote:
> On Mon, Aug 26, 2024 at 08:04:46PM +0800, Kaixiong Yu wrote:
> > The sysctl_vfs_cache_pressure belongs to fs/dcache.c, move it to
> > its own file from kernel/sysctl.c. As a part of fs/dcache.c cleaning,
> > sysctl_vfs_cache_pressure is changed to a static variable, and export
> > vfs_pressure_ratio with EXPORT_SYMBOL_GPL to be used by other files.
> > And move the unneeded include(linux/dcache.h).
> >
> > Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
> > ---
> > fs/dcache.c | 21 +++++++++++++++++++--
> > include/linux/dcache.h | 7 +------
> > kernel/sysctl.c | 9 ---------
> > 3 files changed, 20 insertions(+), 17 deletions(-)
> >
> > diff --git a/fs/dcache.c b/fs/dcache.c
> > index 1af75fa68638..8717d5026cda 100644
> > --- a/fs/dcache.c
> > +++ b/fs/dcache.c
> > @@ -73,8 +73,13 @@
> > * If no ancestor relationship:
> > * arbitrary, since it's serialized on rename_lock
> > */
> > -int sysctl_vfs_cache_pressure __read_mostly = 100;
> > -EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure);
> > +static int sysctl_vfs_cache_pressure __read_mostly = 100;
> > +
> > +unsigned long vfs_pressure_ratio(unsigned long val)
> > +{
> > + return mult_frac(val, sysctl_vfs_cache_pressure, 100);
> > +}
> > +EXPORT_SYMBOL_GPL(vfs_pressure_ratio);
>
> This was a static inline, but AFAICT it's only called through
> alloc_super() which is hardly "fast path". If this series gets another
> version it may be worth calling out this inline->out-of-line change in
> the commit log.
>
> I don't think it's a blocker, but I'm not a VFS maintainer. :)
It's actually called from about 7 shrinkers of filesystem objects. They get
called relatively frequently during memory reclaim but I don't think a
function call is *that* expensive to matter in this case. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH -next 12/15] fs: dcache: move the sysctl into its own file
2024-08-26 12:04 ` [PATCH -next 12/15] fs: dcache: move the sysctl into its own file Kaixiong Yu
2024-08-26 19:56 ` Kees Cook
@ 2024-09-02 11:17 ` Christian Brauner
1 sibling, 0 replies; 27+ messages in thread
From: Christian Brauner @ 2024-09-02 11:17 UTC (permalink / raw)
To: Kaixiong Yu
Cc: akpm, mcgrof, ysato, dalias, glaubitz, luto, tglx, bp,
dave.hansen, hpa, viro, jack, kees, j.granados, willy,
Liam.Howlett, vbabka, lorenzo.stoakes, trondmy, anna, chuck.lever,
jlayton, neilb, okorniev, Dai.Ngo, tom, davem, edumazet, kuba,
pabeni, paul, jmorris, linux-sh, linux-kernel, linux-fsdevel,
linux-mm, linux-nfs, netdev, linux-security-module,
wangkefeng.wang
On Mon, Aug 26, 2024 at 08:04:46PM GMT, Kaixiong Yu wrote:
> The sysctl_vfs_cache_pressure belongs to fs/dcache.c, move it to
> its own file from kernel/sysctl.c. As a part of fs/dcache.c cleaning,
> sysctl_vfs_cache_pressure is changed to a static variable, and export
> vfs_pressure_ratio with EXPORT_SYMBOL_GPL to be used by other files.
> And move the unneeded include(linux/dcache.h).
>
> Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
> ---
Reviewed-by: Christian Brauner <brauner@kernel.org>
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2024-09-02 11:17 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20240826120559eucas1p1a1517b9f4dbeeae893fd2fa770b47232@eucas1p1.samsung.com>
2024-08-26 12:04 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 01/15] mm: vmstat: move sysctls to " Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 02/15] mm: filemap: move sysctl to its own file Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 03/15] mm: swap: " Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 04/15] mm: vmscan: move vmscan sysctls " Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 05/15] mm: util: move sysctls into it own files Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 06/15] mm: mmap: move sysctl into its own file Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 07/15] security: min_addr: " Kaixiong Yu
2024-08-26 22:49 ` Paul Moore
2024-08-27 1:38 ` yukaixiong
2024-08-27 1:56 ` Paul Moore
2024-08-27 2:43 ` yukaixiong
2024-08-26 12:04 ` [PATCH -next 08/15] mm: nommu: move sysctl to " Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 09/15] fs: fs-writeback: " Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 10/15] fs: drop_caches: " Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 11/15] sunrpc: use vfs_pressure_ratio() helper Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 12/15] fs: dcache: move the sysctl into its own file Kaixiong Yu
2024-08-26 19:56 ` Kees Cook
2024-09-02 11:04 ` Jan Kara
2024-09-02 11:17 ` Christian Brauner
2024-08-26 12:04 ` [PATCH -next 13/15] x86: vdso: " Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 14/15] sh: " Kaixiong Yu
2024-08-26 12:04 ` [PATCH -next 15/15] sysctl: remove unneeded include Kaixiong Yu
2024-08-26 19:57 ` [PATCH -next 00/15] sysctl: move sysctls from vm_table into its own files Kees Cook
2024-08-27 2:03 ` yukaixiong
2024-09-02 7:17 ` Joel Granados
2024-09-02 10:55 ` yukaixiong
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).