From patchwork Tue Apr 11 08:22:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tang Yizhou X-Patchwork-Id: 13207183 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 2BF4CC76196 for ; Tue, 11 Apr 2023 08:22:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D1A56B0109; Tue, 11 Apr 2023 04:22:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 95B6B6B010A; Tue, 11 Apr 2023 04:22:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7FB8E28005B; Tue, 11 Apr 2023 04:22:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6C0F16B0109 for ; Tue, 11 Apr 2023 04:22:58 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 267B3120AF7 for ; Tue, 11 Apr 2023 08:22:58 +0000 (UTC) X-FDA: 80668419636.02.EF9945F Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf03.hostedemail.com (Postfix) with ESMTP id 5B02020003 for ; Tue, 11 Apr 2023 08:22:56 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b=cWu5zeNK; spf=pass (imf03.hostedemail.com: domain of yizhou.tang@shopee.com designates 209.85.216.45 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=1681201376; 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:references:dkim-signature; bh=IpxUF5lPw5fH1v9GXstfYnEROMjPbDed/M3WOXixapU=; b=fdYHeOrvxu8ANE0FDV4yTvYGkgkQcL9N133ntTCcCDfsv+dXEtwJwas+AyMXa9CrxWPcBF ihb/lQl1vDajv1oucGg7s5YW7nsg4LbX9hmhbF9oxJAyapDkqYK5Q/RVvToU/B51CMTegh hG0cLIxQpYZJubT1NY4AWEqvTh9kqzk= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b=cWu5zeNK; spf=pass (imf03.hostedemail.com: domain of yizhou.tang@shopee.com designates 209.85.216.45 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=1681201376; a=rsa-sha256; cv=none; b=LIs3yg6jPjSEeBspRfm3iNFvysZd/7qxlkcRk+FjVHE8dF0zc3VYLEQThO49PP9QEM/nl+ NkBJBv1KhiJO09wK0hFgZ0Usa6H8eFG3ncxqUZ+4e6bRsoLB6SUzLTKrjx9wWpNvr4qNcL ynqY4NkY3WuRLmRs7PdAlxXFE93h9tM= Received: by mail-pj1-f45.google.com with SMTP id c10-20020a17090abf0a00b0023d1bbd9f9eso10199054pjs.0 for ; Tue, 11 Apr 2023 01:22:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1681201375; x=1683793375; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IpxUF5lPw5fH1v9GXstfYnEROMjPbDed/M3WOXixapU=; b=cWu5zeNKGveJkZyiAQ2eJEzyk9Z1bgZABL/DL4qd/p/mnaIy2dJ1vq3k0moD4u6TiK fMnNSlR49Ew9nZRJ4mf+xjT22EwB2OVZpxusyoDvynf6MM2S24PVOCVIhlhCEtFVjvyd 2SqMLcAWDlXqM1rpnsPz6KiJVZOJiFvF+2WOqOaB85XoV5hoaBidreXGrnft6wDVzOjz RBoYq/sozNJFzoqZR7x/DPkimOnCxd1n6HcVAH8sFi9asEzDOpKEwad1DacPqR51i4Ux xeOHKj58iARqpyUnO7y1AZTL/n490mnFw99/6ZtvMmXBbQrrX7XLwCAEvQ4FanlORsiB bYEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681201375; x=1683793375; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IpxUF5lPw5fH1v9GXstfYnEROMjPbDed/M3WOXixapU=; b=giciXEzBn76PJe+TBHm444KvQtt0ozLCKxJc1ZREcr+FQMWOaxxXj/v9RpsyLTbHcH NotAKpy0Yh2ufGWHSKIXRbr7mmgzKU7lZbQzpSdEH0BDhxzUMSrf3S84jSY5lDrPHeaU Pbkq2EjslpuAL4i77SX5cO/h7dnXr22gAtJzlkRvEs8dk+6K7ayNHjlC+a8vw8hvuM1O fWQB1nXIqZH2cBDTm2xxtUqxUEp9s/HrKngXYm3gKU0giHMfuSSdKXInBgVQ/kvmIv2n Isuo5AupPwEztYQBarZ5ZAuggdOuYr0Xcb0ONbcL+h+01A/XvCvVKMOYoWqnshnq1kD0 1Iiw== X-Gm-Message-State: AAQBX9dKELdiL/tc2reA4lb/uC53pVi/V0cEDKw8eyUKMksGwEJQeRAL H8u34Y7b8HUJj+VCayr8JzOCIg== X-Google-Smtp-Source: AKy350b0nqklIctCdZglTxe4v/+TlWgmr4obZvOfg9n6YFmtBop8TII2GX8zcLdfRJqoxp/zJDtWaA== X-Received: by 2002:a17:90b:4b92:b0:23f:7649:f011 with SMTP id lr18-20020a17090b4b9200b0023f7649f011mr2721652pjb.43.1681201375110; Tue, 11 Apr 2023 01:22:55 -0700 (PDT) Received: from ubuntu-yizhou.default.svc.cluster.local ([101.127.248.173]) by smtp.gmail.com with ESMTPSA id h1-20020a17090a9c0100b00233d6547000sm8684374pjp.54.2023.04.11.01.22.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 01:22:54 -0700 (PDT) From: yizhou.tang@shopee.com To: neilb@suse.com, tj@kernel.org, wufengguang@huawei.com Cc: jack@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org, tangyeechou@gmail.com, chunguang.xu@shopee.com, yue.zhao@shopee.com, Tang Yizhou Subject: [PATCH v2] mm: Fix memcg writeback for rt tasks Date: Tue, 11 Apr 2023 16:22:48 +0800 Message-Id: <20230411082248.1020719-1-yizhou.tang@shopee.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: ib6bsuij4hacnn19mdo5kqhswhhqqkm9 X-Rspamd-Queue-Id: 5B02020003 X-HE-Tag: 1681201376-876070 X-HE-Meta: U2FsdGVkX1//QCUBU7MVcOS1dhkqqjQ9U+XYrvz7RZR+YKjDa3Y9kr6EpXRdc8n08/ezUP/pzmPNsvaX36PE9NQZpqa9+T3xPrLr0319mtDf+5uK+BFtsuvH7MKDKeQSdogI5PgHtJrLn317BIDX2KGRQ7yO5dC5dYyNFLfzIV/ta2lRRLYiDGm5YcR+IjJvjXB9191WUSm1tV0vH1L3DZutyhafJXiW8WUQUawS6mpCohObH/au5SZAzEuRYPv5wB33K6Sj2U9O6bviiuBh9HEcWS/sjHx2O0xReZMLJhOAKXRP2T0yBuJeETDZT6btknuuu6Vg2XCv5eGBeizJMrThKIptt0z8YC0WO68OMReAhcDrspIhV/hyyBzXrItFjZNEm3KS/16CVjJbBpHvFnENDXwtvtqB7BJTEpqrpsCEHAMtMyeJ7fOcWHZRVYCFRpyZgE31qyqwQPS1a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malgCJso4adOIerPL+bhpA== 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: 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 --- v2: Rewrite the commit message. mm/page-writeback.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; } dtc->thresh = thresh; dtc->bg_thresh = bg_thresh;