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 96FB4C7619A for ; Tue, 11 Apr 2023 11:21:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 06872900003; Tue, 11 Apr 2023 07:21:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 01916900002; Tue, 11 Apr 2023 07:21:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E706F900003; Tue, 11 Apr 2023 07:21:40 -0400 (EDT) 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 D8E33900002 for ; Tue, 11 Apr 2023 07:21:40 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AA57CAC029 for ; Tue, 11 Apr 2023 11:21:40 +0000 (UTC) X-FDA: 80668869960.27.D9D3CF5 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf11.hostedemail.com (Postfix) with ESMTP id A8BA14001A for ; Tue, 11 Apr 2023 11:21:38 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=UUelcH4m; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=rVQTft2t; dmarc=none; spf=pass (imf11.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 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=1681212098; 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=82lOFgdBVYINhhrKJi05kihOdbuv6p0omPOKS3yzBIw=; b=ZftwzEhKfJT0oHevukSJGlU44/SbigUIq3qThnmvuB2Ebv/hwQgSwcePfbCpeJ0RTKgSBp +Oe1dsB+vric/b17AApqe7D+5WpHrhZQaplHKN/lwUTPOOobm6ZMTFYKW1Nn/PR9lMIK+E tMB8wDZ++M8R7BmYTg9MQsyNtnvp7Lc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=UUelcH4m; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=rVQTft2t; dmarc=none; spf=pass (imf11.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681212098; a=rsa-sha256; cv=none; b=V8K8hc5roHnmjX6GS5Q/efk05DLuxSQ903z8ZC9NbFGqyeQY3sIDkWP3wCcNSY3t2LEgzW N58t0mitfAhlLCFL/KWpt3WUEfNxlWXtFRqlM0eX9tKFuvkxxsSNLPTFqG8zXOHMgErSYD B04gpBoHeLzbC1A9Tl3l2WynkzEBO5Y= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EA5FD21A47; Tue, 11 Apr 2023 11:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1681212096; 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=82lOFgdBVYINhhrKJi05kihOdbuv6p0omPOKS3yzBIw=; b=UUelcH4mP4U/ZJVUoloWTrseIbp1Z5pbGWuM3LnSx/cfSNJzkOemWzf5P/qlFw5xyt95vf +1PQB4azG4NjQwEj5ZY/+bTdQXnXiO8YJ/kSiOchHkwF6yiDAga+kS8EtvJL1cGGMilx3Y wn0Gv/eTdED39qRKECss2Sv7M5eHyLA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1681212096; 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=82lOFgdBVYINhhrKJi05kihOdbuv6p0omPOKS3yzBIw=; b=rVQTft2tfptnekBUEA06kH3puYeYDPg9clM6TLBZ2LPxSxUxWEwMRgIK/PnNTWkoX6DmBQ xPU6PHZ0GQhUIaDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7568A13519; Tue, 11 Apr 2023 11:21:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id E82KHMBCNWSFaQAAMHmgww (envelope-from ); Tue, 11 Apr 2023 11:21:36 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 2AF3BA0732; Tue, 11 Apr 2023 13:21:30 +0200 (CEST) Date: Tue, 11 Apr 2023 13:21:30 +0200 From: Jan Kara To: yizhou.tang@shopee.com Cc: neilb@suse.com, tj@kernel.org, wufengguang@huawei.com, jack@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org, tangyeechou@gmail.com, chunguang.xu@shopee.com, yue.zhao@shopee.com Subject: Re: [PATCH v2] mm: Fix memcg writeback for rt tasks Message-ID: <20230411112130.7zswqnyifgjhshif@quack3> References: <20230411082248.1020719-1-yizhou.tang@shopee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230411082248.1020719-1-yizhou.tang@shopee.com> X-Rspamd-Queue-Id: A8BA14001A X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: fkhu4gzndqt7yxqmhr74c75yxwjgekg1 X-HE-Tag: 1681212098-627864 X-HE-Meta: U2FsdGVkX1/a/HB4oMirRC8q3M4oBM8Y2Gf9hG2UA5suiWI6TCiZjs6mt8ShWb60cCLI57LgBOxg/6JH3QWkm7b7RE1su8QgH4e/yiFdKQuFgiW7h/QUFtoPtESSWoV1yjsv4dUQS3FwGmopnSUVORZ0z217wlMuGjnsPFl8GHBjjeGbFGdHeoA2L/4BA5yXJ0z8h76RgkLL8RzHu+hcbREoh6gOInWNcnBdOnFd2SZAaa3oCjri3UgDTC0aaLJ+ymbwS1YjL5TTxPVVK/hYrqforuT/ctNAWyUqwG9CGh784RCxZrOkvJOiYfRC1ib0+TUVjLOpF3rQDggKdp5VTLOE0Niy33aWUD++aoV6KVN4FVvgVd6ErHElKRsUtVupVZjj1+m8Wsp1F0e1GWMN2irOw7M8Ol3dJRF0btHpFw0rMpio/HZxXcVv2GSEFQf1gdLEvNrZtGzJLdFds0TbsNwuJiEDDjqJAq2ty1PACHTcAV6i/WU+zrCBB7iE9lRohuD9/RhcdiBgCyg0XkZnDbRHiKfjfCiNakDvgrVDzsQE+P0EKm6iFGkvzCax2ERk8ogz3/KtcxN6P09g0HhG7vXsFz/4rKlt5R/CHxgij+JGDbAp7XKERDSiWkNGfQ3IvA+qb2rHAZcNft6AvjnO4a8quA6okZN/hHvtJ5q8VzJP22/A5EJZjNXQTa6401cYgmS9CY5bXQnoeHKEotH3BNSH565A2mvyXQ9zs45PFb0vd7zUc2ILMmIpCCZ32jJaxh55NWwnpH0QsdCslhB46iDa6mmjxsNAbT2yKzJXCLV53c2xV2phCCCF5YbkQeKAybJhTk96bM77OM7TbyP0qZLSFCrzjLAWNTVSKzKDZNM/5YI4LqF8A31DS0Lnmax4HrHxC8t0m4Wzi9Xn4M1Wf+XWBAf+/A3xCLeU9Z/Uar1UBNY20WeComQc4UXIAlf7udcjCTQH3cwTZGb8Vsk gTEUsfDY 5rDbANbfljqFF/8ZC/OXXtCYvUEFAvXikwEDknZ81r+y4LzyyMjVAvJ8reaS6yWpqzHyqphJguU6QqAGlv/nJ57GUGoqfi6kN416KQOPxxXrMgWtc4nQHydCbGnXxdZVMp5LUY8hZnhS+BBasMgQx4TWAdni4DsN54sh8EArBaGzK2pQPQ1H+BN+N+9VK6igWNAPTeGi1+2I9j4eR9ToYwpQeKVUwonclKuTDUhX1mhr6pSuULZ0ypD7+0fgAGj2DYBNH4qfgFyHKkuQK2KnVnWYV7NKXu6H9GAoujg3QWttxN4BsLfTVBeZVujKUgTx2rOQlpI6kmpGjrCiZu0s+8CWhhjk/EekOEA8J4Q9QltqhH02NgZ1XrnYGNiF1uevInw2MailROSWMw88Emjsw6Wh1RVHAN7UQh+/O 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: On Tue 11-04-23 16:22:48, yizhou.tang@shopee.com wrote: > From: Tang Yizhou > > In domain_dirty_limits(), the calculation of the thresh and bg_thresh > variable needs to consider whether it's for global dirtypage writeback > or memcg dirtypage writeback. However, in the rt_task branch, the > accumulation of both variables only considers the global_wb_domain, > which seems strange to me. > > I find the accumulation was introduced in the commit a53eaff8c119 ("MM: > increase safety margin provided by PF_LESS_THROTTLE"). IMHO, realtime > tasks are given a higher page cache limit because they require higher > responsiveness, but we also need to consider whether the writeback of > realtime tasks occurs in the global dirtypage writeback or in the memcg > dirtypage writeback scenario. > > Later Neil said he didn't know what was wanted for realtime in the > commit message of commit a37b0715ddf3 ("mm/writeback: replace > PF_LESS_THROTTLE with PF_LOCAL_THROTTLE"). I guess he made this small > mistake since the commit a53eaff8c119 ("MM: increase safety margin > provided by PF_LESS_THROTTLE"). > > Fixes: a53eaff8c119 ("MM: increase safety margin provided by PF_LESS_THROTTLE") > CC: NeilBrown > CC: Tejun Heo > CC: Fengguang Wu > Signed-off-by: Tang Yizhou Thanks for the patch! Was this found just by code inspection or is there any practical problem you are trying to fix with this patch? > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > index 516b1aa247e8..7d92de73360e 100644 > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c > @@ -419,8 +419,8 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc) > bg_thresh = thresh / 2; > tsk = current; > if (rt_task(tsk)) { > - bg_thresh += bg_thresh / 4 + global_wb_domain.dirty_limit / 32; > - thresh += thresh / 4 + global_wb_domain.dirty_limit / 32; > + bg_thresh += bg_thresh / 4 + dtc_dom(dtc)->dirty_limit / 32; > + thresh += thresh / 4 + dtc_dom(dtc)->dirty_limit / 32; This makes sense but I'm not 100% sure this does not reintroduce the problem a53eaff8c119 was trying to fix. Reading the changelog, it seems the extra term you are fixing is there specifically to deal with ratelimiting, which is global (and not per-memcg), of calls to balance_dirty_pages() and hence using global_wb_domain.dirty_limit is indeed correct. Neil? Honza -- Jan Kara SUSE Labs, CR