From nobody Mon Feb 9 00:56:21 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C1301FF1BC for ; Tue, 4 Mar 2025 11:03:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741086211; cv=none; b=nhhVQ05bAUjFimvXKaeBynYy7+RY2UZ39yYg/hdBI/Z8CifqqakfSzh522u5NeBNNjynsFiE0HqPgTMs5OY+0cFftCAj2AlqHY9qBDiU3kpzQlCeLe81sEKBlQIerUQ+OrukLdmYZtJ/rHGbVQR/zATprQUSV3QueQ1ZoZ9xUkw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741086211; c=relaxed/simple; bh=WMWcERJJfbqiD3z8oE5+hnpSPeiC/ts2lZLJl0kJDgw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j5vbD3b4w/7v9MMu+xKfM4x+8522O79sSMJ5xyNBFP5FYTa6Hhu00nKKsnq8zcYLKoybaPJArhLGsk6p9/JfVOWCuqtbggpVvd8SME1mgU512eiJog+xHSsOu9xbHByRgCUxqpeTSBk21rCJsGCzTckAOovws9TaCpJKCOKA+jI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com; spf=pass smtp.mailfrom=shopee.com; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b=NCYpASAD; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="NCYpASAD" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-22356471820so86723855ad.0 for ; Tue, 04 Mar 2025 03:03:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1741086209; x=1741691009; darn=vger.kernel.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=0YawdmYDPWdB9hnNHcTCzRAEqbfP7zzuyOxM1DZL9r8=; b=NCYpASADNuvRESIPIYSAyNqu/x2P/gpnp5pgmgeYpTdbzy4ZOANSsFd5jGuG++WrXI ocg67nmijefF4haDICHjBOlUNjiq9uVzHBPOXgAYS/cYtrRA2c+K5EcG50ZSOZPx2xFa 0qZ5gY514tjrfYNeVNKHYxAXnAjYdOY3Ar5jLWCIhEcsEehb+0LGYi6lNLtvHv4F9h7N W9QSQvNXTkmFRjv9jY8+rWAxk01qUQJ+gTaT1fSXPo2HBY290bhwb5VboFzidvAnuHKe 5hB4GV7svePRMG4iN6gMuKNagf+qwglnV8JCISrFWavzEto5DXfTUpOwZjH1fPAHK8SR Kpfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741086209; x=1741691009; 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=0YawdmYDPWdB9hnNHcTCzRAEqbfP7zzuyOxM1DZL9r8=; b=WULCkQGwurgjjU2FVtEsboColXz1G8oguEnO4MrWwKpVq5zTkUiu89acrqN00qLjKG hrKArlnG1WAK1LocKsvJpP29txafVDNRbnBs80gxecQLXB8uYW7H+U0cnoYa/QYv0yro dOZhDVc5HQ53GN9zAICq1Es0+qsOMS/4KSS4kUDrXJFllg5S5avV++TExHiXXD4lBc7J Gnmd0b3lnCBL5C52YtbhGZ94P1MUaTELqCQ07rX1y3PFzksAOLn8jESF/4mYuJ+9aoRl qNxKVzTdtCvJaR/m1/sgtD4tT4G8xu8rTLiiXAMacKDIPdKKO40I53fJR+ehELsZ9C/C 7ikA== X-Forwarded-Encrypted: i=1; AJvYcCVG1Im0CsKOQzhyh+vnbTVT06bfH8khJPji3+isCViv5MTiDkd2pQFYJ7Wln/69I7PxsBK4T3fqAkdPTus=@vger.kernel.org X-Gm-Message-State: AOJu0YyzYR4UHwaux8OlGWhlv12ZQMdBneQhGM3kPkMGRdY36hqhwn28 eRmXbj/D9xc8VfW365hrlAG/TnMHlLdR+36VnBgefvoe3K63ErVZNLdZIYMIQL4= X-Gm-Gg: ASbGnctVYLDrrI4XXNfJx96nUC2rLj+7lxm3bvPAZsoZ861GWFs9wIIiA8HMqiEpBX7 ttUMg6tMFJQSp8z9EyPaNFWnEMeqzzJPF1cmo8P2tyzxyILmhNe/uG5RZS3GXUtsLvpnq5qAtvO dLHSDp8Tifdvxv/r5uGFE1OMdYYc3asx3+LsprCCx/ToxwKAfhDkPmOOp9F11gzZNuMlU8dHRxF /x3Y3QPzoFIApfQLIvKKQu8txOTB8+jQ21j4nc1CIjoMparUfYaRlgFhCRTxzXloF8hrvfY8QE+ 54bF1vLiF0FyHmM9mH3ca7uLGRyh0g== X-Google-Smtp-Source: AGHT+IHcP3j8xP5tujxFcnjNnFi/BdlYDT5lDMwXz1AMbsqmlg8tbp0AtTG0gER04iSD5VopiJ2d7g== X-Received: by 2002:a17:902:d4cb:b0:21f:b6f:3f34 with SMTP id d9443c01a7336-22368f9d88fmr239812185ad.15.1741086209642; Tue, 04 Mar 2025 03:03:29 -0800 (PST) Received: from localhost.localdomain ([143.92.64.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-223501d2778sm92764415ad.36.2025.03.04.03.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 03:03:28 -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 v2 1/3] writeback: Let trace_balance_dirty_pages() take struct dtc as parameter Date: Tue, 4 Mar 2025 19:03:16 +0800 Message-Id: <20250304110318.159567-2-yizhou.tang@shopee.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250304110318.159567-1-yizhou.tang@shopee.com> References: <20250304110318.159567-1-yizhou.tang@shopee.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Tang Yizhou Currently, trace_balance_dirty_pages() already has 12 parameters. In the patch #3, 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. Signed-off-by: Tang Yizhou --- include/linux/writeback.h | 23 +++++++++++++++++++++ include/trace/events/writeback.h | 16 ++++++--------- mm/page-writeback.c | 35 ++------------------------------ 3 files changed, 31 insertions(+), 43 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 supe= r_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/writeb= ack.h index a261e86e61fa..3213b9023794 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, =20 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), =20 - TP_ARGS(wb, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty, + TP_ARGS(wb, dtc, dirty_ratelimit, task_ratelimit, dirtied, period, pause, start_time), =20 @@ -664,16 +660,16 @@ TRACE_EVENT(balance_dirty_pages, ), =20 TP_fast_assign( - unsigned long freerun =3D (thresh + bg_thresh) / 2; + unsigned long freerun =3D (dtc->thresh + dtc->bg_thresh) / 2; strscpy_pad(__entry->bdi, bdi_dev_name(wb->bdi), 32); =20 __entry->limit =3D global_wb_domain.dirty_limit; __entry->setpoint =3D (global_wb_domain.dirty_limit + freerun) / 2; - __entry->dirty =3D dirty; + __entry->dirty =3D dtc->dirty; __entry->bdi_setpoint =3D __entry->setpoint * - bdi_thresh / (thresh + 1); - __entry->bdi_dirty =3D bdi_dirty; + dtc->wb_thresh / (dtc->thresh + 1); + __entry->bdi_dirty =3D dtc->wb_dirty; __entry->dirty_ratelimit =3D KBps(dirty_ratelimit); __entry->task_ratelimit =3D KBps(task_ratelimit); __entry->dirtied =3D 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); =20 struct wb_domain global_wb_domain; =20 -/* 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, =20 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, --=20 2.25.1 From nobody Mon Feb 9 00:56:21 2026 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F51D1FF601 for ; Tue, 4 Mar 2025 11:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741086215; cv=none; b=gI1Etq3GncWQi3pr/DPeAEB9HL+bAxoag72Swbu4NJ0coCFLvvU5ntPdkB8Ttx7y6tXYc7uaWMOrtx5v18ct3GLbEd0t40Zd2MznEnsp6588tpzSy7JpLWVrcPZVP1Htle/01FF/wPTpqWvEFS6CK9hyQbwSkFqZzQXUpCvOGNY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741086215; c=relaxed/simple; bh=wFr310lePl+3sCKMgYEpa1cVuDPHCXJAKPYyZiwfkrE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iUikepKo5y5x3+e41fFRmU+cqw9TZLOBwCFVmmrxXVqsMqDpMP1fQz3bG7plEIIpMsMeLdVN7gMu5o/FMiHt2dWGa4M4lpIgID3OuNnTjsxcL0Q4PfV7Uf29BdTelAcMYH+LPIs+sTw33TyXufj5IxDJKtnckd2D8gKFLodQfkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com; spf=pass smtp.mailfrom=shopee.com; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b=W5Ft+z9H; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="W5Ft+z9H" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2235189adaeso88598995ad.0 for ; Tue, 04 Mar 2025 03:03:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1741086213; x=1741691013; darn=vger.kernel.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=3lES0apB7zPp5Y1gMLsCJ52oXjFeABBbwB1psLGF4yI=; b=W5Ft+z9HUGS6ScmyN3/pxQBoH1N4U4CJdER5cU6G7ZhjMdNEzwMBhZDi7k4Jlt73XX rXFFdDCEn+KoKcRodtnt/eMw5oC2hfJtgf1WP7cOGc6m5B4m0H7bL771mYSLNtpe964N 3i5CyYv3zuroTYOWQvX87ku9hkfEZxhJbR8z/8hBtwO27t5RAASQdTrsffXo6MDIR/R0 ZipgHZEeQ7Jka5xtAyOIg0UxstT01Mwf91hUpCUI/nDrCvT1BMdWNv3q6DhhcwcTnt37 XoOH8D++XRBRUObPwiXnzWDT7G5hwIcH7d2D7/onRdj15wn8XezuH1LCwNGN9N5Yebos 1ULw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741086213; x=1741691013; 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=3lES0apB7zPp5Y1gMLsCJ52oXjFeABBbwB1psLGF4yI=; b=HZpqFnMRcXLreS9tjpNMg7PSKUd/XsX/7BgZ6aY3zuDkOPnTjO0By150qGp0VUd5er ygJkJSH9iIRNNbqAzoR1KaV3gv7UxHxZf1qhHkC3LBZTDemP4lmA/Mv9QjS9uzlnklhu 0MvSusRQ/H3HR1eCf+Mjk5h6EeLOBnifnqQJWRSEnXc9AY4YeGjxDowvTPC9jXZI35N2 Q2wRBjKuvMPCUoTLTfEB7B81fzX6GWgIfeP70BMUnIv57jr0r6H0MI/lZgqlqZFON0RZ vFoCeX4vFiYfYrqHgp+ZQaktxM0e0nUHQ7g7MMqosAt1ColkvE6lukHpYdw4FHcTKFDX 1dPA== X-Forwarded-Encrypted: i=1; AJvYcCXSPXCkbTsW6wldW333z0FCy+tXDHbZCB21D29OXGoetGgiKcJkizuAaYbJDcTXPVBMWE+A+DtSeUBadZk=@vger.kernel.org X-Gm-Message-State: AOJu0YyX+g8GJfDwj6ffzuOdSYmM7oCW58x99F84xF7ZlVLcLax3jdNV jy/4aUL7i+DMEhV3/Cp/Nk9ytzGuKah3cNsrZpRbVJgQQfLjBLCSo38v4wXdHvs= X-Gm-Gg: ASbGncsjXdBwunD62L8F0fpaObLlC/C5zvud9qJLdkVkty7AyYxqAs4VWfTT1e6i6R1 yb94hDwZgHJvczDbEayRO8A3k9jI+ot6tjI8fWStMo7R8x5mFXqDe/sXQjwBS/c3TkyOW0tYD5j dqT4Zyl+jD6HJCTfLasRTCG0Au11U0MnIBRJ1rNUWLxtEUoB7o3e9DyV9+hRkbRJSv/oN7/ZcJi P2AnhG5ctt3HgIlm9MniB3i+c6XLlBZj38FtFuFEjDtCdcZiTJLDjoPhWnR5MfmNpKdp5oIifEC hQr5EYqqdToDak0Z8wpGvU2+dHUA/Q== X-Google-Smtp-Source: AGHT+IEx0Bo+gN1RIbUhA8tGm6rA4iMJsFaRlXeDO7JP3HXXARwvvotVyI8kAbe7AiglMeVqNhDPfA== X-Received: by 2002:a17:902:fc45:b0:221:2d4b:b4c6 with SMTP id d9443c01a7336-223d978eefdmr47027275ad.17.1741086213564; Tue, 04 Mar 2025 03:03:33 -0800 (PST) Received: from localhost.localdomain ([143.92.64.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-223501d2778sm92764415ad.36.2025.03.04.03.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 03:03:32 -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 v2 2/3] writeback: Rename variables in trace_balance_dirty_pages() Date: Tue, 4 Mar 2025 19:03:17 +0800 Message-Id: <20250304110318.159567-3-yizhou.tang@shopee.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250304110318.159567-1-yizhou.tang@shopee.com> References: <20250304110318.159567-1-yizhou.tang@shopee.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Tang Yizhou 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/trace/events/writeback.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/trace/events/writeback.h b/include/trace/events/writeb= ack.h index 3213b9023794..3046ca6b08ea 100644 --- a/include/trace/events/writeback.h +++ b/include/trace/events/writeback.h @@ -646,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) @@ -667,9 +667,9 @@ TRACE_EVENT(balance_dirty_pages, __entry->setpoint =3D (global_wb_domain.dirty_limit + freerun) / 2; __entry->dirty =3D dtc->dirty; - __entry->bdi_setpoint =3D __entry->setpoint * + __entry->wb_setpoint =3D __entry->setpoint * dtc->wb_thresh / (dtc->thresh + 1); - __entry->bdi_dirty =3D dtc->wb_dirty; + __entry->wb_dirty =3D dtc->wb_dirty; __entry->dirty_ratelimit =3D KBps(dirty_ratelimit); __entry->task_ratelimit =3D KBps(task_ratelimit); __entry->dirtied =3D dirtied; @@ -685,7 +685,7 @@ TRACE_EVENT(balance_dirty_pages, =20 TP_printk("bdi %s: " "limit=3D%lu setpoint=3D%lu dirty=3D%lu " - "bdi_setpoint=3D%lu bdi_dirty=3D%lu " + "wb_setpoint=3D%lu wb_dirty=3D%lu " "dirty_ratelimit=3D%lu task_ratelimit=3D%lu " "dirtied=3D%u dirtied_pause=3D%u " "paused=3D%lu pause=3D%ld period=3D%lu think=3D%ld cgroup_ino=3D%lu", @@ -693,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, --=20 2.25.1 From nobody Mon Feb 9 00:56:21 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0DBD1FECCC for ; Tue, 4 Mar 2025 11:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741086219; cv=none; b=jzbZKZDRpOTgYRFOqG2amAQL70WFOjGmtXUVHZSxOq2/nczqaXOszOrgBbRkWxRfSikEAZqgFDW472n8zP6SGXIgCtR+PYrYdwSFchlMEQgoH6TDDJNRD1iH62iBexDCjK8+mpGoZTKDD/P3u9xf9pYD9OP2DmLFhk3XqBX9kEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741086219; c=relaxed/simple; bh=wzIi4HZXwqVOWENoquV+UIkh/r0UJZTDI0sJVxfYL0w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AGt7DGgNt7fmmBWRlCmANYuWKV/sHnPx9vIXoy2ZPfRCi/jvNeet2D9+ejK+LsPompJVR7Db+Qx+Y/R6ZS8EY3I+TObqMysdaZvof9PJFghmYa0Qr//ZEVkoRzWL+dd2yEqKAA0vmlmfDX8eTdBZwBjzmHjN51A3S1pTozKJ6ZM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com; spf=pass smtp.mailfrom=shopee.com; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b=Mxndf6Tz; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="Mxndf6Tz" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-22356471820so86725645ad.0 for ; Tue, 04 Mar 2025 03:03:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1741086217; x=1741691017; darn=vger.kernel.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=qGd6xUUug40ndWv/7UEStbMr4MjIVHoaP0yPiRkB0+c=; b=Mxndf6TzleS+dRPLQMadyqWS9fol6eDBfKYTyFAP3FcRTlGK5Bdfnt2yRUWOI7NFv+ vm7I+i6koCEW9iBSc+/OkyzOKEYOVqX6pVPGJ9mg6eM/sucNWYZyYBgC+7ZOULQoaJEA tg2G/1/mbqP7jMdeh5gHuyVsN0e2IMU04CN9OxvBZOGTUNWs/B4JPSL8naJkAqLcW9HN WxqGW8FME4qh0WtGzYgeTNZSkoPPyQQ0XSMmG8XT07mMEiaslY0wG/q+jRP9nCkPUkPS TkSb7QjCEgApM3CxSio/GcNcPeHNOEgd5Wrf7bcemmfXoHUbD6/D8FvOJemXObW5b/XA iOLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741086217; x=1741691017; 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=qGd6xUUug40ndWv/7UEStbMr4MjIVHoaP0yPiRkB0+c=; b=VHHi/wF9/M5egfM1+tFjHBTwPr/9nr6EAX3rdziuYqPfKg5A3i3XSrR8W+zJ11oxRJ PKIHIJyiCPl+vBYP0L7FfZFrwdIsq03OjKlCZNRIaKaXi9hBwZ5xuO98V9ytsdg3oDJn bSMzwOwNKPy8Dc6EvVxgq11467UnH2sWGS77/LsO0WkBVWVPdnpeob1Q2EprtxVZ/CIN I5FdcAK0LBsFMa47vLtW4Xy9nTpM2vpfpNRGhhIhwGn1BnNAdd8tzUcuD+TScAWC6kLi wKXIJDMShsveCVtbcbUvgsuFH+D4O16RNCgO7RyXqvtF55qtuUBsS4MIprSzIV9MA7Ab RDxQ== X-Forwarded-Encrypted: i=1; AJvYcCXwPacQFcgERFdMwBcjDbeF0UMoU9mLoA/7VZMhaioMdfIknzAz32UvKswvtK2XNnbHOuupey+LuZ/1LeM=@vger.kernel.org X-Gm-Message-State: AOJu0YwuScY363g686HuJ7sVzWUCheHFDhpBJczWKezhfaezQQ2+NYy4 cZ2mwEUxRYpJKD7SuoiHW8Zwk/MwZ1IKczBOnbn6xkrgOB2DkyO7rwK29ARnYEs= X-Gm-Gg: ASbGnctF5+vktGpN0+h8j0APUp5jtGFGK7IrKFbiBZ26T3Yuovxv4uMQddPHicTlNww iXKuflWwdtsy5D8Jl22rZA99uuk3k7u68UEFQVBou7qBcJT6+Si3QcwtWBgWgxCd5V4PSJzE4Ul 1zQ208Nv1RSn+kWte505m3KtPkH6ih7wtiwFbm5RP7IzNFAQv9edRgvTaKTXXAl8xkCUnmY/NYV 16upuSWJp7xC/x6Ucqf6MULIOT0DiK7EHh9evbLhp1aRYHKQgVW6CyQOtGxrxfnPEVfNDNdivXs dlmfHPQlIYIU9GkhGBdDvUorVnzKwA== X-Google-Smtp-Source: AGHT+IHC27naAV4G4mjua+6oLFQl9im5/HZZ3hI9l/b48C3Mb32O1UgWu/XF/2xkyJ8188GOgWiflw== X-Received: by 2002:a17:902:f990:b0:220:c911:3f60 with SMTP id d9443c01a7336-2236926a639mr179441625ad.47.1741086217307; Tue, 04 Mar 2025 03:03:37 -0800 (PST) Received: from localhost.localdomain ([143.92.64.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-223501d2778sm92764415ad.36.2025.03.04.03.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 03:03:36 -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 v2 3/3] writeback: Fix calculations in trace_balance_dirty_pages() for cgwb Date: Tue, 4 Mar 2025 19:03:18 +0800 Message-Id: <20250304110318.159567-4-yizhou.tang@shopee.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250304110318.159567-1-yizhou.tang@shopee.com> References: <20250304110318.159567-1-yizhou.tang@shopee.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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") Acked-by: Tejun Heo 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 */ =20 unsigned long wb_dirty; /* per-wb counterparts */ unsigned long wb_thresh; diff --git a/include/trace/events/writeback.h b/include/trace/events/writeb= ack.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 =3D (dtc->thresh + dtc->bg_thresh) / 2; strscpy_pad(__entry->bdi, bdi_dev_name(wb->bdi), 32); =20 - __entry->limit =3D global_wb_domain.dirty_limit; - __entry->setpoint =3D (global_wb_domain.dirty_limit + - freerun) / 2; + __entry->limit =3D dtc->limit; + __entry->setpoint =3D (dtc->limit + freerun) / 2; __entry->dirty =3D dtc->dirty; __entry->wb_setpoint =3D __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_c= ontrol *dtc) struct bdi_writeback *wb =3D dtc->wb; unsigned long write_bw =3D READ_ONCE(wb->avg_write_bandwidth); unsigned long freerun =3D dirty_freerun_ceiling(dtc->thresh, dtc->bg_thre= sh); - unsigned long limit =3D hard_dirty_limit(dtc_dom(dtc), dtc->thresh); + unsigned long limit =3D dtc->limit =3D hard_dirty_limit(dtc_dom(dtc), dtc= ->thresh); unsigned long wb_thresh =3D dtc->wb_thresh; unsigned long x_intercept; unsigned long setpoint; /* dirty pages' target balance point */ --=20 2.25.1