From patchwork Tue Mar 21 07:11:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ye.xingchen@zte.com.cn X-Patchwork-Id: 13182325 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 3DCEEC74A5B for ; Tue, 21 Mar 2023 07:11:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BE3D6B0075; Tue, 21 Mar 2023 03:11:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76EED6B0078; Tue, 21 Mar 2023 03:11:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65CF36B007B; Tue, 21 Mar 2023 03:11:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 56A676B0075 for ; Tue, 21 Mar 2023 03:11:52 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 20671121259 for ; Tue, 21 Mar 2023 07:11:52 +0000 (UTC) X-FDA: 80592035664.27.B7D2004 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by imf16.hostedemail.com (Postfix) with ESMTP id ECC2E180017 for ; Tue, 21 Mar 2023 07:11:48 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=zte.com.cn; spf=pass (imf16.hostedemail.com: domain of ye.xingchen@zte.com.cn designates 63.216.63.40 as permitted sender) smtp.mailfrom=ye.xingchen@zte.com.cn ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679382710; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references; bh=SErpFVF4UW6sVdnu3uE5fPjI1luIVawyC+EKUZbhv5c=; b=ZRA9MLsE+ITt08zZPJPuB3ZfsH34e1pVBxeGqkULDXQZgEU4pJ3o1DW9QGMd9w2HKFJSeU hB9wVcyGpNS9KfaVZboDawH3DudRCGTBEl4j1PkfJk8smryz+0lNn59RiQez+hkmFOdj81 5NYthg9bxIBp07BJd9RQOqYv0xm9B7I= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=zte.com.cn; spf=pass (imf16.hostedemail.com: domain of ye.xingchen@zte.com.cn designates 63.216.63.40 as permitted sender) smtp.mailfrom=ye.xingchen@zte.com.cn ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679382710; a=rsa-sha256; cv=none; b=nCM4/GP4CeNX/1M9TCZr7noTXkZ2YMTpwG/ZJnzP1BGj7f//sDak3wBabYrsYceqWjOW6F /sGqlMhqgbqdqmlLO71QujcEwny3RY4mAj7GOKeK0qMM4JsCZolC+PVCFKbp7TJTMnlJZ/ Q1FxOK9V/0T4iaTcrlDm5qnj85swgDU= Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4PgjTC5G9gz8RV7L; Tue, 21 Mar 2023 15:11:43 +0800 (CST) Received: from xaxapp03.zte.com.cn ([10.88.97.17]) by mse-fl1.zte.com.cn with SMTP id 32L7BTdq057573; Tue, 21 Mar 2023 15:11:29 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp02[null]) by mapi (Zmail) with MAPI id mid31; Tue, 21 Mar 2023 15:11:31 +0800 (CST) Date: Tue, 21 Mar 2023 15:11:31 +0800 (CST) X-Zmail-TransId: 2afa641958a30e8-bba8c X-Mailer: Zmail v1.0 Message-ID: <202303211511314414538@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , Subject: =?utf-8?q?=5BPATCH_V4_1/2=5D_mm=3A_compaction=3A_move_compaction_sy?= =?utf-8?q?sctl_to_its_own_file?= X-MAIL: mse-fl1.zte.com.cn 32L7BTdq057573 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 641958AF.003 by FangMail milter! X-FangMail-Envelope: 1679382703/4PgjTC5G9gz8RV7L/641958AF.003/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 641958AF.003/4PgjTC5G9gz8RV7L X-Rspamd-Queue-Id: ECC2E180017 X-Stat-Signature: ws4pcrbq5zw9enptonfhawjhiozt6cu1 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1679382708-730623 X-HE-Meta: U2FsdGVkX1+6s02WLZ9n7yMmcUBF5QQ+aj+Pkz5cYD2LI5Lz0GkT6b8kBpfFeTHzviFZLXjsgrxZmPK0sljie37mffVMqurtM/zbvHeYKVRCCissJUKy+gPTiexCdrqTPTxZLS8UkBbRfd5Xaf+IdbXWzextae+Gk4FaE4Gfp1oViGJF4XBPW5WDacnPvxMTAUQoGMvLuZFsBFrynKiDCg/GdNTFdnnareO4B0dxLoqjTiP+fN5F8+IanZ7f4sp8kWuqL1UJKh08s4rqrKNS4zI2B9uxS+AzOJPXKqttqF0C+SKgM5GJU2P1mH21WcB9OhT9kT5S8+v0teCnBeKZzGveAAcQK2/d3eOr+HJZsQMdwZhA8s5hH/yT/MnZrydYK+vfT9ywxWJSlUFqDoNokjovMyh+EUrWyC27QTaAN5wIWggOZ5h53CzxF6scsaJ1qYePVvAkqHEwy9VCfNlLc/8vZSzH3JwPJYXYi0Ec2tnoo6zlUXmOiCEifRXuoYzlRZq9+PDVon6lcflF98dxn+wYnjuPzu4x0Ote/0fWexjNFbbT904rqRi6j6LaKMS2Yr+KAWkTqMk0NqnnK4iZxSw6gs/Dl8KjPPot0SF0Ppq1YxEA7tNQ6cxTZfqF8WWfa1H6L+gT6kxrVs42QA/youj7TNr9jXsZ2dGG0QErnmMlvpio4y/u9clsrscpPkOgjeXDlmp8C7RKe/6OfJ9JCeCGKOm10XvghKA7tyx7ns2PDfp5NhHxOy2aars680fsgunMRg/pcPq9ROZXBxOCRIRyfRzN7yT8xG3+LfZ9o6r6dMiFYaXfdrHcgKHkgfAF8WXP2aDEdAbnnE5uQvFqtsMCbosN2xzHYEz67uCwyjcEnEJ/BJc2qMj5qWF6akOC4tb0uzdkR0Fv0vzh+LGboBFoNvgDYnHJJO0LFnHqw6nQ4m403JkqBPtPoxrB+jhctIVeNBuzAIc4X+6HuCf fPaGz64T 2JJj/AL8+MgVxZ9tfbG8GTSY40HdsGMaSlz7Q4IrlBFAYgF4G04svNvi/gIzp47wXiMsF24w2QOsDWRmUD4X8Jj9l5XWe0ZaxPyBVMgGfugsUHup3dQLWkhc1+19NZv6Ru424PNqD/YBLESsT/wJZxiSHqN/Hnb/76URNiqcz2h2WEmY7Y/rJrYV6fsR5RFDdgUPkOkROb66Rdq2x17sipbcwoFXYdCQ9Ok58S90GvIkLSPtqUDRdPDsoV78XciqvJPVwll0O5P4Z6a6lHda0mol5gxPNa4WpLSjTEcrlhH4T8uhgpaOEMZxhbckueeCdLc+nijVjDl8xl9oRofhHkh0Z+ymXAZxkYYIs 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: From: Minghao Chi This moves all compaction sysctls to its own file. Link: https://lore.kernel.org/all/ZAJwoXJCzfk1WIBx@bombadil.infradead.org/ Signed-off-by: Minghao Chi Signed-off-by: Ye Xingchen --- include/linux/compaction.h | 7 ---- kernel/sysctl.c | 58 ------------------------------- mm/compaction.c | 70 ++++++++++++++++++++++++++++++++++---- 3 files changed, 64 insertions(+), 71 deletions(-) diff --git a/include/linux/compaction.h b/include/linux/compaction.h index 52a9ff65faee..a6e512cfb670 100644 --- a/include/linux/compaction.h +++ b/include/linux/compaction.h @@ -81,13 +81,6 @@ static inline unsigned long compact_gap(unsigned int order) } #ifdef CONFIG_COMPACTION -extern unsigned int sysctl_compaction_proactiveness; -extern int sysctl_compaction_handler(struct ctl_table *table, int write, - void *buffer, size_t *length, loff_t *ppos); -extern int compaction_proactiveness_sysctl_handler(struct ctl_table *table, - int write, void *buffer, size_t *length, loff_t *ppos); -extern int sysctl_extfrag_threshold; -extern int sysctl_compact_unevictable_allowed; extern unsigned int extfrag_for_order(struct zone *zone, unsigned int order); extern int fragmentation_index(struct zone *zone, unsigned int order); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index ce0297acf97c..49a405447c77 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -746,27 +746,6 @@ int proc_dointvec(struct ctl_table *table, int write, void *buffer, return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); } -#ifdef CONFIG_COMPACTION -static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table, - int write, void *buffer, size_t *lenp, loff_t *ppos) -{ - int ret, old; - - if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write) - return proc_dointvec_minmax(table, write, buffer, lenp, ppos); - - old = *(int *)table->data; - ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); - if (ret) - return ret; - if (old != *(int *)table->data) - pr_warn_once("sysctl attribute %s changed by %s[%d]\n", - table->procname, current->comm, - task_pid_nr(current)); - return ret; -} -#endif - /** * proc_douintvec - read a vector of unsigned integers * @table: the sysctl table @@ -2157,43 +2136,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_FOUR, }, -#ifdef CONFIG_COMPACTION - { - .procname = "compact_memory", - .data = NULL, - .maxlen = sizeof(int), - .mode = 0200, - .proc_handler = sysctl_compaction_handler, - }, - { - .procname = "compaction_proactiveness", - .data = &sysctl_compaction_proactiveness, - .maxlen = sizeof(sysctl_compaction_proactiveness), - .mode = 0644, - .proc_handler = compaction_proactiveness_sysctl_handler, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE_HUNDRED, - }, - { - .procname = "extfrag_threshold", - .data = &sysctl_extfrag_threshold, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE_THOUSAND, - }, - { - .procname = "compact_unevictable_allowed", - .data = &sysctl_compact_unevictable_allowed, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax_warn_RT_change, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, - -#endif /* CONFIG_COMPACTION */ { .procname = "min_free_kbytes", .data = &min_free_kbytes, diff --git a/mm/compaction.c b/mm/compaction.c index e689d66cedf4..f56b3dc4563b 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1728,7 +1728,7 @@ typedef enum { * Allow userspace to control policy on scanning the unevictable LRU for * compactable pages. */ -int sysctl_compact_unevictable_allowed __read_mostly = CONFIG_COMPACT_UNEVICTABLE_DEFAULT; +static int sysctl_compact_unevictable_allowed __read_mostly = CONFIG_COMPACT_UNEVICTABLE_DEFAULT; static inline void update_fast_start_pfn(struct compact_control *cc, unsigned long pfn) @@ -2052,7 +2052,7 @@ static unsigned int fragmentation_score_node(pg_data_t *pgdat) return score; } - +unsigned int sysctl_compaction_proactiveness; static unsigned int fragmentation_score_wmark(pg_data_t *pgdat, bool low) { unsigned int wmark_low; @@ -2228,7 +2228,7 @@ static enum compact_result __compaction_suitable(struct zone *zone, int order, return COMPACT_CONTINUE; } - +static int sysctl_extfrag_threshold = 500; /* * compaction_suitable: Is this suitable to run compaction on this zone now? * Returns @@ -2584,7 +2584,6 @@ static enum compact_result compact_zone_order(struct zone *zone, int order, return ret; } -int sysctl_extfrag_threshold = 500; /** * try_to_compact_pages - Direct compact to satisfy a high-order allocation @@ -2749,7 +2748,7 @@ static void compact_nodes(void) */ unsigned int __read_mostly sysctl_compaction_proactiveness = 20; -int compaction_proactiveness_sysctl_handler(struct ctl_table *table, int write, +static int compaction_proactiveness_sysctl_handler(struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { int rc, nid; @@ -2779,7 +2778,7 @@ int compaction_proactiveness_sysctl_handler(struct ctl_table *table, int write, * This is the entry point for compacting all nodes via * /proc/sys/vm/compact_memory */ -int sysctl_compaction_handler(struct ctl_table *table, int write, +static int sysctl_compaction_handler(struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { if (write) @@ -3074,7 +3073,63 @@ static int kcompactd_cpu_online(unsigned int cpu) } return 0; } +static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table, + int write, void *buffer, size_t *lenp, loff_t *ppos) +{ + int ret, old; + if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write) + return proc_dointvec_minmax(table, write, buffer, lenp, ppos); + + old = *(int *)table->data; + ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); + if (ret) + return ret; + if (old != *(int *)table->data) + pr_warn_once("sysctl attribute %s changed by %s[%d]\n", + table->procname, current->comm, + task_pid_nr(current)); + return ret; +} +#ifdef CONFIG_SYSCTL +static struct ctl_table vm_compaction[] = { + { + .procname = "compact_memory", + .data = NULL, + .maxlen = sizeof(int), + .mode = 0200, + .proc_handler = sysctl_compaction_handler, + }, + { + .procname = "compaction_proactiveness", + .data = &sysctl_compaction_proactiveness, + .maxlen = sizeof(sysctl_compaction_proactiveness), + .mode = 0644, + .proc_handler = compaction_proactiveness_sysctl_handler, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE_HUNDRED, + }, + { + .procname = "extfrag_threshold", + .data = &sysctl_extfrag_threshold, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE_THOUSAND, + }, + { + .procname = "compact_unevictable_allowed", + .data = &sysctl_compact_unevictable_allowed, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax_warn_RT_change, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, + { } +}; +#endif static int __init kcompactd_init(void) { int nid; @@ -3090,6 +3145,9 @@ static int __init kcompactd_init(void) for_each_node_state(nid, N_MEMORY) kcompactd_run(nid); +#ifdef CONFIG_SYSCTL + register_sysctl_init("vm", vm_compaction); +#endif return 0; } subsys_initcall(kcompactd_init)