From: Vlastimil Babka <vbabka@suse.cz>
To: ye.xingchen@zte.com.cn, mcgrof@kernel.org
Cc: keescook@chromium.org, yzaikin@google.com,
akpm@linux-foundation.org, linmiaohe@huawei.com,
chi.minghao@zte.com.cn, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH V6 1/2] mm: compaction: move compaction sysctl to its own file
Date: Thu, 23 Mar 2023 17:15:08 +0100 [thread overview]
Message-ID: <704cae66-5128-8628-b7ea-e5e0fe9e0f03@suse.cz> (raw)
In-Reply-To: <202303221108054628708@zte.com.cn>
On 3/22/23 04:08, ye.xingchen@zte.com.cn wrote:
> From: Minghao Chi <chi.minghao@zte.com.cn>
>
> 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 <chi.minghao@zte.com.cn>
> Signed-off-by: Ye Xingchen <ye.xingchen@zte.com.cn>
> ---
> 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 <linux/highuid.h>
> #include <linux/writeback.h>
> #include <linux/ratelimit.h>
> -#include <linux/compaction.h>
> #include <linux/hugetlb.h>
> #include <linux/initrd.h>
> #include <linux/key.h>
> @@ -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;
Couldn't you move the "__read_mostly" and "= 20" part here as well? And the
explanatory comment? And make it static too?
> +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;
And remove this.
> -
> -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)
prev parent reply other threads:[~2023-03-23 16:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 3:08 ye.xingchen
2023-03-23 16:15 ` Vlastimil Babka [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=704cae66-5128-8628-b7ea-e5e0fe9e0f03@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=chi.minghao@zte.com.cn \
--cc=keescook@chromium.org \
--cc=linmiaohe@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mcgrof@kernel.org \
--cc=ye.xingchen@zte.com.cn \
--cc=yzaikin@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox