From patchwork Mon Mar 20 07:40:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13180787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B811CC7618D for ; Mon, 20 Mar 2023 07:20:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F3E4900003; Mon, 20 Mar 2023 03:20:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A380900002; Mon, 20 Mar 2023 03:20:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAC5C900003; Mon, 20 Mar 2023 03:20:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DB0C6900002 for ; Mon, 20 Mar 2023 03:20:29 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 98F7040A3B for ; Mon, 20 Mar 2023 07:20:29 +0000 (UTC) X-FDA: 80588428578.19.2619B24 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf15.hostedemail.com (Postfix) with ESMTP id E9666A0015 for ; Mon, 20 Mar 2023 07:20:24 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679296826; a=rsa-sha256; cv=none; b=kIOpnqsE9FyZLZeethROqTXY6URYK7IGQj4GZxQPJZXbk3mVzDHkEgANeNuAHANthN+oM5 +pwoGcGY22YKpD3tjmn8WSDcOWfAVtrBbCvvb9F2m0yfoC3HzHEqHbKYpBi2g7uEG+vZlJ 3B8Kp4M4halvLIImUK9NJ9RPWNVVQ2c= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679296826; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=nLR5xgeswMjyQ/2LwQ8VCw5yTNjyvdp6YTiPJGbOHxc=; b=rz1WLCIDn5Qot9Db0kUeBpsi0tL+GJY7Vg3D3OQtzha33Bx2VoW4YCOOLaD4EfrPBA1H/T oqAnPvoxv7AcTWxWROUv6FQ1bdRGD/EfwyqpSMvHtKQsNBmqFzw47m0wYM/wzcB4hweA0o b8uYR8SBTM3gpfqA3XRx1oRnMh15mng= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Pg5fz31lxzKs9C; Mon, 20 Mar 2023 15:18:03 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 20 Mar 2023 15:20:18 +0800 From: Kefeng Wang To: Luis Chamberlain CC: , Andrew Morton , , , , Kefeng Wang Subject: [PATCH v3] mm: memory-failure: Move memory failure sysctls to its own file Date: Mon, 20 Mar 2023 15:40:10 +0800 Message-ID: <20230320074010.50875-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Queue-Id: E9666A0015 X-Rspamd-Server: rspam01 X-Stat-Signature: qzs749gnkoonx9776scgc3tw6qo6iwnj X-HE-Tag: 1679296824-843304 X-HE-Meta: U2FsdGVkX19ZXE+przDQR5Q6uyp8/XlfFzQy8yNs4BP4GLC18i2PYh5+QX3Tqjf6+Dd6Obfq6zfOWEr8/gI4IFNK/fmqQ4hA/v8uy4axx1ojIHZDlj/8sNohW9lfOrahlHkkI+y9+WfupkH1i7NSylvyi7cOTzU7pXsOfni+oMALNmVVKj/6SLgjtJ8DkQ+Co0RpvBw19+DX83DacMjQ/kc1SdZMEa7+L+83IaSBiLCegjsVrA/HZke29e0mW2XCFXAbkWyUqpeFmbwGOZBD7A2o2gBzzsLJHAl5ZOwPRCNAsqaGEuEfDQzVU3LTE9giB1GpVSH7cQ6F4tgcHiaP1LcmAwJPYb5zuNDGK8CQf2CMG2+2dzgb/0IY0RahzpZHf3OsBMAO3NqgxuV/j/G+Z9e5yBeWMBTxasVH/giqM9JLKYADd7Cjx/zjI5XvHvE8I96rtkGPRupX7SnHzBNjoSSJ+lacr5h0cW6yEBHLdm0hWYUAwxmNjLw3SPx2ZISREeeOc1puq52FwpGpgOL6mmI0qcHXkEaMVq6kzZVhGR85qytUOZb7QxPfScTIhlQyiZmvQ5qS1QI3SzrlhpGx05l2vo9NTygbQTM31ZoVs/Bw/N8VH5diGvxBFpGp3jbXB6iPO7BfCUntRiwtNM6YyiirIE7tT+4qCDiZwxAOqzVDnMEdKoP0dxGUcsZ72EQZCsUvZdZAXdGU7EXsBQBLiOibbjlWe9YS8EGVZoSXThHpmSFgzJN/MTsIdkerU3CHEqViMUp8Pw+NW8kW6URwriQ1xUjJnyC47Uv60S+/WMJhRWnw0P+meuZH1O92gQ82HOkJIkD1wLFYEiv4URH+Apvnq4x46fGfugYlJVFNMocmwbsCDcJW0GzXSOHSTV6zI+Z9pLErm4N9lLXWHofTveo9tnvLwjNk/eSwpYyu2w9vfp23GSayUSsckxBysyBss9ZeE7508CRzh0jRXwT MtXxZpZc Su7cTBJhO2DFBQ1baxfZdMk+6ureVlJp3mlctUnByoQXFuItFc4/R0914eT7K2HG9i5s/FMF0/Vvlo1mINPndjZKwbk1tZh/9OqN3n9IsIa5I3V3bitEc7F0uUZJNbIP+6SdVy3oe5U1U6DJuanqmbRqvrEhlB86dgURwNaVx8oDWgixgSsI27YGx1w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Signed-off-by: Kefeng Wang --- 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 #include #include +#include #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,