From patchwork Thu Mar 30 19:18:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13194758 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 CDAD7C761A6 for ; Thu, 30 Mar 2023 19:18:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EF60280005; Thu, 30 Mar 2023 15:18:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 97B28280001; Thu, 30 Mar 2023 15:18:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70737280005; Thu, 30 Mar 2023 15:18:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 57532280001 for ; Thu, 30 Mar 2023 15:18:21 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2A25A80E5A for ; Thu, 30 Mar 2023 19:18:21 +0000 (UTC) X-FDA: 80626525602.14.9487D63 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf12.hostedemail.com (Postfix) with ESMTP id 5E1714000A for ; Thu, 30 Mar 2023 19:18:19 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=PUv9MA0n; spf=pass (imf12.hostedemail.com: domain of 3euAlZAoKCPkzptszbinfehpphmf.dpnmjovy-nnlwbdl.psh@flex--yosryahmed.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3euAlZAoKCPkzptszbinfehpphmf.dpnmjovy-nnlwbdl.psh@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680203899; 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=WbNC07VGnJucfMQdaVru/HWxeCTMcNM6hFkgQ/MCeFU=; b=XnXtzwcU8A6bD8z+4/eUFGzNVfdiDWiAXl87rqCwXcSRVi16tnB6lb7wYXisL3s12m48bU 7T1qt/0b7i4cJRoERC1n5zBUQ1GQFRwOosMGfDlouzIVN4m8EoXQUf4hOlpykqATv0/kO8 HPHDhgH3Y4QkYtSQdEgs56j55mwsvPw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=PUv9MA0n; spf=pass (imf12.hostedemail.com: domain of 3euAlZAoKCPkzptszbinfehpphmf.dpnmjovy-nnlwbdl.psh@flex--yosryahmed.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3euAlZAoKCPkzptszbinfehpphmf.dpnmjovy-nnlwbdl.psh@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680203899; a=rsa-sha256; cv=none; b=PzB72aNG6uV4CVKpxtmqj8wxxaHMTL2O0cELNfdaZ4sNKxyWyoi337g/JyH7t0wGxHkeec JrzIwGBCW3nDoRLR7GcSDHxOE5N7djk/p+k8KWX3gVDtFyRd0UwIRNHRmDuwaAQEq6MLAV bYPilN/xvhbTW13I+NIw2XLi6lZSY7g= Received: by mail-yb1-f201.google.com with SMTP id g5-20020a25a485000000b009419f64f6afso19688928ybi.2 for ; Thu, 30 Mar 2023 12:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680203898; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WbNC07VGnJucfMQdaVru/HWxeCTMcNM6hFkgQ/MCeFU=; b=PUv9MA0n+Z8fm7ErrGvHySjECm+JmVMmb7yIewlfjR/61XxilLPkk2HWdbFMTfUOaL VEd5S3Db2lj6fZaM1EVkiIBt/SsoMNdbAydQDGkFf9C+290T1e1uwhZ4tZ9DFf8Phq0h P4OVDvENTCX+3IndK3Cvs6OkRD4foG1c4Yew7PAGOLNrfjOHkmrszhM9+d8Istzt+wK/ krUK3yorRZOqS1BM/g9ye1FRB5jRNaXtQwUxDYcXcRNeFj0C93RhkVtRFak+8MvkC/U9 MW/LMGQgSZbJ8G2s7XbIxfyCgArJtDyQ9vNCBWNE1utNTCLeMAHTcanEcYFbU2EbD5hm feog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680203898; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WbNC07VGnJucfMQdaVru/HWxeCTMcNM6hFkgQ/MCeFU=; b=v5ql9A5ZCzG1g8SwEhDNmklF+HpjHby4rH9ykeq1eDG5ogdFSIdPKAHddSYkCtkcKu 4nSuk9SGZbHKj1TScqbX5/S97idkGhsm+wgyeyUHiZPEzx9L/Mvwj83bkMkReHPdV3jE Q9NPput/kPeYJo36F8yvu7ra+Yf5TZBgXnTU/VVv5MDJQR5VDLFct2Cnw5MhC+Fx2gl0 zTCTIepvq8UaMlYvPOzgkNeViteYUMD47SILTHgzRvFRFCLvZUsuO75/aLyoXZIU76hB BM46SVIaKQ2FjBMZzREJFeoalN+8q/eARg/GzmU317XbYQsZ9aNRASi+PNxI71VxMCh8 YTHA== X-Gm-Message-State: AAQBX9eOUppM0MWbOjnHx0Cx/sM2fXIz6tlFOtGbjCy6W32swaXdlZDt kmBRfxV4ehg0BqJH5WqH42MpPp9rGpY4kx69 X-Google-Smtp-Source: AKy350Z/bGsj2O9Q2OanxyiTVpU0KIn4cOhMHnfEJjh1llR4Xo1YrB6Sk31TDPAteoghtoX9TuixuaLotnLFVi3d X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a25:12d4:0:b0:b6e:d788:eba4 with SMTP id 203-20020a2512d4000000b00b6ed788eba4mr12664999ybs.6.1680203898630; Thu, 30 Mar 2023 12:18:18 -0700 (PDT) Date: Thu, 30 Mar 2023 19:18:01 +0000 In-Reply-To: <20230330191801.1967435-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20230330191801.1967435-1-yosryahmed@google.com> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230330191801.1967435-9-yosryahmed@google.com> Subject: [PATCH v3 8/8] memcg: do not modify rstat tree for zero updates From: Yosry Ahmed To: Tejun Heo , Josef Bacik , Jens Axboe , Zefan Li , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , " =?utf-8?q?Michal_Koutn=C3=BD?= " Cc: Vasily Averin , cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, Yosry Ahmed , Michal Hocko X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 5E1714000A X-Stat-Signature: w7dapencpr4dr48sj6rzddp15q486kmh X-Rspam-User: X-HE-Tag: 1680203899-358933 X-HE-Meta: U2FsdGVkX19MDVGu4M+y40EWvcv57DN3zgzW3QJwJbxW5pUXR4KUOs6K2jqg+gUUILBhIp60264BhENaWOoDj1w991YyxJ7crlv66nmykHVOC2LyOtvdZuents7i1ds6QL6pN6cMXxNMDlajEoOR9ZkMfC279EJdtUoOHSE3nug/iu527IeMEZ+gAVn1qjWIciJhMiRUS3sIjWljLYKhi5rfDM8xWhYUKv1Fb7oAgzqUN7drG2A2i0JXc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xy7vNwaLxcFK9cWvY0w9CRV87iehgExzn9HiXwZU7INiEcTc7WL1zu/7erpxEgF+zQ/DpuFgigeF9gjkRYUog/cNu8QSoHHONaRNEaDlsebZpqw6Q/Z8PUpEGdmsWgKz9LRcOIy4Fp9Mazx+pvj/tE+bOF56zBZQ9X+0XQWnMhBVEgc1Jf6FGnq6xV3tG7tBGgiw+jwJryBhSEHqfNfkKBRd5ZHfyj0cEHg6wIrB+AQ/1l1/yZ6wwT0DalDJ2cQrGmLIdWa5T6mpVj3NfGuhWriQxuPUOutuf9qrAn1a4e6MRLcSfCkqxFITmvgwTywhfIXFzmlxCjgKJOM1RsHWLJmTAd5OPRcctWTihatmPSZLoURjF60SED9yAQ7sez6uE1WwOLKoSHUn+NHO/buwfmaWpuUvpn/Xjp2eM4gIMI/i2gYTcfnf4cNWnrsrJ/ywRKSQ== 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: In some situations, we may end up calling memcg_rstat_updated() with a value of 0, which means the stat was not actually updated. An example is if we fail to reclaim any pages in shrink_folio_list(). Do not add the cgroup to the rstat updated tree in this case, to avoid unnecessarily flushing it. Signed-off-by: Yosry Ahmed Acked-by: Shakeel Butt Acked-by: Johannes Weiner Acked-by: Michal Hocko Reviewed-by: Michal Koutný --- mm/memcontrol.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 361c0bbf7283..a63ee2efa780 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -618,6 +618,9 @@ static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val) { unsigned int x; + if (!val) + return; + cgroup_rstat_updated(memcg->css.cgroup, smp_processor_id()); x = __this_cpu_add_return(stats_updates, abs(val));