From mboxrd@z Thu Jan 1 00:00:00 1970 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 95BE8C761A6 for ; Tue, 28 Mar 2023 02:02:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DFBE6B0072; Mon, 27 Mar 2023 22:02:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 890056B0074; Mon, 27 Mar 2023 22:02:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 756F2900002; Mon, 27 Mar 2023 22:02:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 62C4C6B0072 for ; Mon, 27 Mar 2023 22:02:31 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 223A81C6273 for ; Tue, 28 Mar 2023 02:02:31 +0000 (UTC) X-FDA: 80616657702.01.D491B33 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by imf12.hostedemail.com (Postfix) with ESMTP id 296A64000A for ; Tue, 28 Mar 2023 02:02:27 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=zte.com.cn; spf=pass (imf12.hostedemail.com: domain of ye.xingchen@zte.com.cn designates 63.216.63.35 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=1679968949; 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=dbmW2ABHYYtg61rEy1nbCBswCBa7AVY3ve+1ooDn6JU=; b=HQWBYjAbEbX2X0A1YLdPRqvtWuKX22FEKdEBk1/7BXoMS3ImFxaYK2ulqqLIooNiiqn1p1 zp877+U+OurU+v06cM4xAA6g8VFKFHt+O0VBFh3xxw+bE1DI1yc6PZ4EmYuPUvsJLJJQgl tTBmI6StNQvNbIzSS93zgtiSlM4XOyg= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=zte.com.cn; spf=pass (imf12.hostedemail.com: domain of ye.xingchen@zte.com.cn designates 63.216.63.35 as permitted sender) smtp.mailfrom=ye.xingchen@zte.com.cn ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679968949; a=rsa-sha256; cv=none; b=i4NVTlUAp1nMUY0pvABkDMxSm2aULc7W4y1jufPAq7Qfgxw1LtBk3FFy2wzJme7FpSSAcW 6zLeB4LleA8PryGwBSxrJoPNdfiEMTk8TNzcIJcrfIv0fy3E6BFJ7OYEmrMEcrCmLl3ZzL yMczRBrqQvzbqErlTTMp7A0IoKxsdvU= 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 4PltH32qj7z6FK2R; Tue, 28 Mar 2023 10:02:23 +0800 (CST) Received: from xaxapp03.zte.com.cn ([10.88.97.17]) by mse-fl1.zte.com.cn with SMTP id 32S223RI070586; Tue, 28 Mar 2023 10:02:03 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp02[null]) by mapi (Zmail) with MAPI id mid31; Tue, 28 Mar 2023 10:02:04 +0800 (CST) Date: Tue, 28 Mar 2023 10:02:04 +0800 (CST) X-Zmail-TransId: 2afa64224a9cffffffff949-5d18a X-Mailer: Zmail v1.0 Message-ID: <202303281002046981494@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , Subject: =?UTF-8?B?W1BBVENIIFY3IDEvMl0gbW06IGNvbXBhY3Rpb246IG1vdmUgY29tcGFjdGlvbiBzeXNjdGwgdG8gaXRzIG93biBmaWxl?= Content-Type: text/plain; charset="UTF-8" X-MAIL:mse-fl1.zte.com.cn 32S223RI070586 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 64224AAF.000/4PltH32qj7z6FK2R X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 296A64000A X-Stat-Signature: ss8cngy6yqc5e8geknajy4cx7hwktp8s X-Rspam-User: X-HE-Tag: 1679968947-371781 X-HE-Meta: U2FsdGVkX1/UA0wTPj1Y2159un47zr8sLD6x59LnMpOg+TiVDHfjPI8ulnlGfGe/vshyAg2x/VCYNpyF2wpDWtb45CTX5blMYNyzHY7Zsbg142FnBQqfRefW0U7xf2s4p2KeD13Npwpub59nf+Cr8V7CpKSLEGOmhUbDgDGoK5s1kATMkchDTnan5WP/TfgDNefi/i2ukDm+0p9nBn12wHOPX5jypFhESJFLFQeAKPxNvwYepTlSO6TtAynCIo6c2cRu7Rin9RGqf4EpnCdhXd6CvE0XQaRDAE9ZcJzlKX4BU+z+7LIga203Wwo0cHUe0+At+mkPpHhDl9C8MpYcOwOtfJnG1OktEIL/9VcYe5jB1tPrbJyQrSBIPzU6GlXjX+sIvQNihzM161vcD62V5Tvfvzd0Pj8pwXu4XLcwTGf05Bt4JRj3tyh9muIvBQwb5Dc8zVY0u9cVNHj5pss7CWLO4eHmQC2vsmv6Ed+Ob4bjSyHNuY1Qhz7qdwGw1tYVG/RhVkyutjuMahXbmPk27HRNFXx8H5q22CzOJXTNctp6Ud7MId6L3q5aHyvprSytpwCAkvb7QWCaBlkmVOb7HOp8ywbuKrArEZti99HS+5QTmJyP4Vy4kYPwl4D4rsxDcCe8GlIkZPlOFLCX9G30EJ/J2HoX2/er1vCWPz5BJUzrBTXMhJjFwKKSctHcBShXJk3PgrJOcgVVGvoIc/gQ8uZWNpUQ+0bhOe/IpynDTvjx12n0FpT+cRphAzn/+ouYdN+6QuxkUcRsDwiyBWhtGNj7yiVZDx0PneZkKEQYxQFiPyJFZ+8WcmTcnVvsPLEkRITw050X6IWfSQkRt/0w0AyjNL05W+CVvsYBC0AOhlkfWNUVETPxvoiGyqQWrFZWLdRERwh/upXHw9e/DtxM4EzwhTd8qPndLtohzIqxhuIeMB1K9B4458f3reNLsL4WmnNkhbJ5epbu2siBOeb jLKZ6SUk LRCTYxZzZLUOJ8nALodod6RFd0DmmPBXEZnLogDRLxcIfx9FEzbOO5jaaJRDCz9Din1yg//nlrwUUn00VHUIgoQzMJlxv/mzTHNxp/GP21ion21G+tX2Xf/yRJMagP2XUaetNFaZsgbV9jsdny2k3eHbjc1RDEeI61UQkaNjbDn/ts4JN92faIc+sCMOmwtgxAr2MxVcEKRNPmJhp6OY39tp4rFndXkdKQaAQiB2snrPzRNU= 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. Signed-off-by: Minghao Chi --- include/linux/compaction.h | 7 ---- kernel/sysctl.c | 59 -------------------------- mm/compaction.c | 84 ++++++++++++++++++++++++++++++++------ 3 files changed, 72 insertions(+), 78 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..e23061f33237 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -746,27 +745,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 +2135,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..3dfdb84b9c98 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1728,7 +1728,14 @@ 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; +/* + * Tunable for proactive compaction. It determines how + * aggressively the kernel should compact memory in the + * background. It takes values in the range [0, 100]. + */ +static unsigned int __read_mostly sysctl_compaction_proactiveness = 20; +static int sysctl_extfrag_threshold = 500; static inline void update_fast_start_pfn(struct compact_control *cc, unsigned long pfn) @@ -2584,8 +2591,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 * @gfp_mask: The GFP mask of the current allocation @@ -2742,14 +2747,7 @@ static void compact_nodes(void) compact_node(nid); } -/* - * Tunable for proactive compaction. It determines how - * aggressively the kernel should compact memory in the - * background. It takes values in the range [0, 100]. - */ -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 +2777,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) @@ -3075,6 +3073,65 @@ 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 +3147,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) -- 2.25.1