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, From patchwork Mon Mar 3 10:06:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tang Yizhou X-Patchwork-Id: 13998508 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 A9B45C282C6 for ; Mon, 3 Mar 2025 10:06:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34ED1280008; Mon, 3 Mar 2025 05:06:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FF2E280007; Mon, 3 Mar 2025 05:06:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19FDE280008; Mon, 3 Mar 2025 05:06:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id ED9BA280007 for ; Mon, 3 Mar 2025 05:06:34 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6C48B50614 for ; Mon, 3 Mar 2025 10:06:34 +0000 (UTC) X-FDA: 83179810308.12.4BC6A07 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf08.hostedemail.com (Postfix) with ESMTP id 55C85160002 for ; Mon, 3 Mar 2025 10:06:32 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b=dJ73DP0E; spf=pass (imf08.hostedemail.com: domain of yizhou.tang@shopee.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=yizhou.tang@shopee.com; dmarc=pass (policy=reject) header.from=shopee.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740996392; 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=TlOgUF0I+Rkuiq5isF50AFm1bBn1sNSF5ax0jaYNIBw=; b=RGQOflMnwb7dxJZ2yN5AyeItZnurlEfnObwSP3XF2kTaBDmjc5wYhyGwA4lZRnb49YeHoI oVgLxY1rIH79/k4TKPkKZP0GItun4C9zyQkeORgqQLmxos/mvH67dmbuOZzn1gvvQU1mij MOyz089z/eUhepmRlFSqv5qoj9oA+nc= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b=dJ73DP0E; spf=pass (imf08.hostedemail.com: domain of yizhou.tang@shopee.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=yizhou.tang@shopee.com; dmarc=pass (policy=reject) header.from=shopee.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740996392; a=rsa-sha256; cv=none; b=tp/ucnE3jeqYAcoOGyboKf/mTDtDipEyF+GRrnV+X/nmsc2sTDTCEiVJ6wZYjtHBghN5kY n+r2g4Fe6NgDcc2IC6bsWSG6GrNm0p8xYve5h7PKM+xUTBuI2mZRyxbC9oojJveTHVMEIj JcFYVROrSJa/lxAMsLxjJzbHMC9734c= Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2235189adaeso64204105ad.0 for ; Mon, 03 Mar 2025 02:06:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1740996391; x=1741601191; 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=TlOgUF0I+Rkuiq5isF50AFm1bBn1sNSF5ax0jaYNIBw=; b=dJ73DP0ELB6+3iZnAp5lNc8AWY4vvKv5K/gHN/h3s7DMaTtpkBleessCSosavP4TNK 2HNHPKdpY2MkWdlZcyFCofk9qcRta1oKRoh/IgF3nnrNjUHk8RQJb1t5VpTBGEjEc1Ep D6kXcH38Y0BgArvSmVQqGrJoPthniiytAP0Og9d7BvHwH3ca7oy3JGOC4fIrMGP5aKce xos0u8sYVQ/RwNMideaVdyGpbyjubcf/uc0HAKaTto+N2KOmtu1pGy9XoznIVPMcYA8Z wp+CPGtRw4slsJlz4ZB7xZ6QOBRFjMIfXNbLf805BeWa3l1xvQbNRVyTZLmZ0T1BHftQ TDpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740996391; x=1741601191; 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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chTHQ== X-Received: by 2002:a17:903:1252:b0:223:4d5e:76a6 with SMTP id d9443c01a7336-22367413da7mr199503185ad.1.1740996391188; Mon, 03 Mar 2025 02:06:31 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Mar 2025 02:06:30 -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 2/2] writeback: Fix calculations in trace_balance_dirty_pages() for cgwb Date: Mon, 3 Mar 2025 18:06:17 +0800 Message-Id: <20250303100617.223677-3-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-Stat-Signature: a8t53p6xzftpx3wp6s1xy33x778kndpm X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 55C85160002 X-Rspam-User: X-HE-Tag: 1740996392-91388 X-HE-Meta: U2FsdGVkX1/kyaGxKE0e4eycsEpDEn0M1kAd6+H08O1eVglH9w/Ls6IvHqjlE2wMjhQiTF6YuYpJZLVHd65vMueJih9PLzWrdaLZf8DDhIJQx2G5Zy2AJ6HLhn2osTyC1Mb2btreAt5EZIzFgfoyhXZtDedIktSe34r4p0/HfNgKWWrMPCVab1PyRJYmA2UAqREwEdt9PRVeWajqhfWfbVINzc3jignAKWmexU2+mqTPRa2MO5s7J6nuGb4e6nb/4MzWeLjHQO9Ks906gQXOwgIYGSTd6x7rK1hSnJ62rlrMWZsbUWvwZlLA9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-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 In the commit dcc25ae76eb7 ("writeback: move global_dirty_limit into wb_domain") of the cgroup writeback backpressure propagation patchset, Tejun made some adaptations to trace_balance_dirty_pages() for cgroup writeback. However, this adaptation was incomplete and Tejun missed further adaptation in the subsequent patches. In the cgroup writeback scenario, if sdtc in balance_dirty_pages() is assigned to mdtc, then upon entering trace_balance_dirty_pages(), __entry->limit should be assigned based on the dirty_limit of the corresponding memcg's wb_domain, rather than global_wb_domain. To address this issue and simplify the implementation, introduce a 'limit' field in struct dirty_throttle_control to store the hard_limit value computed in wb_position_ratio() by calling hard_dirty_limit(). This field will then be used in trace_balance_dirty_pages() to assign the value to __entry->limit. Fixes: dcc25ae76eb7 ("writeback: move global_dirty_limit into wb_domain") Signed-off-by: Tang Yizhou --- include/linux/writeback.h | 1 + include/trace/events/writeback.h | 5 ++--- mm/page-writeback.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 32095928365c..58bda3347914 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -326,6 +326,7 @@ struct dirty_throttle_control { unsigned long dirty; /* file_dirty + write + nfs */ unsigned long thresh; /* dirty threshold */ unsigned long bg_thresh; /* dirty background threshold */ + unsigned long limit; /* hard dirty limit */ unsigned long wb_dirty; /* per-wb counterparts */ unsigned long wb_thresh; diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h index 3046ca6b08ea..0ff388131fc9 100644 --- a/include/trace/events/writeback.h +++ b/include/trace/events/writeback.h @@ -663,9 +663,8 @@ TRACE_EVENT(balance_dirty_pages, 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->limit = dtc->limit; + __entry->setpoint = (dtc->limit + freerun) / 2; __entry->dirty = dtc->dirty; __entry->wb_setpoint = __entry->setpoint * dtc->wb_thresh / (dtc->thresh + 1); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index e980b2aec352..3147119a9a04 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1072,7 +1072,7 @@ static void wb_position_ratio(struct dirty_throttle_control *dtc) struct bdi_writeback *wb = dtc->wb; unsigned long write_bw = READ_ONCE(wb->avg_write_bandwidth); unsigned long freerun = dirty_freerun_ceiling(dtc->thresh, dtc->bg_thresh); - unsigned long limit = hard_dirty_limit(dtc_dom(dtc), dtc->thresh); + unsigned long limit = dtc->limit = hard_dirty_limit(dtc_dom(dtc), dtc->thresh); unsigned long wb_thresh = dtc->wb_thresh; unsigned long x_intercept; unsigned long setpoint; /* dirty pages' target balance point */