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: 66593 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp93936wrd; Wed, 8 Mar 2023 20:41:29 -0800 (PST) X-Google-Smtp-Source: AK7set8mrgpvspPPVxNDl4DPfueU0j1fJ7fQm6ZNY5QGto335DlHK5Ybw3gAtcvksUjv97lifVow X-Received: by 2002:a05:6122:2029:b0:401:1c83:fb9d with SMTP id l41-20020a056122202900b004011c83fb9dmr13828138vkd.6.1678336889105; Wed, 08 Mar 2023 20:41:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678336889; cv=none; d=google.com; s=arc-20160816; b=KegzlMmQ9vXUeNvFiC0ZUaAL6coCbGRL95rlRhZ0C2Ic/lsrS7n65EcTPLeK0zwNot heVHvrOYUPEAAhh862RZ2KS6FW7RYdnA+knvMq7qumqFhv93n+N/8SiPcBylmQ+Vv2Hj pDARIOAXVGfuW2LdCvYuLcUVu21vf4z2AZcbjwPscOqRPJxprqBF0xshmLQSJEuLWpS2 qFd0DgMHZky7P43HZ4GTmAH8vfsSmXwJdi3MFHVWxQJAUciTNFhr+JEKe/N2iU+rBG9k U7XDNxkur9GKVRdU87mmmXr0/uqr1hDcRz/djmS+Xcc8ZWgKS01787Y26NCCZZk/BQJu F9dA== 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=3fjly0wDDG93gvPy7hoPdbK/T8mgSPpck87rVFRXJTc=; b=f/e8PZC/xyh5hABvouBJ8yVN2wKKTZ289//hocbWV4WM38uTlc/zprpCf1ZZO2Vx7t tYHyZnQyuK9+iytWs0nnlZO610UyzzX/kwvzniGg+MT9rLbbLybueBNuB2gmRjvanNSi PXH09e2cw9B4lerdz2jsZHncKj4wptPVujb+KNMnITefjEsaUy0t38hx2ruc/p6L9goH BSYQxo3lmQzMJPu66xfnytfEDiVJ344GyaRaChBrPsr1y8NU7gj96bpq0j86mR5tJc2j AEN6fI3Cosyjk2fZK/zdpSV6PRzJPCWTsONE5nqSKBxqXVo0eiv9V+JNPTpju5+McWim CDdA== 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 y17-20020ac5c811000000b00415aa0beb72si5678358vkl.190.2023.03.08.20.41.13; Wed, 08 Mar 2023 20:41:29 -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 S229634AbjCIEi7 (ORCPT + 99 others); Wed, 8 Mar 2023 23:38:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbjCIEi4 (ORCPT ); Wed, 8 Mar 2023 23:38:56 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32940136F5; Wed, 8 Mar 2023 20:38:53 -0800 (PST) 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-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?1759863781562765840?= 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,