From patchwork Thu Aug 17 08:05:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13356110 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 05DA3C2FC0E for ; Thu, 17 Aug 2023 08:09:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6536328003F; Thu, 17 Aug 2023 04:09:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 603BC28003B; Thu, 17 Aug 2023 04:09:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B873280040; Thu, 17 Aug 2023 04:09:05 -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 26D9E28003E for ; Thu, 17 Aug 2023 04:09:05 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E63DA80FC7 for ; Thu, 17 Aug 2023 08:09:04 +0000 (UTC) X-FDA: 81132871008.07.A72AF96 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf17.hostedemail.com (Postfix) with ESMTP id F17B740015 for ; Thu, 17 Aug 2023 08:09:02 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf17.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=1692259743; 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=6d5JvFgXB4IH48gYGHBh4W+DlbqVNMKKaT1DruFmElM=; b=60WjFwf+eKJRDZVAO6bNyP87hL7W6IM5u1AJW6DIKENNQmou37tVHq9InaqJWpa0+KY9Ak BjAbDVeXcEXyYOicSeu3ganvGm9sB/0ePl4fD1Cjuc9Q4z3Qz5embJV4/dPhB4kQZoTvtG Z3ywSMh9ovtlo4rsTl5MowXlFi9EJT4= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf17.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=1692259743; a=rsa-sha256; cv=none; b=h/SEhCTNR33irNLddXZfLHY9nL9f39hDHZqEL+OlEbBfyUfWRrIKrLIlL5W51LYI9umM7/ 9hNk9GqpjO8R+uylyu8+Dip0B2KN/+oNsJxLEAKmkJAT0QCkIHKQpvdxBq8ugvs4ZNwhhh KnvqPN8npu/msNkYd5RRK3FSfTTdE6U= X-AuditID: a67dfc5b-d85ff70000001748-d5-64ddd598af46 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, dave.hansen@linux.intel.com Subject: [RFC v2 5/6] mm, migrc: Add a sysctl knob to enable/disable MIGRC mechanism Date: Thu, 17 Aug 2023 17:05:58 +0900 Message-Id: <20230817080559.43200-6-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230817080559.43200-1-byungchul@sk.com> References: <20230817080559.43200-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsX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bTUBd4saNn8wgtoiAmcTB1j/sXYxcHMwCy5gk7h44xwqSEBYIkfj5oAXM ZhFQlXjSfR3M5hUwlfi9uYEZYqi8xOoNB4BsDg5OoEGb/6qChIWASj7sXcc6gZFrASPDKkaR zLyy3MTMHFO94uyMyrzMCr3k/NxNjMCAXFb7Z+IOxi+X3Q8xCnAwKvHwOuy6kyLEmlhWXJl7 iFGCg1lJhLeH91aKEG9KYmVValF+fFFpTmrxIUZpDhYlcV6v8NQEIYH0xJLU7NTUgtQimCwT B6dUA2P3ZhuRjPWfy9UDL9z26D014an2cSOOpjOvI+OntWtMrQ+p2SNpWPVj2QsVLiutoiXX qjN3Ws1XdrSZJ3J4XdK6yXb2ZReTAuYZTZC5uetgx6lJb+9tT352WbFr53kbN+6wxQrll3s3 a7MJVh1adddld+L01eIGKb61jSeeFpRGPJjxOOjbRSYlluKMREMt5qLiRAD0GJvFRAIAAA== X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: yrehn8r3qesr5cc9hdtpechsuy173eui X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: F17B740015 X-HE-Tag: 1692259742-134426 X-HE-Meta: U2FsdGVkX1/C0yKsSwT7KcvbP9CZfr53+JyOUM+/HgdO5+IbSy9k9cPdM+iJ1i/Wg0kmxyEw/+/93Wqaiz5Rm5KTLvH2xaA5wyzJLYFL8tTWQnRbf8lO2wu7/Od968KzBWkXzE+N0+dbWkqVMnK3D/vyxWv50LAdbEah926BxmX+6FCgr/N3ntjPM3h6uV6ihtxwZGC4nsKtnfPIoL0cekfT80E1Fv3/1cFIfY6RjT2CaG5k1dWZIhoPWjRbBw2OBaBqOomvn5/+zktRQlrBwOXVrkkFhhCOSO2SFf68lWBQr6mUA0YX82NvTQVD+ZM5tR/7JpOuogjtrHpzS0IM4u+NRUkkuhBDj8Vos1z4WZxOQAWjVXXey6DByiOvwDgFShaA/C7GO/4O+SMBfYJLZXRBlVq7b3uIBTFzb13asvSbB30B02DMAgHn6Bo4tHNoeixrarCPMywl8lOsq3uNtmkfSG2Pqtlz6Ysjk7597PBWynyiU+Ndron8NQeilQiFT5M5k5kg4DMn+wEFpfx81KZHTULJprC1KMFG5Aor9g7KMzQVmFeTg1g8Z5NSrMzEGAFDMtSGej9Km6l5gteZCj7N4HvMBXFxmZHTCAfyvm/1pFy8nheOAOrj6p1A0DcwbrsYxwALu2YZQcgTjy0Kv9eRpZYXeGFETxveb49r9zNMM97rLaLj1GXHbmKeq/lcqEKQAVg0nS/puO5So3P8UbHbz/598onfmW3e/AB3tmSNofRWiNjU5RUCBm6H/E89G9AJyfH8e/8KW7gnnZPnC5oHizwCu0RINovPRu+7DT43cTZaYVpJICnuORSFfdyLc14MWJbrYYuBROA5cgS2dzOkot5VYRAUV//4Gb8CeyaQeiGXChniwcQ48UFl9zuChQzm0F7eS8DQKB6nCc3MClNMquwsN9XAUlpVTUVVdcTDiEO8zOQKN3BNka5Hz0LbdRbc8ZT6udrEu4KgY+C GKg== 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: Add a sysctl knob, '/proc/sys/vm/migrc_enable' to switch on/off migrc. Signed-off-by: Byungchul Park --- mm/migrate.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index badef3d89c6c..c57536a0b2a6 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -59,6 +59,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 /* * TODO: Yeah, it's a non-sense magic number. This simple value manages @@ -288,6 +330,7 @@ int migrc_pending_nr_in_zone(struct zone *z) } #else +static const int sysctl_migrc_enable; static inline bool migrc_src_pending(struct folio *f) { return false; } static inline bool migrc_dst_pending(struct folio *f) { return false; } static inline bool migrc_is_full(int nid) { return true; } @@ -1878,8 +1921,9 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, VM_WARN_ON_ONCE(mode != MIGRATE_ASYNC && !list_empty(from) && !list_is_singular(from)); - migrc_cond1 = (reason == MR_DEMOTION && current_is_kswapd()) || - (reason == MR_NUMA_MISPLACED); + migrc_cond1 = sysctl_migrc_enable && + ((reason == MR_DEMOTION && current_is_kswapd()) || + (reason == MR_NUMA_MISPLACED)); if (migrc_cond1) migrc_req_start();