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 596A8C282D2 for ; Tue, 4 Mar 2025 14:25:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9924B6B0089; Tue, 4 Mar 2025 09:25:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91CC96B0092; Tue, 4 Mar 2025 09:25:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65B716B0093; Tue, 4 Mar 2025 09:25:33 -0500 (EST) 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 491C66B0089 for ; Tue, 4 Mar 2025 09:25:33 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E35538013F for ; Tue, 4 Mar 2025 14:25:32 +0000 (UTC) X-FDA: 83184091704.26.5C82DA2 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf05.hostedemail.com (Postfix) with ESMTP id EE187100007 for ; Tue, 4 Mar 2025 14:25:28 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=NsyYfudN; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="PWxEua8/"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=NsyYfudN; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="PWxEua8/"; dmarc=none; spf=pass (imf05.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741098329; a=rsa-sha256; cv=none; b=Bnn0VfqKRyIWNApcy1oiitAtiofWbyLjhIFFG3FAh7EJhAivaRIZhRTEk/O0OCHFnEkDAk SALLKn0ZwDv9povpvACoREYQc40+f5klBOAEvJza6+RyEgghMRMnBOz9MxcVJqcUSlHjSB ytmQTHUFhuIwtIILAt1mgMqus5GeOdA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=NsyYfudN; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="PWxEua8/"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=NsyYfudN; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="PWxEua8/"; dmarc=none; spf=pass (imf05.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741098329; 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:in-reply-to:references:references:dkim-signature; bh=21R63puFBhLrbr9hO90cmJ3hCPSZdL7Adv8+v03JTpA=; b=yPUU54xHrSCyUCnxYoZM6qu5i+T/zez8ksJHJARp/HV0hFtfGrVO92+96JW1LXoUZZUgSv NhwWulJyr5msSxZYDAYCz6qN1tnYVfOmdwJoSTIjPaFS9dmbfFUR605KkTQRz7m1N+CZ1G r6ciqjiSy6hLi4YcRYGKL7lhTTUxSc4= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2357A21170; Tue, 4 Mar 2025 14:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1741098327; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=21R63puFBhLrbr9hO90cmJ3hCPSZdL7Adv8+v03JTpA=; b=NsyYfudNY9FvF1DL3njfH8UJz/mC7PaFYt4sJHkItzjHknJ/lyBc//bIUhmBTwymukq0SC wej+vQVwkTB1AnPXJYsidSrKE1YmqNjSIc0h8/qvuapxRtn6ulH//Lu+c59sUQOePJn4F+ xhPTrRt2AOOV+lD++9nc9oNZCeUHsyQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1741098327; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=21R63puFBhLrbr9hO90cmJ3hCPSZdL7Adv8+v03JTpA=; b=PWxEua8/DYaf0TaSvOdTf1d0fUsUZls/1sdlh/pe7g8t/wlQL17tO9K9WBtZv+2B07Rp4s Q49fLmhD94CZglDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1741098327; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=21R63puFBhLrbr9hO90cmJ3hCPSZdL7Adv8+v03JTpA=; b=NsyYfudNY9FvF1DL3njfH8UJz/mC7PaFYt4sJHkItzjHknJ/lyBc//bIUhmBTwymukq0SC wej+vQVwkTB1AnPXJYsidSrKE1YmqNjSIc0h8/qvuapxRtn6ulH//Lu+c59sUQOePJn4F+ xhPTrRt2AOOV+lD++9nc9oNZCeUHsyQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1741098327; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=21R63puFBhLrbr9hO90cmJ3hCPSZdL7Adv8+v03JTpA=; b=PWxEua8/DYaf0TaSvOdTf1d0fUsUZls/1sdlh/pe7g8t/wlQL17tO9K9WBtZv+2B07Rp4s Q49fLmhD94CZglDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 17F521393C; Tue, 4 Mar 2025 14:25:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 3evSBVcNx2ejMAAAD6G6ig (envelope-from ); Tue, 04 Mar 2025 14:25:27 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id CD815A0912; Tue, 4 Mar 2025 15:25:26 +0100 (CET) Date: Tue, 4 Mar 2025 15:25:26 +0100 From: Jan Kara To: Tang Yizhou Cc: tj@kernel.org, jack@suse.cz, brauner@kernel.org, willy@infradead.org, akpm@linux-foundation.org, rostedt@goodmis.org, mhiramat@kernel.org, ast@kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND 1/2] writeback: Let trace_balance_dirty_pages() take struct dtc as parameter Message-ID: References: <20250303100617.223677-1-yizhou.tang@shopee.com> <20250303100617.223677-2-yizhou.tang@shopee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250303100617.223677-2-yizhou.tang@shopee.com> X-Rspamd-Action: no action X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: EE187100007 X-Stat-Signature: ytzsco5dd3p76qwxxfh1e78gbwkpq6xu X-Rspam-User: X-HE-Tag: 1741098328-910335 X-HE-Meta: U2F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EQ2NGjeEhAWYbnyQ8Nx1W+/bKS13bQpLF3oq6ENujEBmoJ8rUtq9rSxKgRNIlwEPB8njEQYBplakCEaixHziZcX/oj/i2lL6TvV0LaaSoFH7n2XH1q1mdyFoYEw65xmR4PFPYdVR38ggp+nHN0UOa+7RHismIE2h97NrNxbfAmZm5F/6HxjYDij9Bwd2caxFr0VPDFi+SpwwJUKhvuo3+6SmRAJvtV+XO4q4b0y7qSN7J+2YZaWH/+IozSCPQgvYF1uMxeteyfBgQZPBjZcJErL/cFuo21XkTs5eE0n5zOhaMGRu+yLBlLoBXWn6WImfqFvsZJpTd9EZ2xcVOQpQrMUEaUqi8Es+dv6HnjuX 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: List-Subscribe: List-Unsubscribe: On Mon 03-03-25 18:06:16, Tang Yizhou wrote: > From: Tang Yizhou > > Currently, trace_balance_dirty_pages() already has 12 parameters. In the > next patch, I initially attempted to introduce an additional parameter. > However, in include/linux/trace_events.h, bpf_trace_run12() only supports > up to 12 parameters and bpf_trace_run13() does not exist. > > To reduce the number of parameters in trace_balance_dirty_pages(), we can > make it accept a pointer to struct dirty_throttle_control as a parameter. > To achieve this, we need to move the definition of struct > dirty_throttle_control from mm/page-writeback.c to > include/linux/writeback.h. > > By the way, rename bdi_setpoint and bdi_dirty in the tracepoint to > wb_setpoint and wb_dirty, respectively. These changes were omitted by > Tejun in the cgroup writeback patchset. > > Signed-off-by: Tang Yizhou Looks good. Feel free to add: Reviewed-by: Jan Kara Honza > --- > include/linux/writeback.h | 23 +++++++++++++++++++++ > include/trace/events/writeback.h | 28 +++++++++++-------------- > mm/page-writeback.c | 35 ++------------------------------ > 3 files changed, 37 insertions(+), 49 deletions(-) > > diff --git a/include/linux/writeback.h b/include/linux/writeback.h > index d11b903c2edb..32095928365c 100644 > --- a/include/linux/writeback.h > +++ b/include/linux/writeback.h > @@ -313,6 +313,29 @@ static inline void cgroup_writeback_umount(struct super_block *sb) > /* > * mm/page-writeback.c > */ > +/* consolidated parameters for balance_dirty_pages() and its subroutines */ > +struct dirty_throttle_control { > +#ifdef CONFIG_CGROUP_WRITEBACK > + struct wb_domain *dom; > + struct dirty_throttle_control *gdtc; /* only set in memcg dtc's */ > +#endif > + struct bdi_writeback *wb; > + struct fprop_local_percpu *wb_completions; > + > + unsigned long avail; /* dirtyable */ > + unsigned long dirty; /* file_dirty + write + nfs */ > + unsigned long thresh; /* dirty threshold */ > + unsigned long bg_thresh; /* dirty background threshold */ > + > + unsigned long wb_dirty; /* per-wb counterparts */ > + unsigned long wb_thresh; > + unsigned long wb_bg_thresh; > + > + unsigned long pos_ratio; > + bool freerun; > + bool dirty_exceeded; > +}; > + > void laptop_io_completion(struct backing_dev_info *info); > void laptop_sync_completion(void); > void laptop_mode_timer_fn(struct timer_list *t); > diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h > index a261e86e61fa..3046ca6b08ea 100644 > --- a/include/trace/events/writeback.h > +++ b/include/trace/events/writeback.h > @@ -629,11 +629,7 @@ TRACE_EVENT(bdi_dirty_ratelimit, > TRACE_EVENT(balance_dirty_pages, > > TP_PROTO(struct bdi_writeback *wb, > - unsigned long thresh, > - unsigned long bg_thresh, > - unsigned long dirty, > - unsigned long bdi_thresh, > - unsigned long bdi_dirty, > + struct dirty_throttle_control *dtc, > unsigned long dirty_ratelimit, > unsigned long task_ratelimit, > unsigned long dirtied, > @@ -641,7 +637,7 @@ TRACE_EVENT(balance_dirty_pages, > long pause, > unsigned long start_time), > > - TP_ARGS(wb, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty, > + TP_ARGS(wb, dtc, > dirty_ratelimit, task_ratelimit, > dirtied, period, pause, start_time), > > @@ -650,8 +646,8 @@ TRACE_EVENT(balance_dirty_pages, > __field(unsigned long, limit) > __field(unsigned long, setpoint) > __field(unsigned long, dirty) > - __field(unsigned long, bdi_setpoint) > - __field(unsigned long, bdi_dirty) > + __field(unsigned long, wb_setpoint) > + __field(unsigned long, wb_dirty) > __field(unsigned long, dirty_ratelimit) > __field(unsigned long, task_ratelimit) > __field(unsigned int, dirtied) > @@ -664,16 +660,16 @@ TRACE_EVENT(balance_dirty_pages, > ), > > TP_fast_assign( > - unsigned long freerun = (thresh + bg_thresh) / 2; > + unsigned long freerun = (dtc->thresh + dtc->bg_thresh) / 2; > strscpy_pad(__entry->bdi, bdi_dev_name(wb->bdi), 32); > > __entry->limit = global_wb_domain.dirty_limit; > __entry->setpoint = (global_wb_domain.dirty_limit + > freerun) / 2; > - __entry->dirty = dirty; > - __entry->bdi_setpoint = __entry->setpoint * > - bdi_thresh / (thresh + 1); > - __entry->bdi_dirty = bdi_dirty; > + __entry->dirty = dtc->dirty; > + __entry->wb_setpoint = __entry->setpoint * > + dtc->wb_thresh / (dtc->thresh + 1); > + __entry->wb_dirty = dtc->wb_dirty; > __entry->dirty_ratelimit = KBps(dirty_ratelimit); > __entry->task_ratelimit = KBps(task_ratelimit); > __entry->dirtied = dirtied; > @@ -689,7 +685,7 @@ TRACE_EVENT(balance_dirty_pages, > > TP_printk("bdi %s: " > "limit=%lu setpoint=%lu dirty=%lu " > - "bdi_setpoint=%lu bdi_dirty=%lu " > + "wb_setpoint=%lu wb_dirty=%lu " > "dirty_ratelimit=%lu task_ratelimit=%lu " > "dirtied=%u dirtied_pause=%u " > "paused=%lu pause=%ld period=%lu think=%ld cgroup_ino=%lu", > @@ -697,8 +693,8 @@ TRACE_EVENT(balance_dirty_pages, > __entry->limit, > __entry->setpoint, > __entry->dirty, > - __entry->bdi_setpoint, > - __entry->bdi_dirty, > + __entry->wb_setpoint, > + __entry->wb_dirty, > __entry->dirty_ratelimit, > __entry->task_ratelimit, > __entry->dirtied, > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > index eb55ece39c56..e980b2aec352 100644 > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c > @@ -120,29 +120,6 @@ EXPORT_SYMBOL(laptop_mode); > > struct wb_domain global_wb_domain; > > -/* consolidated parameters for balance_dirty_pages() and its subroutines */ > -struct dirty_throttle_control { > -#ifdef CONFIG_CGROUP_WRITEBACK > - struct wb_domain *dom; > - struct dirty_throttle_control *gdtc; /* only set in memcg dtc's */ > -#endif > - struct bdi_writeback *wb; > - struct fprop_local_percpu *wb_completions; > - > - unsigned long avail; /* dirtyable */ > - unsigned long dirty; /* file_dirty + write + nfs */ > - unsigned long thresh; /* dirty threshold */ > - unsigned long bg_thresh; /* dirty background threshold */ > - > - unsigned long wb_dirty; /* per-wb counterparts */ > - unsigned long wb_thresh; > - unsigned long wb_bg_thresh; > - > - unsigned long pos_ratio; > - bool freerun; > - bool dirty_exceeded; > -}; > - > /* > * Length of period for aging writeout fractions of bdis. This is an > * arbitrarily chosen number. The longer the period, the slower fractions will > @@ -1962,11 +1939,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb, > */ > if (pause < min_pause) { > trace_balance_dirty_pages(wb, > - sdtc->thresh, > - sdtc->bg_thresh, > - sdtc->dirty, > - sdtc->wb_thresh, > - sdtc->wb_dirty, > + sdtc, > dirty_ratelimit, > task_ratelimit, > pages_dirtied, > @@ -1991,11 +1964,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb, > > pause: > trace_balance_dirty_pages(wb, > - sdtc->thresh, > - sdtc->bg_thresh, > - sdtc->dirty, > - sdtc->wb_thresh, > - sdtc->wb_dirty, > + sdtc, > dirty_ratelimit, > task_ratelimit, > pages_dirtied, > -- > 2.25.1 > -- Jan Kara SUSE Labs, CR