From patchwork Mon Mar 3 10:06:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tang Yizhou X-Patchwork-Id: 13998507 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 D4F6CC282C5 for ; Mon, 3 Mar 2025 10:06:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D4C3280006; Mon, 3 Mar 2025 05:06:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 48429280005; Mon, 3 Mar 2025 05:06:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34BF3280006; Mon, 3 Mar 2025 05:06:31 -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 125A6280005 for ; Mon, 3 Mar 2025 05:06:31 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BB102140615 for ; Mon, 3 Mar 2025 10:06:30 +0000 (UTC) X-FDA: 83179810140.11.9E48371 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf20.hostedemail.com (Postfix) with ESMTP id C7AD21C001A for ; Mon, 3 Mar 2025 10:06:28 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b=JIIfrA3X; dmarc=pass (policy=reject) header.from=shopee.com; spf=pass (imf20.hostedemail.com: domain of yizhou.tang@shopee.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=yizhou.tang@shopee.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740996388; a=rsa-sha256; cv=none; b=pvh8FOToPa4oRODzK5b3W88NsAs7n5KpdDK3yvB57AE7mxD8lmV43onidqYBrsY5IUiGGh nnykhutV/ZY0NXv761FsVKgz+Ooyhpb7fkOWHXxd+VTvpWlHIB7FkCGjOt6j1iwJXcLR0d bLREJZKf1K6cj5bbCURXnsvUbLre/P4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b=JIIfrA3X; dmarc=pass (policy=reject) header.from=shopee.com; spf=pass (imf20.hostedemail.com: domain of yizhou.tang@shopee.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=yizhou.tang@shopee.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740996388; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=a/PqsQZYzh2gZL6Eu3byS2da5OGA46n+6o2RqtuMFMA=; b=wk3Y6QKb9pmIxQmY7x/MjYLQXR47PVk+3hUm12LkkkUTF4fkC1jdwofNmJ1xRS0iq3p68V AMYYwHzIQYboQubz5zjYc433l9vzLJj2YpXYwPcX7+MWFpe7k7vSbHM5mmU42GnmHcUi3e Vuiz2Q1O02r0bNyniTLpeI7lz2EgInE= Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-2feae68f835so5706703a91.2 for ; Mon, 03 Mar 2025 02:06:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1740996387; x=1741601187; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a/PqsQZYzh2gZL6Eu3byS2da5OGA46n+6o2RqtuMFMA=; b=JIIfrA3XsnLVU+DSmV3vpqXwsXi5McVf48chYR7Oqz8v5qojNjAIVZuGdx9lcxgKgL NLUI0Ej3mSD+gGFm0K/ioGmfi/d4mgpcVJ9mVz4ZaSyFjLmoUuxb1fBiqk3bnjf2N5B6 SjJwUbLoyarHA/wzc1b1t8pu83gkgsW9JS+SrnQRfdA6jQiY8ZJp60HC+DYwUX468YCz v4fPoY4XpoIGR6a54h5WROdiaU35y/qq39wLjLLCp7kSB2U3tlelRzXxzB+UNIjzVla9 1avUmD2BPQ9JepDbL2IOmI6KFtnXyN9LxF4A2WjGhcnth0fdPtK0A7xVzV6skn31Djca lsaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740996387; x=1741601187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a/PqsQZYzh2gZL6Eu3byS2da5OGA46n+6o2RqtuMFMA=; b=PIFQ+wGmeUpS4osduIru05Dy6X5babtTzIM4dCLOMgTLc3PIWqiS6K4nXx7bc+sZYw 7yM6biMyAkCjYDtSqGJvpQDr8JK088FbbIvjZD+RVgGTyITkmYUvWnLpDReJyWsvEj/3 /NFSXqiF0u9ORyDbmxVD4/PAaAYW/chaZVKCjxIrXLk7IPpqYz3vnZUXceJH2MH7ys6b WQLNyS5HUQXYJ4B0HI6KqPfEvIm/fkE3Kga1sMfsNe9aL0qB5GclOtiw7E2B1sfoi8pi w72c2S7EEwY9Pka8esBObe3Dods1h0qmM89wJqXPVCMM3anWAbJ43mDbNaSa70qfFYPB AffQ== X-Forwarded-Encrypted: i=1; AJvYcCWsbOXUEndVZ75+HL1xVypAFhnaBrz6RGleHlO+W4B1bWtT61DwkKO4U5TXHP6TcwOZy9zd21rr5A==@kvack.org X-Gm-Message-State: AOJu0YyQ620ZIBBRdmNh4jr6nBuoME3rMZmHiLPTCyvCYreYWnldo6Fy V8DiI+EvBVdL5aydkPV1awIbVbeQA2vbO1xYKV8IB5sQYOzSe9uQ11OU1zSA/Uc= X-Gm-Gg: ASbGncsGWzouAIJQihJo7wvkSg6M/lOz5WQ+xOl2YzrOe5C7U0rgMTa+EF6angzcHbT Zode9Drp1S59m0ayi7FeJCDx0v8cqdLwiQzFPum42DX99yQ6UKl8VOJ7AR3yr8qMmJw7FJM7dGN ASFSzMqnlYlk+lusuEmo6/piIRhLCnPlN0sVWgBP7xN6tolof/VnYtVC4FKju/jUNqwpmT7T18j NnXtJItQrfgPXwCgcloalQbufCpwkjRW8po0IN/5A/ETFR8KpLLuwgrtBdO/Z6pzzDUQBZtJ2Wk PI1DMjmf7LH1dvsLQnlFtsK0R+Xg9Q== X-Google-Smtp-Source: AGHT+IFrTHdg6NNuF2FgYK7p70ifhC/X3+blinwEJuQgxKQLWCLBaBmRYMC0rSrt/DKnxA7VSNUMuQ== X-Received: by 2002:a17:90a:e7cd:b0:2fe:8902:9ecd with SMTP id 98e67ed59e1d1-2febab2edbdmr18742630a91.1.1740996387540; Mon, 03 Mar 2025 02:06:27 -0800 (PST) Received: from localhost.localdomain ([143.92.64.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22350537b47sm74397275ad.251.2025.03.03.02.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Mar 2025 02:06:26 -0800 (PST) From: Tang Yizhou X-Google-Original-From: Tang Yizhou To: tj@kernel.org, jack@suse.cz, brauner@kernel.org, willy@infradead.org, akpm@linux-foundation.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, ast@kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Tang Yizhou Subject: [PATCH RESEND 1/2] writeback: Let trace_balance_dirty_pages() take struct dtc as parameter Date: Mon, 3 Mar 2025 18:06:16 +0800 Message-Id: <20250303100617.223677-2-yizhou.tang@shopee.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250303100617.223677-1-yizhou.tang@shopee.com> References: <20250303100617.223677-1-yizhou.tang@shopee.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C7AD21C001A X-Stat-Signature: xeb4y6r5dp9wfcq66gagof8n7d3jnz41 X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1740996388-220184 X-HE-Meta: U2FsdGVkX19o+BUeMG+k8VvrQf2/dqMZpacHoGVi06BYlyZMeKJNGtpYeUMrrLM5u4n2x34GFRVvnr6yyZAkvY9GdGw7LlHIK+mOkzyMyyBX0dHPwE/N0xQI/Giv+bu0EJsaY7WIWDt5+kkq4SnQtSSUVzScIox1E+rDxSE76yibU4Ly0P4n508h5rEfiGaNSmYcs6BWPrIWp6k/TH6Mtuq2GfdqSdN9zi32WeNlEJp80dNsQDKNqOVm152OiQSM0cpI4VPez3Vgmilfm4HsQ45R5LbUmctVECic20YprYSWDjD+SdNf5S/V1odglFb85Xjzp2mnYgdTEvqc3WEf7AkQvHsSMf9qQOR+YhZqlmrZGDO4/61kkyJdFEY0X6Su6BQdc1XDwgFuvxyes6gpImZuq9uj2kye+ldxs7BlOtsh8Ezx1/PziQmuuBOG+lRC/VK/Q3E69gvEWuLiFktNTECjI4B5msIpjBuL/LFqqgtjj/sTQchyd+JoIHywd2Jx7k8iOheGPXHtqw8Hb1EFPuHN8VV/WqzVL6wyqpLty8jyhdeijCQJlkvqjkt6i+73/jzgkfoyTjhkkoWuovJC8ZaI9AKpwJPf4dNXoMMdGRVD2o6sH2l68GXvCkas9bb+cx5/IvXACFD5Is1y+VDLcL7zdudxWi0A7C3Hiab2LVZ3bSf54Ugw0mJV5LHQ0E5/PQX7/EWI2d4jGt6fhRfrT/CHS9IwzLVtXyG+sQqQCvA9qLj25Fki+Dferj/spaPQdxeRHXxO/Eojhtmzm2v6CjKXeHProVRNRBUGOpLB1zXD1yxD05omy+O3pM+qmM5sfv24YYllKbzVsryfs7kzosdtY54A/+sXJtaF+6dfBro0758WKXRJOpa1rGvCVWUZVJLlyhquNGVonKFh4xuY4PXkNvZ2NtN6p7/vM4WnZf9bu/QvoE6+ZWoZX/pEdNknm1oa5s/d6AFxWq2xafW clbvz+Qg GrXvkeyJaOv1p19czkJ7kpGxHsSFmNpe0/KUz62/gX6IQCsHQD4n9egbcSNJQPQw1kmC2Dzr6Yz049BfQXlUMKfEaWitLAobWZjSsj/b1BOua26sTZm68tpyJvmQjN1Y7Ba7xMcrQNZ2s1TvnkcY2yiBgtnCkbjxMa7dKR4xsp0+Ubs6yLmT07IFOTY9XkZsRdCRAe1gAWwSFy9e5AgtIiE3LMRT2oZH+G8ETOKz9L/w9uCU6SGu0Ei+hBE7PTZCYqtZUy5o9Rxom0pACWLezJ+5/uGXy20vw8y1xw2s90SuaEVeCEcQ+yZKF8kd5FNyAN5snAz3ycTzOt62oEIKpqLTGw0nn8vyrie+pkfuIUY0u86l45/0tkdua/TjmUUy7oUXd 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: 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 --- 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,