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 769EBC6FD1D for ; Tue, 21 Mar 2023 15:26:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE1A86B0074; Tue, 21 Mar 2023 11:26:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A920A6B0078; Tue, 21 Mar 2023 11:26:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 959686B007B; Tue, 21 Mar 2023 11:26:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 832BA6B0074 for ; Tue, 21 Mar 2023 11:26:10 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3652280131 for ; Tue, 21 Mar 2023 15:26:10 +0000 (UTC) X-FDA: 80593281300.03.A911AED Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf02.hostedemail.com (Postfix) with ESMTP id E072F8000B for ; Tue, 21 Mar 2023 15:26:06 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=IxufG8ke; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=iifihTlZ; dmarc=none; spf=pass (imf02.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679412367; 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=KhZIrgDPD74P810Uzhm3yzk3QcaPBkmpJ69S46jGLm8=; b=tWS4UNMEJI1g26re65/PzGJsvAJWgMGWeNyLH/mYa1qtYTiNuT15sTWQkukzz5MJCSKz/r yjyEJM06R5Vu3VEJCxrwu8lSm6IPbXf65TuY/lvjFKNiMkP36lQy7gtedFxfr5I83tEAEJ 6KVW0zVFpWQTxKzfWBV63hgpjAJklds= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=IxufG8ke; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=iifihTlZ; dmarc=none; spf=pass (imf02.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679412367; a=rsa-sha256; cv=none; b=dBzK2Vm9UAToLNW+yOSv32UaQym9XLX8K6mhw0A0aDGMW8eAZx/ILVSLiUte8uPdBLuQum 8QArRGJ3BFr/Qx8eQXiuogY1sUjs/OwgCT0XU7x0XY4+37gcj3fRsXvpQr6hN5PyBvooiF 2LrsZZ7DzropN2bqaE4usgkwih0OuCw= 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 86541201AA; Tue, 21 Mar 2023 15:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1679412365; 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=KhZIrgDPD74P810Uzhm3yzk3QcaPBkmpJ69S46jGLm8=; b=IxufG8ke4f+UKmgoQV9q/5pnK2H7HS/lPMe58VwakCtSSyilAWnUwr9t/Heb37v6HiCLpn BlBwZD3X4kTs66OS+8xPceUvnB8vVapT+XsbC0P54WrH6agpRSpeABAal3nsKcvDzb3feL AdtAeRcqL7372FLZcJ633Tbl2WCYZ1o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1679412365; 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=KhZIrgDPD74P810Uzhm3yzk3QcaPBkmpJ69S46jGLm8=; b=iifihTlZKLBLfKievhIRtBdtYqOQPT0FlnQAt759dk7MD8H8kl3ugUZvGKgobBxFqe0pRl KGmK57gNjjk1uZDw== 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 4922913A9D; Tue, 21 Mar 2023 15:26:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id lAQpEI3MGWQfWAAAMHmgww (envelope-from ); Tue, 21 Mar 2023 15:26:05 +0000 Message-ID: <9952bbf8-cf59-7bea-ce50-0200d4f4165e@suse.cz> Date: Tue, 21 Mar 2023 16:26:04 +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 V4 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, chi.minghao@zte.com.cn, linmiaohe@huawei.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org References: <202303211511314414538@zte.com.cn> From: Vlastimil Babka In-Reply-To: <202303211511314414538@zte.com.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: E072F8000B X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: ojg7dsxm5mi9ukuwb5r6jao96gxtz7od X-HE-Tag: 1679412366-312302 X-HE-Meta: U2FsdGVkX19FchqoU8ldSh/w/lWo2ezePCSj73hbU8eHIapM87p/77vJ+keIq2gXK0u++X6NPKTbgYlX3pQFjIBPAFwHUO2P2Y9ALF1f2zKfpQUV/kyGxkxMomYqY98X0F9d37WXVMqoJsZOCQAh0+qhTNacDl1y/iqakOfEylWBOZ6PRQwdtm7J/qyOu10GveQWVxLFHhyDWSJn6rRxsTw9CNMxxiHQPWhgGtN6CaAvxTmiGP132DiQo3wXIPsd98cUJ2Wr72zWRfDQxQvsOZnECpBXoH7FbGZ0vp7Ew7adTrjWr7ZZys0PzQi67NoZcmbkvvJ0djQnfec0JLrcJRWAAI5e4+OLydmAQYHVIFyvO1DYuQ/42xowNinnsW1JngZngcKr6juqjfjONkhuWDQtwJQrpOLC1iVDEn2Yw50ivRsuPzLJ9kJqoZk/uEaqZJiD7zAuO+nNjrdppiC4P/y1cnSopKskhhFwePQdtyiX20Zgb47x+UN/XEnQmQixpRGnMkwpAIAF5vbmoywLB7mFIbgpfZlLapMZtQ6GYbVyJRPisk1IJiAS0WGmRxo23bqaR0MlE5mm/1RCGxUPMzNReU9i3/DlR5es6eomZ1DvU/RtNBMijQNxt/mw0yQ9p8/rdk/A7Hh7aSFw+QlhFFqxTw4R8oXCITE4aCYBoYgwObSmyr9nw/JCEeVP6A9L8jjwOcMKdUNQdcc/mlY2/W0fxT1B3Un3c8BLyPKqvSLAAncp8b/TFbAiAleb+3qE371vT9iTrkSuKl+ChOyxWDNbYLHFi+CxqAzDJdFn1p4Ybpw3IFW6a7WlaVtsHmu/T+pUh8IOS/My0TqE6R4Rp9/XPYCc01FWTSNjgCe1j+2Esd2y1vRYMf23Fda59KZanbNuWLjt4Giv7/Lfa0YgZVGyRpCjfjCbLshm0TyLjBoJ4zBMMpETs6hs7kQLmndYF5WfH/E1cqBLZNzViKF o8pjZUIk Y9dP8h1N7ECsEofYlz20wQ8K3+KBFfS1oZjf4VW4xr5Mf2kQjjDnqnaKGNyE2aGsEVppEIgndoO/WYe97iuh3fIeoieSWq7ObX69p19KwDQtXE5p2cuuyt41Gy8Sin/6cP0J50Xoy4ebAnxblq3YJfKAaqWZQto+TMjsoHNdSj2OgsZCTIpF1G3iVM8ArMyIiP9Uukw/4NG2zcgJlFCw4qANinuCQlVn/OlJzQRgQxinZQBCSu81RLeWmIvJ9K6+AVruwshhCTmZdRY+/vV6UIBoXXj2ZnIYoMHwXn0E9sEYbUxzcXWGcTbdvUiKfQn085TRdMaTnanOC+NLFcjEe/ee1ombzTunCnrXyOd3TGUEhFzP8MzCPP5XYByrj2RX7tihD8FFFhnojkjs= 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/21/23 08:11, ye.xingchen@zte.com.cn wrote: > 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 You should be able to remove the #include in this file now? > @@ -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; I would move all the sysctl_ variables scattered later in the file to a single place here. > 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; e.g. this > 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; and this. > /* > * 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; > Remove newline so that's a single one. > /** > * 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; Also move this one, and can be also static now? > -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; > } Please add newline here > +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; > +} Newline. > +#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 Newline. > 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) Thanks!