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 F4192C6FD1D for ; Wed, 22 Mar 2023 03:08:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69D506B007B; Tue, 21 Mar 2023 23:08:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64D31900003; Tue, 21 Mar 2023 23:08:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53BC6900002; Tue, 21 Mar 2023 23:08:25 -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 457C96B007B for ; Tue, 21 Mar 2023 23:08:25 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EC69314027D for ; Wed, 22 Mar 2023 03:08:24 +0000 (UTC) X-FDA: 80595050928.11.402A4E3 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by imf14.hostedemail.com (Postfix) with ESMTP id 491EF100004 for ; Wed, 22 Mar 2023 03:08:21 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=zte.com.cn; spf=pass (imf14.hostedemail.com: domain of ye.xingchen@zte.com.cn designates 183.62.165.209 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=1679454503; 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=rjeLWaIedDStpvQjajlel7uym9wXZaK4YF7tOlyV+wY=; b=kPSIJUwRXB6MtCfl2ToLhZ6cV9L3yFuNVumPWeTK97brWCBGFmV3ZwZq372FkE7fQTmQL8 K8Of8TiYyPJAAYjjuPsnmXvyXKTatr6HAteCsMqE0bqqP4rJKvH9CO6QHiYMQpcDPWUMkj xWfYWlD7JckOw2IWTQ+3Td1ywWEkB7A= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=zte.com.cn; spf=pass (imf14.hostedemail.com: domain of ye.xingchen@zte.com.cn designates 183.62.165.209 as permitted sender) smtp.mailfrom=ye.xingchen@zte.com.cn ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679454503; a=rsa-sha256; cv=none; b=YIk1zYU4LOa+NTFdwpJ+z564pASWZnN8vA70BCHxGJHaWXxOuB5EFl4rkmESDmD7ywnCtV quiXVPyfvNSxSWEVjwlEKgSdXcAAV2mL5lftNs0mdUAINnys6otndMJLZmuQ2RNdHa1OXb CtTf/RBJ7J1N5EuIykGSMI7YFgW5lfk= 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 mxct.zte.com.cn (FangMail) with ESMTPS id 4PhD1t1w3Lz501SY; Wed, 22 Mar 2023 11:08:18 +0800 (CST) Received: from xaxapp02.zte.com.cn ([10.88.97.241]) by mse-fl1.zte.com.cn with SMTP id 32M384fw094843; Wed, 22 Mar 2023 11:08:04 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp02[null]) by mapi (Zmail) with MAPI id mid31; Wed, 22 Mar 2023 11:08:05 +0800 (CST) Date: Wed, 22 Mar 2023 11:08:05 +0800 (CST) X-Zmail-TransId: 2afa641a71157b7-98788 X-Mailer: Zmail v1.0 Message-ID: <202303221108054628708@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , Subject: =?UTF-8?B?W1BBVENIIFY2IDEvMl0gbW06IGNvbXBhY3Rpb246IG1vdmUgY29tcGFjdGlvbiBzeXNjdGwgdG8gaXRzIG93biBmaWxl?= Content-Type: text/plain; charset="UTF-8" X-MAIL:mse-fl1.zte.com.cn 32M384fw094843 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 641A7122.001/4PhD1t1w3Lz501SY X-Rspamd-Queue-Id: 491EF100004 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: hnib5i6mu3btudyr3ztqb59x41abe13f X-HE-Tag: 1679454501-570010 X-HE-Meta: U2FsdGVkX1+vlf3zB6P9ONirddH6GkWcMT++LWMH2h/F4AjocMTc9SftUCIk9Py+mGJ2VUnkOFGrLEeqkbI79J0OpmTKyboaBFx5sR9E/IQcANTWOgfZdMI3m/Z2VI8otihMmz3U9NfoENgT2Hpwj1Pef6C+u4cinS42PEefhhxDrkt+whnE05yANVkyq1wiiGUDmNqzB+DpCNEwiWMbnRe0i9ZpQmfT5gnNhx58gw3KYcWZ0ZImBwQXlMtGAjgE/JYQ+v0maqEGFqEFuDpIqvmcDWmokfwiy/Zft68CPJPQa+mgot9MJBwHxAKcg17N8cFX045AhXfLtSrS7E3fs3MZEQKDiWAUyQTJyZwrxGCOleQwcyt+oQI5PwvBuvbtNIWXFGCsXBVxuYQ9VKLfVwRegc/QLjb4rLkSyomQbiNSGlrexPrVHckmYHQBJOvsY/hpDPiGwxK+Bm/Vnli8qL08ZmN1I4N1iMte4uuFjO8TS0guaydMjlQ8BizVGg2T18kOox0AMKUup8jrqOU+T8R+d2IIxbo1rsAv6V5iludLfPLwFKH/fnkj7WqwhtSDHxapQnFI5KTd97LiYWV0GcmVGnMWDLAY4h6Zb8y2CVvGibInBpncv3Dx1D3E6mpqqPF+KRmQeZoWBp7k21pWSOFPd61cSZ1/VCnFCz91VY9Q9Bh7ucpBTl/8wvuEx/yzcxP2dAboNRzYsnjwa9p98TA/j+p/LvJ0jAAQ2zhn/XclPjSZ20KCQI1jFEbWAPibBS0ancgJAuH2+IF+LOnrTIQr6D8uaOl3Pu0fTQSY1y3QeqID1eC5Ul/aeNtBz7RJ/IscYu2XCAP8lQChF3SQLbD+CGDbsSWgZtm35FmKkP1QknSBodTnhSHx3ADCCIn+QocghW14K7xl4zZPvDKF+tCPmHZoZizLgU/tYwJUzw+f2CWGzt6MMy2Wq8kLTLT0zGWCRv/SbJ5ZLJbspuk 89y52Kml izFInfIRMebDGyMSarNvQYEeR9H+cuM1dSJY/fb6LzFS5EYFgD7/7524hxX1TyJxU8yXXiHfSbIjs2emLoKJ3CUJIoPYuoZQ6JjOyvkYHOtYLrEvDfLioKGKSO1CF2ZWrV2IopTu/bFmzQwNLEg4kY+7DXB4k8GCtHlng4+B6WxhCBYP6kTLVbc1BBxQ2DTyyRj4xFs5yR9MuFp4NQ+QSFeH8VzJPZS4d/DkJcxyZFCoyr3kCI4T+AZ1K15K1Gn6+9I7BCUEi5GyVc4sZdpbFE+SAOkaHrHwjpIsSIdv3QX77ixQ= 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/lkml/9952bbf8-cf59-7bea-ce50-0200d4f4165e@suse.cz/ Signed-off-by: Minghao Chi Signed-off-by: Ye Xingchen --- include/linux/compaction.h | 7 ---- kernel/sysctl.c | 59 ------------------------------ mm/compaction.c | 73 ++++++++++++++++++++++++++++++++++---- 3 files changed, 67 insertions(+), 72 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..ec2989f2c5d3 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1728,7 +1728,9 @@ 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; +unsigned int sysctl_compaction_proactiveness; +static int sysctl_extfrag_threshold = 500; static inline void update_fast_start_pfn(struct compact_control *cc, unsigned long pfn) @@ -2584,8 +2586,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 @@ -2748,8 +2748,7 @@ static void compact_nodes(void) * 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 +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) @@ -3075,6 +3074,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 +3148,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