Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2570438rdh; Mon, 30 Oct 2023 00:41:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtBVE0suYugLahCe0E40XXzLssUSxq/tNGQeZoWQksBQuCloeYPKt0LmoidNQNdpAHHlLd X-Received: by 2002:a17:90a:2a86:b0:27d:4b20:3604 with SMTP id j6-20020a17090a2a8600b0027d4b203604mr5302262pjd.27.1698651711839; Mon, 30 Oct 2023 00:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698651711; cv=none; d=google.com; s=arc-20160816; b=N3rsU0o4RfoIytd1k1mfURtM+nSCuGSd/FPizqdvlfOr9kFVhHOG9L3QjmkCKj86nt KsbLTwm2AKcD+760HkIzNWEru98NyvuXtB1ij1Ol6ObN5qq4ibgfdyOLkKJkYWmaz2bz CZQuxWZrOV21vAOAdlFnS4H2BEA25P+c3l+haUX7bCLgtA6eMuOKQH3ITbT3rcJG/HPq lo3Kr+B8d7KWLoPUBdqRzsZBkwL1uBfaNQpquYLlTAY2/PE9nM/UljvZ86BkRmoBm1hq /g/bY446MWirxdzzLptvJaS3tUc+sPafBRExtIpUTHWfjpXIPGkVScuw7QMGz2JNTnpw aLcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=hrgjmqVaDOBF5f6G+yK5DKE3ReIkP/zjgMI+LTlLJG8=; fh=qkutryktk1+eA6li8Kr0a/P8xPDRQ0wHxGCKWFfNW0w=; b=UXknmTD4Koct4AWclGqGZgaIbyq34ZJq8FyVdl5RYmRVMbMqLikIyzPqcfrhYVABR+ qGfnoIHQc6rXGruj2kw0siXwndkNMaOn7ViEs962xI5r5EodAXUoF2Ls9TMBJtODLvp2 jx2nn/Owy02VlC+ZZslFRWNAX5pWiMbqUKOX1v1NUUkbnINKYpLcyXZSIdynFOUoIE/O AOBP0MN4+roCIqTCZyKXIWopoznkcEyApwGP/ZAgLrLBarltEiscgHUqLBo0HJ3HRlSf cxoi24eyLvVhU/f28lfAQzNOWLoZhY3IOQhj1Ui3lRyq1TrhaI0W09NHCaJQyAXBXkOt qJrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id pi17-20020a17090b1e5100b00280435c5051si2098569pjb.174.2023.10.30.00.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 00:41:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 67228806117E; Mon, 30 Oct 2023 00:41:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232155AbjJ3HlS (ORCPT + 99 others); Mon, 30 Oct 2023 03:41:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjJ3HlP (ORCPT ); Mon, 30 Oct 2023 03:41:15 -0400 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6CCA0C4 for ; Mon, 30 Oct 2023 00:41:12 -0700 (PDT) X-AuditID: a67dfc5b-d85ff70000001748-ac-653f5a7fb3a4 From: Byungchul Park To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: kernel_team@skhynix.com, akpm@linux-foundation.org, ying.huang@intel.com, namit@vmware.com, xhao@linux.alibaba.com, mgorman@techsingularity.net, hughd@google.com, willy@infradead.org, david@redhat.com, peterz@infradead.org, luto@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com Subject: [v3 3/3] mm, migrc: Add a sysctl knob to enable/disable MIGRC mechanism Date: Mon, 30 Oct 2023 16:25:40 +0900 Message-Id: <20231030072540.38631-4-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231030072540.38631-1-byungchul@sk.com> References: <20231030072540.38631-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKLMWRmVeSWpSXmKPExsXC9ZZnoW59lH2qwc25chZz1q9hs/i84R+b xYsN7YwWX9f/YrZ4+qmPxeLyrjlsFvfW/Ge1OL9rLavFjqX7mCwuHVjAZHF910NGi+O9B5gs Nm+aymzx+wdQ3ZwpVhYnZ01mcRDw+N7ax+KxYFOpx+YVWh6L97xk8ti0qpPNY9OnSewe786d Y/c4MeM3i8fOh5Ye804Gerzfd5XNY+svO4/Pm+Q83s1/yxbAF8Vlk5Kak1mWWqRvl8CV8Wrt C5aCr7wVr5Z2MjUwzubuYuTkkBAwkTh2fxETjP1w8zE2EJtNQF3ixo2fzCC2iICZxMHWP+xd jFwczAIPmCTmvl3BCJIQFgiQOLl1PVgzi4CqxLL7m8GaeQVMJU72/WaEGCovsXrDAbBBnECD Ph/vAqsRAqrZ/v8wM8hQCYHPbBKXb31kgWiQlDi44gbLBEbeBYwMqxiFMvPKchMzc0z0Mirz Miv0kvNzNzECA39Z7Z/oHYyfLgQfYhTgYFTi4Q0It0sVYk0sK67MPcQowcGsJMLL7GiTKsSb klhZlVqUH19UmpNafIhRmoNFSZzX6Ft5ipBAemJJanZq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Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 30 Oct 2023 00:41:45 -0700 (PDT) Add a sysctl knob, '/proc/sys/vm/migrc_enable' to switch on/off migrc. Signed-off-by: Byungchul Park --- mm/migrate.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index 76278eca8417..f6bbdc2d4fb1 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -58,6 +58,48 @@ #include "internal.h" #ifdef CONFIG_MIGRC +static int sysctl_migrc_enable = 1; +#ifdef CONFIG_SYSCTL +static int sysctl_migrc_enable_handler(struct ctl_table *table, int write, + void *buffer, size_t *lenp, loff_t *ppos) +{ + struct ctl_table t; + int err; + int enabled = sysctl_migrc_enable; + + if (write && !capable(CAP_SYS_ADMIN)) + return -EPERM; + + t = *table; + t.data = &enabled; + err = proc_dointvec_minmax(&t, write, buffer, lenp, ppos); + if (err < 0) + return err; + if (write) + sysctl_migrc_enable = enabled; + return err; +} + +static struct ctl_table migrc_sysctls[] = { + { + .procname = "migrc_enable", + .data = NULL, /* filled in by handler */ + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = sysctl_migrc_enable_handler, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, + {} +}; + +static int __init migrc_sysctl_init(void) +{ + register_sysctl_init("vm", migrc_sysctls); + return 0; +} +late_initcall(migrc_sysctl_init); +#endif atomic_t migrc_gen; @@ -242,7 +284,7 @@ static inline bool migrc_stopped_pending(void) static bool can_migrc_system(void) { - return !migrc_stopped_pending(); + return sysctl_migrc_enable && !migrc_stopped_pending(); } #else static inline void migrc_mark_folios(struct folio *fsrc, struct folio *fdst) {} -- 2.17.1