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 84970C7618E for ; Fri, 21 Apr 2023 14:57:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CE6D6B0071; Fri, 21 Apr 2023 10:57:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 07F256B0075; Fri, 21 Apr 2023 10:57:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E89006B0078; Fri, 21 Apr 2023 10:57:39 -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 D6E706B0071 for ; Fri, 21 Apr 2023 10:57:39 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A67A81A0413 for ; Fri, 21 Apr 2023 14:57:39 +0000 (UTC) X-FDA: 80705702238.19.92A16ED Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by imf09.hostedemail.com (Postfix) with ESMTP id C201414001D for ; Fri, 21 Apr 2023 14:57:35 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b="WYm/u6je"; spf=pass (imf09.hostedemail.com: domain of yizhou.tang@shopee.com designates 209.85.218.50 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=1682089055; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2tGOts3QoCJkBrTh/elI0w5gRAXfGN6PXECZof4lKmE=; b=oksPrHoZ48R2yPWoNYv4fHfGktPfoNUIeEFhFx1PMd/l8SLbt6fboagp15whOI36b7qrqR WULWLLTCEFzSX3yBpI4BUS9PPSjtRvUOZusugNdI00SPHxFKtZvJ/vKAKT6OxOloKVwyjy 9uBtcekFZ7uLeGcPPbFhq4q8pfefSwE= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b="WYm/u6je"; spf=pass (imf09.hostedemail.com: domain of yizhou.tang@shopee.com designates 209.85.218.50 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=1682089055; a=rsa-sha256; cv=none; b=2pjUwCma34ZwaUiHCS0tVAvtPmq1roD/xX4nmE4EOJn/+vD3Q0+s0qDZUVfsGj0jZyzKs2 EVPD44GMNXK+V1+Jf93qxvbYvFe7CWFDHqZ9SFXFRmK/snstGW2hiaCnstX5+YlOyVQvLg 7VZpYzLtCZgfUUlxUt45ut2DAutje6E= Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-94eee951c70so254008366b.3 for ; Fri, 21 Apr 2023 07:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1682089054; x=1684681054; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2tGOts3QoCJkBrTh/elI0w5gRAXfGN6PXECZof4lKmE=; b=WYm/u6je/yQrVcdxaM21rxEZ0+GXTk8XaxTEQOkETzAnYXRJnQgamFUHVTTAMyw+w1 3+rbI16Nbl7j0JK/T/VYMCfo1xsFJxbxyBEsS7Z7Li9VJv9YNQTCFzykz8UP200xICu8 8ja7sQj9zZZ4b8tbUrtpD/NA9+e5aM9ZE3RqSYihq4tPCJtf4oPf+o4n5X6wE7X/XJVD qh41TZI1OXMriBxEiTxTI0FpFwFGTz2WtrmkcpSLA9co23FWI0R8YWUmrLp2OrkpzIeo 3nfcR3CRqre9dJ5ci8wSoEvzZzEb/VS0v6gHSga7GIk59vh/KSr8e/SHphyLG0tc+fap Fayw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682089054; x=1684681054; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2tGOts3QoCJkBrTh/elI0w5gRAXfGN6PXECZof4lKmE=; b=BEeURyOHz4ZQdM8XbIkPaaNEjgChh5GGkawFE4+ijeEMxOig5LiN+AauhlmgqZ4NDh lwEHxipfnPxxhw7xmjTkuZWsm3whSUXYQTv7RJ2n0vpT8aqIHg0a0ZJ26uPbVPlxs1kL Xm10RPXjkRsymJdFl2LlIgeH5Hooc4ghH7fX2RIED/p5rxGXyws8Uv/wU4k3KMztzYiX 0BFO20sLMnxl1C/kKGqp3TFIKFqMMp4p7TcMHgqCI3d8F4L9JsfhpanARxo/fm8VvIO0 QlmvdNHwQ1KpNc09Nrou8YbCGuHHdaNl7kspvldW3PLdqW/SCXdd5PJr2gvPN0D5YVkq Fz/Q== X-Gm-Message-State: AAQBX9fA6SxHcYZkIptf8RQkOrsFZ4lssP6UGp37MSxbGlHWQGsPRvXi CZPNQBfOloA/cBK8BsBvbT0/hMbp+XWl0SOQq3REzg== X-Google-Smtp-Source: AKy350YOqjCAd20DbcXBhENwSsKheuT7lUuo2ljQofZhsNS/wOOp3VDL8h65sMreevD+PCzHnCnp1uqIlwwd4A0NSNg= X-Received: by 2002:a17:907:86ac:b0:94f:3804:5cd6 with SMTP id qa44-20020a17090786ac00b0094f38045cd6mr2991499ejc.66.1682089054218; Fri, 21 Apr 2023 07:57:34 -0700 (PDT) MIME-Version: 1.0 References: <20230411082248.1020719-1-yizhou.tang@shopee.com> <20230411112130.7zswqnyifgjhshif@quack3> In-Reply-To: <20230411112130.7zswqnyifgjhshif@quack3> From: Tang Yizhou Date: Fri, 21 Apr 2023 22:57:22 +0800 Message-ID: Subject: Re: [PATCH v2] mm: Fix memcg writeback for rt tasks To: Jan Kara Cc: neilb@suse.com, tj@kernel.org, wufengguang@huawei.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, hch@lst.de, mhocko@suse.com, tangyeechou@gmail.com, chunguang.xu@shopee.com, yue.zhao@shopee.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C201414001D X-Stat-Signature: dwe98sj73fzgwjgss67gx3s9rf6h3c1p X-HE-Tag: 1682089055-833529 X-HE-Meta: U2FsdGVkX18HzQxU1H2NIIxxyQpgeVY40+fQOeOMyjQfQBhBJeJPh0PuWHkzBttoINSsbm/GlqRVyiQXQt5d+9jlKHghtPNOR5OCg3pJf3Cr6PaB/CPloOxugYtZOwufkM3pdvy/Fj0R4VT4EI7Cn3clXNJZmCAx3c5FAfHeL6+L/xZfu4fKbcc9uR+yASobTrOn51mU5BOOuYpoOu6HXKcqrg8UgziAOohXfd/BCDIDRthQ13PpQXsNoSAL2fdbAqBbBNMPB2KRye2QTZovKHA7469DIaVKIAl+lj0Nl/zZ9rwbF0FI8Gv4fnZp3hfHrfUWBmqZc1m70HVTTeJNy2bZIU4RNDs7OIu0kZzmlnSK3KgWZgxvxOgu8gYDjkU/YBIeN+7gmi8wPd/XOvJ4ouqdiROb6d5a9K2+hhD+pfMhGNPEkgLCIWBu+hKeponIYYugnYpVCVSDM7QqTlxXV+W0EYJ2ai3CLr48T5UgwZ+xT1TVX5F6XaumjTR1du8JBRfiKoUeCKehXDQtMWFl/DE6+kX21Cwa678AhVmD2NH2wVL2sJKs4tvvEmxt19b4ruHhqv6pQTvtPRB4bZsaTg4wXVVBCJW4D9wFzSBrderqRYiOvH6KW5bpNmmR71uE/2ef0sEEywAJJN85YDdD30/JC1Rb78LkEwh9l9Btly5jQ1uKenD1CIgsgAaoZUWtOQF/2LnY8+lRDpTcB2/XCgrhgHK5ioamwudDjAV36ZobIoF7lNqr5Ef2emqtMAB7ZfGS0b+dhHgcpZRteR4esbrHEAwObbRq0DDrZVipNk8+ydQ8WFn29xxm9O5O6aK4LOhVtCuEe0gPd487YsbGfU2OQBrrniCZAmBQiIb7mmu3fNp3yJccb0Xh54DDOEaCwfS1XWjVkQhXDCdwQFp2/7v2/hPOTQpJVI2no/5wABU0XVwwb8A73YqU7uD7FSZp8w2LcnlKkGpKj3YnfMP 8rz1m6ht CjfaIEcLsRBenmpVf7jwa/H2nje01cimSbwUT6zWtVeUwIHzNPjj5G9N7hIBIq5v+11oQ1A2HtgT4hp5Y5haWA7XjgDjoSiKt02xSkqghAUDxeTQPWZaVzdxFI8oBW5dOYzsKj98OgpdftlrAdQcHQ19LegEesJyMCiKpthge3I5pMnfe2FNwV5qonTcS5aNGaeSEGRADT3J9x1NjllqbKD6EvUHPp81Rr6Saf9POyZ/3BxrAq4oim1c194Jf48VshOXWXA17vL4Pp4HIN9vd3qUsZDmWjvh0uS5Vx4FJuVrBL8+MwWt61nBLWnUsAGeex74aQcAvhWa8SjONffuCRGRozSZGt/EA/upQ34DUplOfAfi522g7q1u0Wz9jcF+H+btVgU6WxLl4IrXvOMtVq7NlngpKyWiUOTW4IjxwbrwXb5k= 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: CC Christoph Hellwig and Michal Hocko. On Tue, Apr 11, 2023 at 7:21=E2=80=AFPM Jan Kara wrote: > > 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_TH= ROTTLE") > > 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_thrott= le_control *dtc) > > bg_thresh =3D thresh / 2; > > tsk =3D current; > > if (rt_task(tsk)) { > > - bg_thresh +=3D bg_thresh / 4 + global_wb_domain.dirty_lim= it / 32; > > - thresh +=3D thresh / 4 + global_wb_domain.dirty_limit / 3= 2; > > + bg_thresh +=3D bg_thresh / 4 + dtc_dom(dtc)->dirty_limit = / 32; > > + thresh +=3D 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 t= he > 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() an= d > hence using global_wb_domain.dirty_limit is indeed correct. Neil? > > Honza > -- > Jan Kara > SUSE Labs, CR