From patchwork Fri Mar 10 03:57:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13168675 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 E58B1C6FD1F for ; Fri, 10 Mar 2023 03:37:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DBE66B0072; Thu, 9 Mar 2023 22:37:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 28C626B0074; Thu, 9 Mar 2023 22:37:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17AB46B0075; Thu, 9 Mar 2023 22:37:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 09D2A6B0072 for ; Thu, 9 Mar 2023 22:37:02 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C5674A1276 for ; Fri, 10 Mar 2023 03:37:01 +0000 (UTC) X-FDA: 80551577442.30.5903327 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf13.hostedemail.com (Postfix) with ESMTP id 0179320015 for ; Fri, 10 Mar 2023 03:36:58 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1678419419; 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:in-reply-to:references:references; bh=3tBSv8AYC8TZxbT4UJOASM9ra7ZaE+ejvwIWrirvf2s=; b=8I1goNTEACLX4EQ8uJbalghxJC4s5porxxeApzhTAbmPcyEdrg+AyWj3WLn4UeQGt2uds/ rthIi7ajdS8ygFLTD+TTCwCqYwRRInoXY/been0rcTMG+f2Mren4rOLQG0EKqFzDLb8swQ fRCuMhIbP2+01G0qHSJN1Ouiy6nAsN0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1678419419; a=rsa-sha256; cv=none; b=V0ZS/6fAjdqDggPRmDYqjtmoHxwFaxWliGzxBPej0fKui3clqYREWKK9CVdrLDgKFlgjid QvxE8mlPjKEnoA1X/9vESK7d2bl/k4nPNY3bEFNBQ2ibFaI8wW9EitKh48bFxbODu+1Dgb QogmQiQSSbG7nLDW+rDXukGK5ZbSAYE= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4PXsCT0PbpzrSDH; Fri, 10 Mar 2023 11:36:05 +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; Fri, 10 Mar 2023 11:36:52 +0800 From: Kefeng Wang To: Luis Chamberlain , Naoya Horiguchi CC: Andrew Morton , Miaohe Lin , , , , Kees Cook , Iurii Zaikin , Kefeng Wang Subject: [PATCH v2] mm: memory-failure: Move memory failure sysctls to its own file Date: Fri, 10 Mar 2023 11:57:09 +0800 Message-ID: <20230310035709.16281-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230310002038.GA4076019@hori.linux.bs1.fc.nec.co.jp> References: <20230310002038.GA4076019@hori.linux.bs1.fc.nec.co.jp> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Stat-Signature: trebsceeuyw3gm79nop7gqbpcdartqyd X-Rspam-User: X-Rspamd-Queue-Id: 0179320015 X-Rspamd-Server: rspam06 X-HE-Tag: 1678419418-557606 X-HE-Meta: U2FsdGVkX1/vs2XaO8GSi9W7MxjEZKO5xRHwM6TxQrH8D2Z2q3TgWFyHrERTr4jOpqPd52fzNdo3RfwbGckUoc5DBIVWEJ/YtAMNRDxycZs79XTuk1wFNHNdxcDv3nchWWQBD+48hWsGS4aK8WZOg8r6GEanKpAZ5z8Gu8PBEhYu44xJoEc4zxRNmNhXdUiwYpfpsjV0t5PtT2xX94lMAvhPyQMIHKiYXqPsIY94SFJZi3zyu1T76EnWreNTVP5SxlzbKtocfa3tmMb/O26Pro5Ulx7j/7l15ngfxgJkXFpRK2Ht/zz28GmcHxLK56nCmvFEhdQi/8GVVVz8B5asWiKR1+7QmS0j0bA3fI+ZNGsDfQ2Sgp9PuqQKE2CSHxGzWNrdDNcbL2T1VDSbcIM/UpdGwSRXWniC1jgugU1iM/9xHGEdTfftK9z9LikjwsdG9Tj7rLK3vEGnPD1FIsbv1VP/+Rw7lNy74uH4MLwozXO4XHnLWXK/RbB6livZ/WDqgRjqyD5zp7S2Occ4MdGAyEuRrlq7us9tOzyFMJbBToZCV39Ov7FDNkOWo/pTrSjOA5UE1fZJkEzxYGgbIH5Oe6y7VmvLLFI3uBnkRvkO4DOQaa92kC771FM0tAIKBYNoMJYQWHeefzxl4wlNUXIQ6vu79xVE1th6/A1o1zurojclKY6txONoQ9HmDpuLa811gPq9OmES9U/N5zndEge/eNtFMTsZml/bwBBk3pgO3am6einiL+s3YiuzrvC97xAECwUzbZmoYb1f59WKpqh61B5Oj00Y27fkDEtceH6q1Q39gm36zVjJDEskDTt+zbspW5cPR5ubmz2n1Q8vAGUiwjNe8EpOdqJ59vrMc3zdtDE70WuC+ceG9sw8tmrxDrHnOqkdBJHbZcpFEtbcg0czRYPg/KXS//roHEW1QRLeGczc7t3RcbAnwMUmRx4VXToqYpnyp1db48xfGIdrVxL tVKXyYg9 WNBIa0p388tsYclTVat+7+V+ygltidO/AlYYGdl1/3QC+mrZW8+Njdu7gQuiQvLcuh6cRs9xjHcj3O5DSs+hX7ssb64Y0R3QMA6cX7sHgxGv0gjCO1FfyMh2ht4BY99I3mM48pExmETIzrVQwM0MOuXgufeL950DCOWNEzzmbnpDe8ksgPlmqc3TYQPkg9ezMsR+t 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 --- v2: add Ack and do not initialise statics to 0 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 ce1590933995..4765aedee1d4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3587,8 +3587,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 fae9baf3be16..6c007b7730fe 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); @@ -122,6 +123,36 @@ const struct attribute_group memory_failure_attr_group = { .attrs = memory_failure_attr, }; +#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,