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: 67197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp668223wrd; Thu, 9 Mar 2023 19:48:31 -0800 (PST) X-Google-Smtp-Source: AK7set/08kDfW2yILrjM4eRqHqEHVa+h0AAfAUjQhOgD8LAiV18rvtXSR7Bv3nHhQ24ABIJzOOpu X-Received: by 2002:a17:90b:4d07:b0:237:ae98:a47f with SMTP id mw7-20020a17090b4d0700b00237ae98a47fmr663360pjb.1.1678420111682; Thu, 09 Mar 2023 19:48:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678420111; cv=none; d=google.com; s=arc-20160816; b=U+YmbjkcZqgDdtSGjY/acxuFg1c8cBpBvLvdLAjWKhmhu1qpMSPLMS4ASwSql9hZS9 pr4gnFUgEk29pbbxLDJny2ONGyZ9pGf006oPNSPqHVnaEJpjyKEQKnKw1Mer22yb2XYv WbS9+jQlt1X5ICRoJpBZiC8ynDLomjXvHkN/qj6XbQq8JU9/j2nGtNnhk6E92iB7dy0n L4jUGaGpXum4dVG+p8V4y5ZocBxP9ru83s1dCrSgqYeA2uiOn4si4ubz+nzYX4sVpOT9 9GPAH2Dyuz9NrwIgW7wkd/uiKYm27SeEBkTCzBe8Vl8ieF6PU7O1bmb3ZnCcZwMBedvK iOaQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3tBSv8AYC8TZxbT4UJOASM9ra7ZaE+ejvwIWrirvf2s=; b=EIjLr2AI/v5eOk/89Bsvs6OvXrCYIYqNdAOgk4xpPOuTb+340Fs8Csi/9B44lPQg8m dPBx09XeWXGufUvhX4iLtv1jkPqA7ozdvhGenT/+LQkMHhzrvGSxt04Fbe5XhbY6rCoD yuiKjftnxYbKJIlSqn2nzkpXwxMKbYb5JIfAUv1bT1admaTORmb1Cy4Gwifh7vAXwoRX K4JR3CtlE74Gfkk7U1FhbQMZyAtk7qF1GXCI79usj1XUCM6xPtrNs/h/UMXiT7frBcDj BPF2tVFebIc4qsMc2P6xQYz2eZL9E/q7R6h9QFBjZSufyN2UCNv8xrMYxpkmAVxoYMfd LuzQ== 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 z2-20020a17090acb0200b00230a19ce84asi1461246pjt.147.2023.03.09.19.48.16; Thu, 09 Mar 2023 19:48:31 -0800 (PST) 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 S230075AbjCJDhC (ORCPT + 99 others); Thu, 9 Mar 2023 22:37:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229976AbjCJDhA (ORCPT ); Thu, 9 Mar 2023 22:37:00 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C177116C23; Thu, 9 Mar 2023 19:36:55 -0800 (PST) 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-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?1759863781562765840?= X-GMAIL-MSGID: =?utf-8?q?1759951047205141447?= 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,