From patchwork Thu Mar 9 04:59:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13166781 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 BE25BC6FD1F for ; Thu, 9 Mar 2023 04:39:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 170BB6B0071; Wed, 8 Mar 2023 23:39:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 11F2B6B0072; Wed, 8 Mar 2023 23:39:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00E606B0075; Wed, 8 Mar 2023 23:39:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E8EAF6B0071 for ; Wed, 8 Mar 2023 23:39:01 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B6387A0502 for ; Thu, 9 Mar 2023 04:39:01 +0000 (UTC) X-FDA: 80548104882.09.E566B9E Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf08.hostedemail.com (Postfix) with ESMTP id 4352A160007 for ; Thu, 9 Mar 2023 04:38:55 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.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=1678336740; 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=3fjly0wDDG93gvPy7hoPdbK/T8mgSPpck87rVFRXJTc=; b=148JNIOZ/F/dk5B4OliwkGtInGAzRoMQ+eaVf2GzsVjQP+VBfoMM4ghA89UT/kVrIGSNvH +eE6genu5FApWb4LOUNAZY0/7ZUqP7k6cHjpC4/A4rIjFq08zUTqdvRf65NSMdiBWmOhp0 /ziBbHdPed/HAfd4K3194LShKSVjfGE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.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=1678336740; a=rsa-sha256; cv=none; b=opb4+/7LPd2+Gfq/H4+bDuzPXdem/PeLqps7jcBj3OJV1UxFS29+hCL/cgZ0/7O6HdDejU SX3xw6XNTjCh5uTJvB1LMdFI/KZlUVhxP3E06MhYmMTSvhE/Ys8+uLlyjcSRBFCk10q6DV 4Kp421gu2kvlPzVOZ8Y7TOqBQa8T064= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PXGZl4zBqzSkgM; Thu, 9 Mar 2023 12:35:43 +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; Thu, 9 Mar 2023 12:38:48 +0800 From: Kefeng Wang To: Luis Chamberlain , Naoya Horiguchi CC: Andrew Morton , Miaohe Lin , , , , Kees Cook , Iurii Zaikin , Kefeng Wang Subject: [PATCH] mm: memory-failure: Move memory failure sysctls to its own file Date: Thu, 9 Mar 2023 12:59:24 +0800 Message-ID: <20230309045924.52395-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-Stat-Signature: paztb5au1axbe54kudh8n9pabcb7196z X-Rspam-User: X-Rspamd-Queue-Id: 4352A160007 X-Rspamd-Server: rspam06 X-HE-Tag: 1678336735-953776 X-HE-Meta: U2FsdGVkX19p4WSh0J+FPzQCswt0m5GhNa+lJBnXhBSEE2goHlw/39VJO6OC/LMfZygb05W5SOmr4R/n8lEkkqKXZjJaYv5K52lmTt927rqlupZenMKKAGCuJgfILgbn5OTlrHS0cjjO6phXj9BGbxzxxx5HLybmmQ+OyE5nnKiK/GyXSuNmTdgYQLgQ+17n5Zw9e0VvMqDywZisqahVG444RdjNi8FiP641o8XsQNysW9EKq+EV7/HKqtPIiwv+Oa2a9uIP5bqyRz/MfMWTgC068cjLXI1vi9wyG66LLfZCLqYZyk06xoDn+WO0O/lNg+jKuZOu7QXumICnJdbr+sS1MaeKVKtvuw1LPjAQGZsQSTzV+pIWkZSBQEGfebBvSL57uHP9rwuluMkkLJ1XrNvX5irwI14tFV4JqlEiH+SLFOOziR0CkJyp6neTBW11i2SAhC7/nRktBlOY1lFfbAFQnWFosJFJAxQKaGKCde3DeGnXjZ8I2SiS8XQsC6c3y1ZSHtUo9rDBO34ZuokWbBmoLqT+nr7jSokRI0U1eDdNVn5+/pqfEKIooZLExSNI5/zDs5zV3KdlinC6hEAVofFmLHDbdCFH/r7nCp8tnNJ6G42ic7tRo7rxZcXrva59gRupbk8VirI11defA6qlYhkPH1mrUM8eK4qQPQJmSVPYD8qpUiN3aMv8L5jKd5brAbmpDb3fOZ2RZH2WX5DasdpmnZLaRYLXuaChnFmisakB2mTYkzeLTA3vro4HBGUFQYH2HGc+2QC0RsF1A8FDAlmzGAgVxrdlE5QiueoH0s1QjlbkCa9oupLJL2AEoDvRS/Uk8yg9MeYxHytltaWeT3n8ddvfTIZyHZOj1YOqP3I8a8EFtAsqlvlMdv83C3SQnHjGbp9NIi77J0GfihhRRrDXy8oinOAJUyerH0bwziKN43iFzUH9dCwjkXOz1ssE86ewB2nb34SS/QRx4MA 8wSg4D3B tiTPf8stknDh8Rnalz4WPIyW0YjgtBaXnO48RInKoHpVyK983Kl4OXivkwzbedsi4acVV7MOMhjaBNehiz51NKZo5UbOSQkxPKQKLJq5HPoxMYDGbv+EW5dJ6MVg8Kn4xxs1Hx2NKlzcZ4Vqvi9QwyBiNoNrJFTN2GoiB9dY1KMUH9P32E14w8DOjRwPEfQ0lTgMa5CMnfnBzqzI= 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. Signed-off-by: Kefeng Wang Acked-by: Naoya Horiguchi --- include/linux/mm.h | 2 -- kernel/sysctl.c | 20 -------------------- mm/memory-failure.c | 36 ++++++++++++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 573db4266885..3ed739c79026 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3583,8 +3583,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 932a5c196ab2..e6d73ee5917b 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2240,26 +2240,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..d3edfffb3f07 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 = 0; -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,37 @@ 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,