]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mm: swap: move sysctl to mm/swap.c
authorKaixiong Yu <yukaixiong@huawei.com>
Sat, 11 Jan 2025 07:07:38 +0000 (15:07 +0800)
committerJoel Granados <joel.granados@kernel.org>
Fri, 7 Feb 2025 15:53:04 +0000 (16:53 +0100)
The page-cluster belongs to mm/swap.c, move it to mm/swap.c .
Removes the redundant external variable declaration and unneeded
include(linux/swap.h).

Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
Reviewed-by: Kees Cook <kees@kernel.org>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Joel Granados <joel.granados@kernel.org>
include/linux/mm.h
kernel/sysctl.c
mm/swap.c
mm/swap.h

index 70cca450a68a2991552c893121c5971c970aad1a..23cfaa40fef3835fbea56a27a2c3aa9745e3860a 100644 (file)
@@ -76,8 +76,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;
index 74a33552731d7ae3605b6fdc2ea61fd4017f804d..b14e8764d45b34a654cb3cc5c6dc3e30c29199e3 100644 (file)
@@ -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>
@@ -2044,15 +2043,6 @@ static const 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,
index fc8281ef42415da576e4513649a17595d7593159..b81cce146eb29a610e0e6058dc2f4fee330be4e8 100644 (file)
--- 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 {
        /*
@@ -1076,6 +1076,18 @@ void folio_batch_remove_exceptionals(struct folio_batch *fbatch)
        fbatch->nr = j;
 }
 
+static const 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
  */
@@ -1092,4 +1104,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);
 }
index ad2f121de970d50647b3010e1ddf8d5af7daa1ac..274dcc6219a08ffa6cb995937ad5d18ed41fc35c 100644 (file)
--- 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 */