2023-03-20 07:20:29

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH v3] mm: memory-failure: Move memory failure sysctls to its own file

The sysctl_memory_failure_early_kill and memory_failure_recovery
are only used in memory-failure.c, move them to its own file.

Acked-by: Naoya Horiguchi <[email protected]>
Signed-off-by: Kefeng Wang <[email protected]>
---
v3: rebased on sysctl-next, asked by Luis Chamberlain
include/linux/mm.h | 2 --
kernel/sysctl.c | 20 --------------------
mm/memory-failure.c | 35 +++++++++++++++++++++++++++++++++--
3 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 716d30d93616..1ab157757906 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3459,8 +3459,6 @@ int mf_dax_kill_procs(struct address_space *mapping, pgoff_t index,
extern int memory_failure(unsigned long pfn, int flags);
extern void memory_failure_queue_kick(int cpu);
extern int unpoison_memory(unsigned long pfn);
-extern int sysctl_memory_failure_early_kill;
-extern int sysctl_memory_failure_recovery;
extern void shake_page(struct page *p);
extern atomic_long_t num_poisoned_pages __read_mostly;
extern int soft_offline_page(unsigned long pfn, int flags);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ce0297acf97c..0a8a3c9c82e4 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2350,26 +2350,6 @@ static struct ctl_table vm_table[] = {
.proc_handler = proc_dointvec,
.extra1 = SYSCTL_ZERO,
},
-#endif
-#ifdef CONFIG_MEMORY_FAILURE
- {
- .procname = "memory_failure_early_kill",
- .data = &sysctl_memory_failure_early_kill,
- .maxlen = sizeof(sysctl_memory_failure_early_kill),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- .extra2 = SYSCTL_ONE,
- },
- {
- .procname = "memory_failure_recovery",
- .data = &sysctl_memory_failure_recovery,
- .maxlen = sizeof(sysctl_memory_failure_recovery),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- .extra2 = SYSCTL_ONE,
- },
#endif
{
.procname = "user_reserve_kbytes",
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index c77a9e37e27e..242b6cae0035 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -62,13 +62,14 @@
#include <linux/page-isolation.h>
#include <linux/pagewalk.h>
#include <linux/shmem_fs.h>
+#include <linux/sysctl.h>
#include "swap.h"
#include "internal.h"
#include "ras/ras_event.h"

-int sysctl_memory_failure_early_kill __read_mostly = 0;
+static int sysctl_memory_failure_early_kill __read_mostly;

-int sysctl_memory_failure_recovery __read_mostly = 1;
+static int sysctl_memory_failure_recovery __read_mostly = 1;

atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);

@@ -87,6 +88,36 @@ inline void num_poisoned_pages_sub(unsigned long pfn, long i)
memblk_nr_poison_sub(pfn, i);
}

+#ifdef CONFIG_SYSCTL
+static struct ctl_table memory_failure_table[] = {
+ {
+ .procname = "memory_failure_early_kill",
+ .data = &sysctl_memory_failure_early_kill,
+ .maxlen = sizeof(sysctl_memory_failure_early_kill),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = SYSCTL_ONE,
+ },
+ {
+ .procname = "memory_failure_recovery",
+ .data = &sysctl_memory_failure_recovery,
+ .maxlen = sizeof(sysctl_memory_failure_recovery),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = SYSCTL_ONE,
+ },
+};
+
+static int __init memory_failure_sysctl_init(void)
+{
+ register_sysctl_init("vm", memory_failure_table);
+ return 0;
+}
+late_initcall(memory_failure_sysctl_init);
+#endif /* CONFIG_SYSCTL */
+
/*
* Return values:
* 1: the page is dissolved (if needed) and taken off from buddy,
--
2.27.0



2023-03-20 18:06:06

by Luis Chamberlain

[permalink] [raw]
Subject: Re: [PATCH v3] mm: memory-failure: Move memory failure sysctls to its own file

On Mon, Mar 20, 2023 at 03:40:10PM +0800, Kefeng Wang wrote:
> The sysctl_memory_failure_early_kill and memory_failure_recovery
> are only used in memory-failure.c, move them to its own file.
>
> Acked-by: Naoya Horiguchi <[email protected]>
> Signed-off-by: Kefeng Wang <[email protected]>

Thanks, queued up onto sysctl-next.

If you have time, feel free to help move each of the rest of kernel/sysctl.c
vm_table to be split into their own respective files as you did with the last
one.

Luis

2023-03-21 06:54:33

by Kefeng Wang

[permalink] [raw]
Subject: Re: [PATCH v3] mm: memory-failure: Move memory failure sysctls to its own file



On 2023/3/21 1:58, Luis Chamberlain wrote:
> On Mon, Mar 20, 2023 at 03:40:10PM +0800, Kefeng Wang wrote:
>> The sysctl_memory_failure_early_kill and memory_failure_recovery
>> are only used in memory-failure.c, move them to its own file.
>>
>> Acked-by: Naoya Horiguchi <[email protected]>
>> Signed-off-by: Kefeng Wang <[email protected]>
>
> Thanks, queued up onto sysctl-next.
>
Thanks.

> If you have time, feel free to help move each of the rest of kernel/sysctl.c
> vm_table to be split into their own respective files as you did with the last
> one.

I could let some freshman to do this jobs :)

>
> Luis