From patchwork Tue Mar 4 11:03: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: 14000466 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 EA40CC282D0 for ; Tue, 4 Mar 2025 11:03:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FEF6280002; Tue, 4 Mar 2025 06:03:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AFC6280001; Tue, 4 Mar 2025 06:03:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50256280002; Tue, 4 Mar 2025 06:03:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2C05E280001 for ; Tue, 4 Mar 2025 06:03:33 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CA38B1A1B83 for ; Tue, 4 Mar 2025 11:03:32 +0000 (UTC) X-FDA: 83183582664.12.EF5D2A3 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf08.hostedemail.com (Postfix) with ESMTP id C01A5160014 for ; Tue, 4 Mar 2025 11:03:30 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b="N+J/aQ2h"; spf=pass (imf08.hostedemail.com: domain of yizhou.tang@shopee.com designates 209.85.214.175 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=1741086210; 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=0YawdmYDPWdB9hnNHcTCzRAEqbfP7zzuyOxM1DZL9r8=; b=QiFMXEdjx0bpuPaiXhZOzvJ+dfxHUYE7q7Pn8D73nhNd5kzMRyxR4orgBZUYjzqm9bnVoe isfLaBJOGBLhwudC0LA+pw3WoW+lnKeNUGCryxOV8Kvoj61DlXcs/cl/iWEgrF8svGV3yP loIW7X+aU4Hxp1HZuoIHiVSFiLfC8WQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b="N+J/aQ2h"; spf=pass (imf08.hostedemail.com: domain of yizhou.tang@shopee.com designates 209.85.214.175 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=1741086210; a=rsa-sha256; cv=none; b=1SJTxHjgEsBj6C3riOC3aYr/JeE9rXXF9TgKkgNFEKh/0HbfmYIp5VY29G/jEzlGMQRnk9 SLDTcoylg50zquQruI4Z/NH/qvP8KwzMtwFN/c+IWA4h4Zr96Rc9A28dDUmABBP0c9ufRE V0i2RQiN2hMJN2516+ivoU27JrvBnHU= Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-22382657540so53952235ad.2 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=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=0YawdmYDPWdB9hnNHcTCzRAEqbfP7zzuyOxM1DZL9r8=; b=N+J/aQ2hdvlkPB5eaJxE3p+VsYVxdO5XsGQUJla4Itpo9YrnqkkHT93nS+0JkypbH/ /g4M2/nVR6VfNlFAYQJho+PKJGutLXPuR7jd5aWXGCNRN6EeyKIs45k/Wg01B65k8I2P J8XauBo/fwwjWasbxF1NminIIUXgLkUvzBJcIv9Zv5ACwImFzzxfHac2gwtnjKJJ5qzx KQbeQ2pBE2QLbWSj0XGl06hmt4j3wK9KXb+PqwbPTD5GwIrre6yItHSrQBtKK1vQo3g5 JBKK1TzfCQh3OO4qhx5YAZmlGwluhF/cRG6632NqWh9cwC+U3O7Dt16uxmMNxm0bgCYL B0hg== 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=n8+ntMR8T4Qvn/EfrES2THM0BtOALL6ZT2J4Po8LtE+kLzE1RDPJbSo/qOGWaGz254 1CJ/cLZFufhhOGWdIVe4eYcRZqgO/uKQsOMQWqtCezwsvEt5VTfjxzbw1p5dhDTOzFiC hU+VFduBPwnfrfBZTpgX4TCesMZ/riTs3IFqSDkTvfyl5WzIaCst2RmuCkThrtUotR+x TAYC5o9lFEQNFgQ5eL+lLm+Sl9aw7+/R0YhttuCHjrk3wzNROPfQ2nujNBqvV8DD24Ws grlI1IecEshlqJq7B87SZfc7vx4EMix8KgdeXaN8AOrB1AYQkijWU2gkxFNhFczu/rbe vM/A== X-Forwarded-Encrypted: i=1; AJvYcCXyahF5BNqhU+JZ3qJ7astvrnhQiLPRwMjM3TCMRPnxbpdN8OdAZTc0YtMg0iN3nb/XGn7A+RgiTg==@kvack.org X-Gm-Message-State: AOJu0YzzUvrDRsM8zHhN689rLkWoUN0kS6UnYg93rz9yhBGe2BKZhIh9 xR6bYsTi8zNmMlD0+uGVEps9ob+dbW2nGBxLkp9r996O26TofezHLLRvCIeQGkMLYdoRDdI6X4w h X-Gm-Gg: ASbGncs9Aqjx5eMLHaj37vFONqFM1VrE2v0+iDvAb+3ikK8WATNG3YLLj8mBK2nwJ8g OFTYoo5rula86LkKXyEWLyMnwUzv0mpICIvXzRlP6Qia0vum39UzsEUlHVqgDqWKWeS49tSdLmt u3pcdv00X66d5ihuArHZAAo/8Bz4SghkjnDycrQFCbmutB8Di8fCS5zDCqoo5TxV8IY6Q9FPjqI FmwiGrjpxURDiZnSiaVf53bJzHB7eQHK+uCZ9vYtmzghgWZZzi4N2DwlKb3EFdc4mEc/aIyAdFH Kl1SPIsDDJgW+ypMwg98tzJ1Z9pErg== 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> MIME-Version: 1.0 X-Stat-Signature: 9zermnwm5tzsggdc3xfiij7ofdobqcs3 X-Rspamd-Queue-Id: C01A5160014 X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1741086210-373336 X-HE-Meta: U2FsdGVkX184rEoJA4Dqur2MycESthPpj/gbB6ddJHCSEYETRl5Mtk5TZ7JGlnhZ80ZAKqrbwsKqx064Zp7CQUrH4XlvWCZGhc+Qftd9o0UHQzyHDs6TSglPfPODjayaUdgfyDxKEs/zxcgqzKPHxiIt2vbkt+gCMO95UUaa4g1k691U1Eqb4O9QYxr5x+IED3CteGTzNmY5TF5eu6O4r3uW7cFJy9muGxNx4KiPkTP7W/W+GFiJJ8OPgTRcWcEp+gw6nymhIPTIMb49Jf7T/2Z+vOvLel+AQ98ckth9W7bKiLZ4pv8n7371OtFmwtXLLGKlDw4qQ1F7HC9dw8xgBQat6QmOeACTuU9zr1/v4lkbBvCb3vOylJxIE8xDFUfH6JnfVMFrUA/JBth/LyRrMUh3mevOw6LtxiggO/LaHpUwl0OKzDTgaJdX3ZRqY2+PKHuv/L9sY0CU/CB2/NIQpRdc6XPyzJOwG1ZCsaoaFh15y+Qd8iemhxQh7V+RA+1YwXSe6mR3DpBwzoS7tqBTrczzZlFTsmMPjDJ3yjMksiVT6FEQv7jiWaCSHo3AVFWn1na4Grq+0NIKG4d7JmVHxvmLYHQJ7Do8G4RZLhdczyxA1rFTTKIkdB7xa0ZODjmgvOf8RS5wBP1B89SvRxNLr0QprDr9BDjI7DS5aUUNJIMGT7B+kZuitprjysHuo0Og+X1L+Icu8Z1DsIJRDxSIhaL3oXQqh3DvxLuSW6qGi5D7VPHSeVEJLty1wI4Sj5R6FthJ25hbHJMYWRU1hYu0l+GGNkedYqrQADrlZmiqWr2Cn25GTX0pl2TCl6/YQtejkAF2ItM5v0m8z/EWKiaXy+0QOskNxUBxjcNK0oEfJRbQGGZr0Lpu2J7grKvvdBY8cU7cdS/5GtmAP/gY007Kfrmvpreg/DmcNyBW8FQzdbGXqTiWcq29vV+v77gLZivi9Y6QuBwNv1397J7rhnW /6IES8av s9fu2pGzkLxWCIej82SnhrQ6YCkdZsylRfyKBhw3KVXx3JCvyELxAY5fOUjmvMuXYy+unb4O3L1XotZKUI7zxhmv/DMEityZ6WQtUO4/qbqJLfLX2W8WVCgK4xnfx2J3QnAwaoNqvcgVK8OK8QwpNQ2HdbkG8eGUBgz5RsisFoYLH0G/Bn/cu1X62Dx1fEePSZJvK7eIqCyZO1BVoFoNGNYJk/NAv6j6ghW8wXHr9NatJnFumSt7oDL6O0+dZWZMC5Rfb2xiyOPi4kdLuLNodLAuxv7JtClZAEeqjZ+kpfRkutH4D8C/0TyimhJ5qsAAAw1680pIyAn7gUYtolnKMQwuMJlU0J3lODy2Z0PYSY/dx6qW8+3CS+3BWNn5AvCKzctC+ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, 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 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 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..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, 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), @@ -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->dirty = dtc->dirty; __entry->bdi_setpoint = __entry->setpoint * - bdi_thresh / (thresh + 1); - __entry->bdi_dirty = bdi_dirty; + dtc->wb_thresh / (dtc->thresh + 1); + __entry->bdi_dirty = dtc->wb_dirty; __entry->dirty_ratelimit = KBps(dirty_ratelimit); __entry->task_ratelimit = KBps(task_ratelimit); __entry->dirtied = 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,