From mboxrd@z Thu Jan 1 00:00:00 1970 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 B3E9CC4345F for ; Fri, 3 May 2024 09:11:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E1DE6B008A; Fri, 3 May 2024 05:11:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 492436B008C; Fri, 3 May 2024 05:11:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 333876B0092; Fri, 3 May 2024 05:11:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 100006B008A for ; Fri, 3 May 2024 05:11:19 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BAE191C0E04 for ; Fri, 3 May 2024 09:11:18 +0000 (UTC) X-FDA: 82076515836.24.8B33DA0 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf28.hostedemail.com (Postfix) with ESMTP id 88CDEC0005 for ; Fri, 3 May 2024 09:11:15 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=wvXngvbD; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=rgiV5Cqk; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=wvXngvbD; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=rgiV5Cqk; dmarc=none; spf=pass (imf28.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714727475; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Qhjug2pP1FcqHpUp6SZr2JmbXQhkwBjXb46lfZXSx9g=; b=gnGJG6Zug74XprUCB8PNb04dCn7IxowkrgrOiNytjO1BI1AsA0NqkeqzD46Xg/3U/3gh0B 6trxI/lQXS1HfOEyhsRMBskTgeLl2PJGzabGC8lz5hTML5uJxJUuf8+cRkGkIDj2PfrmSI 4V7EV0ja0jZtxqIWATARVE+9jCyiMK4= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=wvXngvbD; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=rgiV5Cqk; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=wvXngvbD; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=rgiV5Cqk; dmarc=none; spf=pass (imf28.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714727475; a=rsa-sha256; cv=none; b=No13RX0LJDNEWgg3GVCuDx8M02jgGlKkRA4mylS6NInWPsgeZW07ZwPPJXITxSFghOYQlL mLm92slND5GyDn2LpAJgtGAD/TaRiEzw7g4FDtgohgXCC8PSTdMMun8l4hoH2VE/SgcRab qPNbp4pw1UCEtUGqRRquXQEVyinlZY0= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B44B0229F4; Fri, 3 May 2024 09:11:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1714727473; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Qhjug2pP1FcqHpUp6SZr2JmbXQhkwBjXb46lfZXSx9g=; b=wvXngvbDAxeg6dfnV6zvydbKtfSWaXXc/maNCIS9JXTYVKem2iiqN1N8OJ+PvviZy8er6Q JTsOm0arHvmGXjGOgHA90wSaUD7qNIxDhVsZoINz+Omx5KDtfrGeNc7RzDEYtQB5puFNNj An3aYD0l4Yu0QWg87JAjWo+TSYemIjI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1714727473; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Qhjug2pP1FcqHpUp6SZr2JmbXQhkwBjXb46lfZXSx9g=; b=rgiV5CqkirCzDfm0dX/nr4SMMGpLYjwGcLCKE+Hnah+2/oMPSD8tAdwoCtzDXq480m6QDh CrC0r2L6KJQ4MaBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1714727473; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Qhjug2pP1FcqHpUp6SZr2JmbXQhkwBjXb46lfZXSx9g=; b=wvXngvbDAxeg6dfnV6zvydbKtfSWaXXc/maNCIS9JXTYVKem2iiqN1N8OJ+PvviZy8er6Q JTsOm0arHvmGXjGOgHA90wSaUD7qNIxDhVsZoINz+Omx5KDtfrGeNc7RzDEYtQB5puFNNj An3aYD0l4Yu0QWg87JAjWo+TSYemIjI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1714727473; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Qhjug2pP1FcqHpUp6SZr2JmbXQhkwBjXb46lfZXSx9g=; b=rgiV5CqkirCzDfm0dX/nr4SMMGpLYjwGcLCKE+Hnah+2/oMPSD8tAdwoCtzDXq480m6QDh CrC0r2L6KJQ4MaBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A541D139CB; Fri, 3 May 2024 09:11:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id RIdUKDGqNGb4KwAAD6G6ig (envelope-from ); Fri, 03 May 2024 09:11:13 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 4C62DA0A12; Fri, 3 May 2024 11:11:13 +0200 (CEST) Date: Fri, 3 May 2024 11:11:13 +0200 From: Jan Kara To: Kemeng Shi Cc: willy@infradead.org, akpm@linux-foundation.org, tj@kernel.org, jack@suse.cz, hcochran@kernelspring.com, axboe@kernel.dk, mszeredi@redhat.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/4] mm: enable __wb_calc_thresh to calculate dirty background threshold Message-ID: <20240503091113.bkrw3ihx7gggtlxo@quack3> References: <20240425131724.36778-1-shikemeng@huaweicloud.com> <20240425131724.36778-2-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240425131724.36778-2-shikemeng@huaweicloud.com> X-Rspamd-Server: rspam01 X-Stat-Signature: ga6sgygt4d1w818bkz6wqg4pjzfi9kmq X-Rspam-User: X-Rspamd-Queue-Id: 88CDEC0005 X-HE-Tag: 1714727475-454602 X-HE-Meta: U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08l2wGr7nshmi2BMWyKpX4MaIj1uYqcbWhDNMDF/CAbfscG4jC1/jySzsAsqfDk6s4hTvrHgKQyiX3XyCjmzrJx4uVxhcPSq6cbM4PJ2/Hl5aN+KAogZy0NlZaXRzSUU9fi8BKz0nDiA0KR33YEyNp1t+btEbdKmC3qCpRqeza7uC7U6r2uvuIzGiz6+e/pB2U81R6eTvCh+rWQOX1u0lc6h79/bViYjJy3Xwkwg8Mr7lwwe7UsZGngSNdQDMFh+hK4vxE//SiClMzY0FiWN7jCREPo5f7gU7dPeU 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: On Thu 25-04-24 21:17:21, Kemeng Shi wrote: > Originally, __wb_calc_thresh always calculate wb's share of dirty > throttling threshold. By getting thresh of wb_domain from caller, > __wb_calc_thresh could be used for both dirty throttling and dirty > background threshold. > > This is a preparation to correct threshold calculation of wb in cgroup. > > Signed-off-by: Kemeng Shi Looks good. Feel free to add: Reviewed-by: Jan Kara Honza > --- > mm/page-writeback.c | 33 ++++++++++++++++++--------------- > 1 file changed, 18 insertions(+), 15 deletions(-) > > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > index db5769cb12fd..2a3b68aae336 100644 > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c > @@ -838,13 +838,15 @@ static void mdtc_calc_avail(struct dirty_throttle_control *mdtc, > } > > /** > - * __wb_calc_thresh - @wb's share of dirty throttling threshold > + * __wb_calc_thresh - @wb's share of dirty threshold > * @dtc: dirty_throttle_context of interest > + * @thresh: dirty throttling or dirty background threshold of wb_domain in @dtc > * > - * Note that balance_dirty_pages() will only seriously take it as a hard limit > - * when sleeping max_pause per page is not enough to keep the dirty pages under > - * control. For example, when the device is completely stalled due to some error > - * conditions, or when there are 1000 dd tasks writing to a slow 10MB/s USB key. > + * Note that balance_dirty_pages() will only seriously take dirty throttling > + * threshold as a hard limit when sleeping max_pause per page is not enough > + * to keep the dirty pages under control. For example, when the device is > + * completely stalled due to some error conditions, or when there are 1000 > + * dd tasks writing to a slow 10MB/s USB key. > * In the other normal situations, it acts more gently by throttling the tasks > * more (rather than completely block them) when the wb dirty pages go high. > * > @@ -855,19 +857,20 @@ static void mdtc_calc_avail(struct dirty_throttle_control *mdtc, > * The wb's share of dirty limit will be adapting to its throughput and > * bounded by the bdi->min_ratio and/or bdi->max_ratio parameters, if set. > * > - * Return: @wb's dirty limit in pages. The term "dirty" in the context of > - * dirty balancing includes all PG_dirty and PG_writeback pages. > + * Return: @wb's dirty limit in pages. For dirty throttling limit, the term > + * "dirty" in the context of dirty balancing includes all PG_dirty and > + * PG_writeback pages. > */ > -static unsigned long __wb_calc_thresh(struct dirty_throttle_control *dtc) > +static unsigned long __wb_calc_thresh(struct dirty_throttle_control *dtc, > + unsigned long thresh) > { > struct wb_domain *dom = dtc_dom(dtc); > - unsigned long thresh = dtc->thresh; > u64 wb_thresh; > unsigned long numerator, denominator; > unsigned long wb_min_ratio, wb_max_ratio; > > /* > - * Calculate this BDI's share of the thresh ratio. > + * Calculate this wb's share of the thresh ratio. > */ > fprop_fraction_percpu(&dom->completions, dtc->wb_completions, > &numerator, &denominator); > @@ -887,9 +890,9 @@ static unsigned long __wb_calc_thresh(struct dirty_throttle_control *dtc) > > unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh) > { > - struct dirty_throttle_control gdtc = { GDTC_INIT(wb), > - .thresh = thresh }; > - return __wb_calc_thresh(&gdtc); > + struct dirty_throttle_control gdtc = { GDTC_INIT(wb) }; > + > + return __wb_calc_thresh(&gdtc, thresh); > } > > unsigned long cgwb_calc_thresh(struct bdi_writeback *wb) > @@ -908,7 +911,7 @@ unsigned long cgwb_calc_thresh(struct bdi_writeback *wb) > mdtc_calc_avail(&mdtc, filepages, headroom); > domain_dirty_limits(&mdtc); > > - return __wb_calc_thresh(&mdtc); > + return __wb_calc_thresh(&mdtc, mdtc.thresh); > } > > /* > @@ -1655,7 +1658,7 @@ static inline void wb_dirty_limits(struct dirty_throttle_control *dtc) > * wb_position_ratio() will let the dirtier task progress > * at some rate <= (write_bw / 2) for bringing down wb_dirty. > */ > - dtc->wb_thresh = __wb_calc_thresh(dtc); > + dtc->wb_thresh = __wb_calc_thresh(dtc, dtc->thresh); > dtc->wb_bg_thresh = dtc->thresh ? > div64_u64(dtc->wb_thresh * dtc->bg_thresh, dtc->thresh) : 0; > > -- > 2.30.0 > -- Jan Kara SUSE Labs, CR