From nobody Sun Feb 8 18:19:15 2026 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 52D5F1F237D for ; Mon, 3 Mar 2025 10:06:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740996389; cv=none; b=GDx2nm1Ejgpxi2MZ40ZbX9CKRaU7klKb3C2XbP0z55c+BDU4hnAXThVg24j+9QTrlal4yxUjlyF+hFE2RkOcz0knMeBDFXCV45GUlRKqyamhCMnZXSbAlqoofuq8kvrhZOnRrJf4iOLHBa+cnOZvi8Ap8lTpgtB9yo5QRCWrOhQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740996389; c=relaxed/simple; bh=RTxBZ+NUAaUwIZLg/UYjKt+XNtfXUf6QorszPjtSIJg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OuOXDG/Bou3QZdcf7cQwnBnI9m75AdO2NOdT3czlHG2GRPZOx2hbTHWn10gRG5HMbl8kB4GNpVPAUmXM/iATwRVJJt1EPGi155jFlRDOYaLoOdUNgoiUXG6PrbKhxp1ghKhS/YEmricPJhY9oeiECM5wyGdMxonWPyqgJv4Lusw= 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=WPkqK6DZ; arc=none smtp.client-ip=209.85.216.47 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="WPkqK6DZ" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2feae68f835so5706702a91.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=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=a/PqsQZYzh2gZL6Eu3byS2da5OGA46n+6o2RqtuMFMA=; b=WPkqK6DZbErw6K/HmytQaXlB4i0YDt2UoBlWXYHB8Y8a1itw0N5mGjvT3DDjBBlNJv KvdMdeR5VkTYiWjLnw4YLRYSA/jFS8/bnv/wwviGantQR1xJvxVzMgj+2kXLk7iOabCo mednLj5051+S4B57985B7az71fCdL9MsgiUs37fdqCHzuc0aSI8iwxQARvTKo10LxM8E A9asTgXr0oNTNIeqk+CxdDEEh9xTENBhN4NZwXo7d/rvG5XMNQJ3UvIxgcjHcHimbgTy Udmdy9PDSQvVpBtXFni/ti8dNnIVtx6fzaS3KRueiVcuR13nU1DWTkFTn3KDyenlVMC/ 8+bA== 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=iPcK8A04r2PxC++xVtz6OH/8gahgsbNYhowJHbel0XHlKXYszug1lYXTB6oDSIWoZy unx+VIMNwv9Cce2nl0R8LZSmbSbJDb3wMPKOp8+ozkKD3UpvLKavqdAhXPNPlIFF8VVJ RPxmTJxto6Bh7x/d4xa70ldaiqXCIVP+oS5S1P0KPzozhzmCeRbyM50PD7iblawL9LIP as1PaWEZIFhZc9LE4g34Up1BU4EDBtlk5UZzl5JcTGfgRBp5Jn8NNexX+C4JAwrq39wM g3tYcktQzPfaagGdBFpjypKW2iPakTUx12VxHImjX16Ck2esiRgu/LrfcJaG0DbZUyw+ yzDQ== X-Forwarded-Encrypted: i=1; AJvYcCWcr4WvBH999GVZzyty+ljOcJgmz6cXcQWCDBD76YPgutKN4GoGdsF4+r09SazxL0h/YL1Lx+wPlcM3s04=@vger.kernel.org X-Gm-Message-State: AOJu0YysKyJwnqpFc8zeZsNSfaQDB1KuGL4iM4u1SpGgZ9qrSSUfehhL cSNi6wSU+8DXXZG97cCkvOmmNm7QbRi881LcCXWziAW4YdNOoD5ZkMPKveFIb/I= X-Gm-Gg: ASbGncv1QAuqsQlx/Z3nX9xqFSH2fKTWai0icXPBCXSFAkji1aRTL9SE+Ja+rqMOKEr dJI9BMs+6qQCx+qxEMU9v56JXNMhf5ct7HQSN1WRxHGgEvps4fdT/FT1rrGJ5PjgR14Gam9X5zt KFforjQNmVzhenykpMMPAwzOi/vLWnTcHMzmjlmoqz0965EY3K/8ky4SPHRRuHjI7wGc1sg3RMa qY8p7YDYi1LL06JyitL4mcbR68tvkcFI95z3yEkubY+OUAByPKWtcJH0ymHtUXKfs7rzCsNh4Qb ttcNfl0+1Hs2Qh58q5A2MQuIoz+1LA== 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> 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 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 Reviewed-by: Jan Kara --- 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 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..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, =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 @@ -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, ), =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->bdi_setpoint =3D __entry->setpoint * - bdi_thresh / (thresh + 1); - __entry->bdi_dirty =3D bdi_dirty; + __entry->dirty =3D dtc->dirty; + __entry->wb_setpoint =3D __entry->setpoint * + dtc->wb_thresh / (dtc->thresh + 1); + __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; @@ -689,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", @@ -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); =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 Sun Feb 8 18:19:15 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 D6F3D1F2C58 for ; Mon, 3 Mar 2025 10:06:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740996393; cv=none; b=kYxeM25OLSOdVAqyRA7dLwkSRwQpKOutvnEFYSdtIkpsmwLhvItR2qWhjZhQfskB80vzmN0VRwkTPTvXnRWViAOGa5eR6V3A0KV2M8RzxQ0JC1jnBsn4POzJonXEtlo5H9e6V370nW3rqAAO6UbdVrS8o+iwgffRyp3xcW+kheU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740996393; c=relaxed/simple; bh=q4V8PCiwKojPy1QYgapBfO9lTDA+LB5m3KPLTH/ST84=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dseJopjkw+5Axc6yZAcYbr+MUChTUIRXaxEc/Sltx3+ux2eHPNpx+jamyuuPu+4pyqKL9ASFn0D2gXE5BdiBhV124S7ojVR3R4hKj95BgHvIEVaSVhOL20S9O/0lfcN9BF9Bgz4d+merOFHTgnhqMol5O2Lx/MiJwdvSnuAEEQc= 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=Fs+7Qod3; arc=none smtp.client-ip=209.85.214.169 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="Fs+7Qod3" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2235189adaeso64204095ad.0 for ; Mon, 03 Mar 2025 02:06:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1740996391; x=1741601191; 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=TlOgUF0I+Rkuiq5isF50AFm1bBn1sNSF5ax0jaYNIBw=; b=Fs+7Qod3K10fvD4Su8HbWX/q4o85LCBPoozoYzvvUAcDRlQl96GY+8btzFXi/rEZ52 bXLnNFbVUY960ppNVBcLbURzjWh+w+uy49nkbwVdNDdBdyepRkFOHdPMY7pQIdULSmZ9 gTshS3wtf6dYNs9aKECZOV1JNyNSh1r6zS+AzY8AIUFaA+RezauogotUWq23PNaeeSIB dCeezkzk3qJGiTe+yRtaJtcKGfm5B5AKobl9ak29polJQQhWYAC1m2/xbiUJ6DSSTHhE 3cbwawafLwWhDfdoHgeoEQBnlsFpgn5yb7BNnE+TIH7VQdMoflefL+ZOxpzzcRb0A5vN suqQ== 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=TlOgUF0I+Rkuiq5isF50AFm1bBn1sNSF5ax0jaYNIBw=; b=eXmW5JgHLk/rf4l5VrXKSWXqX8hZMyGpUJMHOz0f5BUf74VIk1QEJytlTNdsz7GmDs JRO54E6enZDPw/+lJaFUZYMeFZ4GUOA+clFUTuCmh1OrJnBLT2JHkQMFe+qfz+p9WYSb 0hsNoWZaPuQHuqvBWkLD1zcQJK0hY6PFHhvjFLQiEXxsJY5+qhcJbvUIJ/CQIHw253u0 BOq3Eivruk1kfyg8207rjhFS3yUFKcHrNZlPVxcgcduwfOC6Uy6ixWfDmU2odlEd6M3b ipQnRUAyvsLiblAxNW/RuNPtr6awx2QRiItexflPlO2AZpfKqWplCYofl+xqRDCGUcJd u5iQ== X-Forwarded-Encrypted: i=1; AJvYcCXOG2U5MpDaCres1iyz7B3rpFDbPsvp9VnD/9UMycixA5jQL+wUkHFucs6rUfrEnzdXpf1uVXaZr/LdnKA=@vger.kernel.org X-Gm-Message-State: AOJu0YzekfH3txBjpT77unhFWxquge+jKLcL0k8VZ8VJTIpoAWGGwcZk jCDUDLM1ZsBYplFiEw9uNkyzQVzFjUUe13pWrplzGIW8Zsc7IIN1mxRc+aatGJg= X-Gm-Gg: ASbGncumUk1eJsYEEiUT+zn1p6pGZzyT+xms4YdT7p0N7HCN5hUODIOc5AsdxKRuMY1 gGTfw8AXCcIZadjVYgK2DzI6wcclyhPuWYihEZ5KkmE1nLtRIXA/Qt+2OYOufHIvGhMUqEwzEdW hKTdPjmdNvnsD91XJXIsCdcLeCuHWUjYi7z6C7rHIt8IxAWT4dleBsbyzIDp5XcIsUU+IuKojJk XMSe1WhnEdy/isG2o3fEUjbXDUgtT+edj8yMll1FATMw/29hX02q0WZq7F6YLbui3BYo13ce0uP 8R1uru1EKCyczkIBvath2h5J92jujw== X-Google-Smtp-Source: AGHT+IHIVt3VPmyTSVrkUCPhcW9I+/9BdLXMLDmjaYIvdMR9bAGzwWvrVsZS6NIolMs+7Bf7bchTHQ== 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> 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") 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