From patchwork Mon Oct 30 07:25:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13440121 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 7A437C4167D for ; Mon, 30 Oct 2023 07:26:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D7DB6B0185; Mon, 30 Oct 2023 03:26:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F2D006B0186; Mon, 30 Oct 2023 03:26:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA6EA6B0187; Mon, 30 Oct 2023 03:26:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C1AEA6B0185 for ; Mon, 30 Oct 2023 03:26:00 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A0F73140415 for ; Mon, 30 Oct 2023 07:26:00 +0000 (UTC) X-FDA: 81401293680.04.BE66F95 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf12.hostedemail.com (Postfix) with ESMTP id BD1DE40006 for ; Mon, 30 Oct 2023 07:25:58 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf12.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698650759; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=hrgjmqVaDOBF5f6G+yK5DKE3ReIkP/zjgMI+LTlLJG8=; b=RIq62Me3okY5sC2MPJjyVeBtoemUY0B+JWwsOZCu3t9yuq9wze7eBJxfO7do5zJy2n9CzI C7awtUAVlikstYp/bcmvkd0Gch6/Kl1tPprDqAPHk8ugV5vNaDLWGbPk8LXlK9Qj5m9Sly kS0X6RCAcIc1HAjJMH308eUxfc5pBBg= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf12.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698650759; a=rsa-sha256; cv=none; b=RT7WMEy62/QgFoDwnzQFoObGSAi4K/UJLxQsiRXYM3Sumrnmeorbc7IiVYhp6oC0WTQyk1 k7NUq6K3c9kvVTanvMiIuWeuhrkOE38VQLVN815zmD20WEeH7HlfOmOlezQBPCUtr4C0sJ i7dV+xx53550rVujq5DCZGoK4PR1DX4= 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: H4sIAAA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T 2D3enTvH7nFixm8Wj50PLT3mnQz0eL/vKpvH4hcfmDy2/rLz+LxJzuPd/LdsAfxRXDYpqTmZ ZalF+nYJXBmv1r5gKfjKW/FqaSdTA+Ns7i5GTg4JAROJh5uPsYHYbALqEjdu/GQGsUUEzCQO tv5h72Lk4mAWeMAkMfftCkaQhLBAgMTJreuZQGwWAVWJZfc3gzXzCphKnOz7zQgxVF5i9YYD YIM4gQZ9Pt4FViMEVLP9/2HmCYxcCxgZVjGKZOaV5SZm5pjqFWdnVOZlVugl5+duYgSG8bLa PxN3MH657H6IUYCDUYmHNyDcLlWINbGsuDL3EKMEB7OSCC+zo02qEG9KYmVValF+fFFpTmrx IUZpDhYlcV6v8NQEIYH0xJLU7NTUgtQimCwTB6dUAyPnJ//QSlOprwy1co+/ntjRor53bUAf +92Sw9KL9p6ft1fkZVu/1Jtthw/u2/lNMPfbjbV9J39rcBvmP2ze+SD8d1/M3q7F0bPEdulM Orz2AttMmeA1WxjO/mho/p7nXrxKK4trubVL1Q/mQMmpMre3xhyd+NrZp9coa27UG13bsIQF 7r9CBFcosRRnJBpqMRcVJwIA4xMH/F8CAAA= X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BD1DE40006 X-Stat-Signature: zwrjj3fgkrcmhupk5x7ccod83fudkg1x X-HE-Tag: 1698650758-316464 X-HE-Meta: U2FsdGVkX194QmYP3m7gyuM5LHmEbOQmwxh66EbA9avWBmMC3N6sdbME6d/VDo36WwhRTF1YiFTAO2M7Cm6SfwWeI8qEo4sgdklgSEQWiUme+A20gHSowiD4zhEVV4hvEoOuUroNtgLpYxNrfgO9T/MMf+LwKPqlQSQn/DyJWJXLT2O47U/4JOdC8li52f/Sw0mHPNVv68rzxMv9cpXHIeKImG1rnJUwMNpU7E2IHCwjvS4NDAEs4uB911g+w7Ki/4qoYgDNQCTC9pT84zPJPQYwwEEnasFud4aw3H3QJoyI9PYYSHTaEn9VRxIsMvUjvMM8RhIZqvv34Euut8QVqmVa5dHwk9qkqTbFs4hWhdhLdSS6/jrJE7ctfsxMzrgRvWTZqRxVkeiTI8lpoVsYjA5svB2uKGpTbcpFjt7vPaQOMDw/tH20gIVAY0gLD6yL0tW147L7VnAChgbJeOHFtpj7FcNasyIeoVLnqAqpp4+VeUJa+/OKmwHaOF0KPLD3uM3UVfJp44taxA19eS4HiyAyCceZ2RlHTSmtYX80tkdzC+c5Oyqb1vKznfUkO5v1M1NcObz6XQDLiX7kRsQG4SUkihD+Lc7pFkMwyJDitYlYi6B1RNmZcLpEHRiH4mfnc1ZRqMowtBXBYnZP5YNdDnssYMb0+E+u5aDs7TKobqvutk8QobYss0ncMxpRrP/x07Gxvevw2wn7US8RpdAQmy+Amw+TUXcV0aJ65uO1bcMAyW0BT0j2VDCir6CUIHDRWpRRtmAf/9UG4TFOiHZEap9g8friyFcFFgFlqRa1Q08e1OLHhkRpk3RwMXkVHFI7o6LAPnKFmzlDY/Yja8JL/Le5mkQJGv2gP0OMM5yYEfLgr/5TNHreuc+Eil8dnZhRaeiv/8tJpPatTeADrFLBElZUwHlaoG6DQxBzK+dd+fkts95GDb3u8jE8CdrtrtMLvTPWgmYI7x6+ShTcNr8 oMQ== 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: List-Subscribe: List-Unsubscribe: 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) {}