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: 72019 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1068827wrt; Mon, 20 Mar 2023 00:32:52 -0700 (PDT) X-Google-Smtp-Source: AK7set9ogEwfYJ7NhMZ6cP24EH8twp4ax04jk2D09xKDN55HzI/ca11dcRPDDm3Z2bYr5b3zqL/u X-Received: by 2002:a05:6a00:27ab:b0:627:e180:ac04 with SMTP id bd43-20020a056a0027ab00b00627e180ac04mr6705546pfb.0.1679297572268; Mon, 20 Mar 2023 00:32:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679297572; cv=none; d=google.com; s=arc-20160816; b=HlRxajwOgpHWmNNWjSue4LNvgxgqDDdwUIqyEp4pVMGicZTpvWOk5Ks2McOR+ZBTp4 XfvyXvQldtHKoeFJMvXsZHNIRI1ISidQyAhy5b2AQEEWz9z5b6DAAhdybtRFK3vJMaQh pa3Z/LF8YNXLw6XUwksDhkul1n6GciIjZQHJrPgGjMW7rfJVGR/B9N6dV8JQjV6R18KK qCJ3iMkeEeFSr4cFczDI7V+QS9jps7KiMj+GGsEzvs5egyVgqsl3DDOAPvODtfMGnsN+ iWtmW8ZXDzuh3LWhQ2ba4S/0M8VjKoYW1rxmIF/NJW/z/pA5rlV7XukSPmVwHP8hMnZV ircQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=nLR5xgeswMjyQ/2LwQ8VCw5yTNjyvdp6YTiPJGbOHxc=; b=PFo3hzcp1A5cq6i0KDPa6HSXcflZkOnpZ1GIjISPLZyGMiED5I4TQviYvGUrGe0UAa vpuDrlD6VOBreZEXxumP3lHUOQNUOcO6ti49CIxi+HoOnCgP7zW7LQlhjKrVgQEOzp9F ssSVpfizDWRi0H3jCcUX5EpaZWjp9ftSIjhWzzXMV4TIDKoZMtPef4ktxmEUHKKu2Pus m6fLqmSUCm4ToVzE5drv7MC7l5LvrULheY0cmucROTNOrYLrJxEpfP+/96FC71EMjmuv LHFLX+KRZVu77rDv/WTweOmkhHTVHGPiVIvfUmZr0GN1xYiGCNbDrCJt46wYzXUdLo/m 8J6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q6-20020a056a0002a600b00590712dd84bsi9463925pfs.81.2023.03.20.00.32.37; Mon, 20 Mar 2023 00:32:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229914AbjCTHU1 (ORCPT + 99 others); Mon, 20 Mar 2023 03:20:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjCTHUZ (ORCPT ); Mon, 20 Mar 2023 03:20:25 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4275CFF3E; Mon, 20 Mar 2023 00:20:22 -0700 (PDT) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760871130987054306?= X-GMAIL-MSGID: =?utf-8?q?1760871130987054306?= 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,