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 7B60CC74A5B for ; Thu, 23 Mar 2023 16:15:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D96366B007B; Thu, 23 Mar 2023 12:15:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D1EA86B007D; Thu, 23 Mar 2023 12:15:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B98F96B007E; Thu, 23 Mar 2023 12:15:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A2EC26B007B for ; Thu, 23 Mar 2023 12:15:13 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4B57F40646 for ; Thu, 23 Mar 2023 16:15:13 +0000 (UTC) X-FDA: 80600662506.19.5EEC2C0 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf19.hostedemail.com (Postfix) with ESMTP id C86131A0009 for ; Thu, 23 Mar 2023 16:15:10 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ZzmDOH7P; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="/OGtHFA8"; spf=pass (imf19.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679588111; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Nao5YJy5U8MamFKPwtjtE3/coDYBxSRiD+wySqWUFFg=; b=eCLna0Gt0bQ3R4Fe6gOsgbwvcS82+5T1gH6+k3h7z3sebJGgubQfbTeoVZp8Ftft8oZ8If KwkURa337ygbrwY2Q4vDrsph3fBseTYGEOuab7gcXuU2zYL3SblqRRt3lPJkuULEu/PgmG H5gJ4pgyiSnMEBQ11pK1jdiCJ+lLGj8= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ZzmDOH7P; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="/OGtHFA8"; spf=pass (imf19.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679588111; a=rsa-sha256; cv=none; b=xoPa9lZUkjmxH7zmWrYpCZpwjrEwyWNoXCoaTjkSjVDtczR41h2ozboOL0MgJpjNePcmwz P01c1S17nNSZ5VKKIfCl5AjL1XeOoCIBQfrKLkKdwPOnPyixrfPSA+e0J/EHP+CtKzWSnT dW9ronr/jcNMj1aeuT4flk/9cj/2T3c= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 253341FE0C; Thu, 23 Mar 2023 16:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1679588109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nao5YJy5U8MamFKPwtjtE3/coDYBxSRiD+wySqWUFFg=; b=ZzmDOH7PKtRDNFQCKzB3/DwbckrO6pbYa4doXEGSz2y3e2l0Wzal7+txERSkuW6NZT7H8/ 9Hwp1U1KBYFVP/3zozE/xwh9grNSt5PB45WVCUzsw3iVWXcQ2al7yimnJ1powbWagKkepP XBGdDWyN716cd0hJhGVQlwdUlRgKwLA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1679588109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nao5YJy5U8MamFKPwtjtE3/coDYBxSRiD+wySqWUFFg=; b=/OGtHFA8Cw9F9Twg6BicDum99ioSBoKzFJ3KSm0S9aCrgaOfE8uNHqrXaSkbWUkphXNO/3 07sWoT6Ouf/mbyDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F14B513596; Thu, 23 Mar 2023 16:15:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KGI+Ogx7HGRzQQAAMHmgww (envelope-from ); Thu, 23 Mar 2023 16:15:08 +0000 Message-ID: <704cae66-5128-8628-b7ea-e5e0fe9e0f03@suse.cz> Date: Thu, 23 Mar 2023 17:15:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH V6 1/2] mm: compaction: move compaction sysctl to its own file Content-Language: en-US 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 References: <202303221108054628708@zte.com.cn> From: Vlastimil Babka In-Reply-To: <202303221108054628708@zte.com.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C86131A0009 X-Rspam-User: X-Stat-Signature: 6fxh41d5sfihfi1b8ow5366xn7qzygbg X-HE-Tag: 1679588110-816330 X-HE-Meta: U2FsdGVkX1+q7oVmhkFs3tA29OzAzE27rnd8FCpNGrvjyZHLjyB+0VPk6S1hj9efRkn3F3+HC6PytYUlvWS2551L/EgKHAKil2KHzIu14lgxDdbYrpq9kMS+uQEYLs2dUi+KafGelvXPb/tR3VISdNCH1aPpPWnKrQiB7TWKDwM43Fr0Ugxh425Xh2Eedc9uI8+b+JUaDpcyTPGAsgDwCTvEoO8jzuARFOw6hoNfpuL5VzlaxfumGzF656Q7ErmB9a6JfP/RA+/oNbMf7jD5NjgljvgV4IJl9lBRsKjwPL/5W+duelnVZ/G0fQCSIjKtTuP1b4gPzhdZXlKAR1a+KiMVWQ8R/ujuFyG8aiA2VdwTgxefhFOjfs3f225uVRf37eWKGaQZfgS5e+wnyfsdIRkjVUPPIFq71iOKH0d0xN7cu4ZW3J2U0fhJqhUFqlcWAOnmvEWo2KOVIQa/nUmDlxugXfr5Blx4U1TGUhEXtb7PhsdA9X0fxI6aDYmszRGVt+T/tyTNYkUVZah7uZvR4G7dBvixkObZcp2IFBlOX8aBC1JUTjmLZEyjTu8rs7vRImgeSdfIz3qr176gFTa6jq7mxyYIC9eMY2PWuk/C3jCxm1FDChaFhgVK1RpR461h18NMG03yLOcynKhLxKPsStQYbhhRJ6M6/KhbNgRQaByHCCCyY1mGWEr5P6rR+yUIN/NTA008PH/6h4jP/j3A602IbHCJDlZXKJIP8c/OxrAzZuPMwx0SXMlzzX/6/5PeaFAwB74X99UzZ1vhXPjZuzxVwcjf+5lXRC8Kbi0npCmb701gcB4J9K3J+jwM9SuGLNHrxT4IXzpfeqkMvRrBCw1CdC+SdZjWUXupu+5kg4/sMzVuhYrgvn/nbV97PHJy5hGMBy/Aczat+Uw0fuPUCBLlo7jayceMlCEKpFnzt469y338clcjCrbuZqg7QHdeAe2Vjp86FlPu7p2nHHy Q1XqH7XA Sb3N+U0BDwz2yz4i3LI7to1tt4he0JlaaTXlVuMSQoijmmxSK5kwQLTCsdKkapA65o/HSRETG2I903TbrRA+C9ztswPZxbzejfCLOZ185sX7iQKrLUpWPSXW91J409P2+PBorDJVuMbufLd+yiGbiEEEAF+RAl76u8fG/eJufIPFDYmQ1BHLRASK2+UHsBF/jYQFYhvazx4hANAnRu+PQcVmgo9VgpbwCdsIOc+Li5aTCP13JupUtwzb5+l1gNSrJnL1kSBf/7gkQs/bMPdfH9/KIz1o7dSAF8yGSD0P18DuD5DxayYxo3wBea83SJsMRuZJJNLcWExEBR/I= 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: On 3/22/23 04:08, ye.xingchen@zte.com.cn wrote: > 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; 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)