From patchwork Tue Mar 28 06:16:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13190562 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 398FEC76196 for ; Tue, 28 Mar 2023 06:17:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4092280006; Tue, 28 Mar 2023 02:17:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF115280001; Tue, 28 Mar 2023 02:17:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDFD0280006; Tue, 28 Mar 2023 02:17:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AB3FF280001 for ; Tue, 28 Mar 2023 02:17:01 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 06CB9ABAA5 for ; Tue, 28 Mar 2023 06:17:01 +0000 (UTC) X-FDA: 80617299042.27.09B4FB7 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf13.hostedemail.com (Postfix) with ESMTP id 28A3C20003 for ; Tue, 28 Mar 2023 06:16:58 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=G3C3U8FV; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of 3WoYiZAoKCBkNDHGNz6B325DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--yosryahmed.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3WoYiZAoKCBkNDHGNz6B325DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--yosryahmed.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679984219; 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=Vy8wz9BoJKucmcMBXvIGPOuITeThi///HtllaZbgtCo=; b=okbC1wTf0/TrLgl3F47IiWE5ZEmZrPLA5qnCYQw7qRRF8E9KbPrpDQeiu+a126RA7x+tJz svAcNUnqY+Vz3yqGidrDJRiFTL9oAc0zti6nECvSptPJPs7RRUzvzdpeh/RP2AkpclIoUR Dje7oClsAXjYAtjAMJAxbjfcdTrY9T4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=G3C3U8FV; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of 3WoYiZAoKCBkNDHGNz6B325DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--yosryahmed.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3WoYiZAoKCBkNDHGNz6B325DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--yosryahmed.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679984219; a=rsa-sha256; cv=none; b=yI6x1lWc0MUF4OtvaQwLNGkNVfyeEBmECisDRXz+PDnp5I4t4o2WHEQA5bpGp9ayTikkW+ F6mHVxhWsFlE4twMVPF3b2CJTkiJphkQwBnN80HdKQ7tdk+BlY77X6f313XFjM3tXnUnsJ p+fOBVUJ9lrAlgUFxBK/7K9Bd3ZGQZw= Received: by mail-pl1-f202.google.com with SMTP id k17-20020a170902d59100b0019abcf45d75so6954802plh.8 for ; Mon, 27 Mar 2023 23:16:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679984218; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Vy8wz9BoJKucmcMBXvIGPOuITeThi///HtllaZbgtCo=; b=G3C3U8FV5xO4vsplclhU9+4PkBH686vIIIrQFFquICu8//oGn5xL/Tmt4VNVE1HnMt hORJK4mB81itHhGs1+plTWPpHn6PXb4UvAXp2In5M38sRtIYXUydb86gW9UCcwU8NUMK AKSJULzbSmJ/Zh8xR8z20CA4EuuFhupmK6yUb7XM0dWX+orGZyC4roBLz+bFSVl/SrGz jDFcau8INkey+e5jkuXnym7vXagjhy1slym0NeO+iUEtBeJGIjBlnt29eYQhaZCdCsb9 TItPIolnMlslNIl39r9v4yrb91hLywelng+1GUeMlXmGbk+u0V1YHrp34uG87/cMCuf4 DKLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679984218; 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=Vy8wz9BoJKucmcMBXvIGPOuITeThi///HtllaZbgtCo=; b=6FPmaP4y7pD0GqsdDl9D6B0/bc9irJanv3ygAmFU26IeHTC2bpXqsS61KUPEhyP+Pm H95q1xEq1OaiEeMo6qxG9zJDy1IZ9ZGUzSQFeYklKG7xcO8s/efQAPBXrVmA1KClLKq9 4nPUZ2FYz4kQq0zEUPhzB+1vXrq+IU9jv1uuxQ8tccvx2QpU9fdq73cIFYv/LpJ/ywlb kHSTuxdv/g6BXv8r/80YXRoS8RYzn9U9TI25gxTou8/4uk4905uFlb9m4AKoAdCKYSEx NUjAaCJY0+/YJ7AN6/VMCYamScfcAmlyuGR7XXrPQPEXPh7N1Zyblt8JVD1B8sJ4Phqp 4+fA== X-Gm-Message-State: AAQBX9cC4V2OoHHA6SFgW8YYl8R2B5shWgxcK8y93TJ09+wgqE7FuKCD s5lIlU4c0VqU5YrYkqvTipRkWCcKnPc+myPZ X-Google-Smtp-Source: AKy350aVn7i51pwbUpBHdDCfopSzB0y7+YNrEoZI1+8jV5mnjDSATrQRcelVSU3ikfIyno7DP54WO5q/0DmrmRgv X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a05:6a00:1781:b0:593:fcfb:208b with SMTP id s1-20020a056a00178100b00593fcfb208bmr7364360pfg.3.1679984218020; Mon, 27 Mar 2023 23:16:58 -0700 (PDT) Date: Tue, 28 Mar 2023 06:16:38 +0000 In-Reply-To: <20230328061638.203420-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20230328061638.203420-1-yosryahmed@google.com> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230328061638.203420-10-yosryahmed@google.com> Subject: [PATCH v1 9/9] 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 X-Rspamd-Queue-Id: 28A3C20003 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: ps91dhh8jpa7fxnxytq78tbq6gawkkig X-HE-Tag: 1679984218-65429 X-HE-Meta: U2FsdGVkX1+Qy47AqLBPoXMnWoE35RZsWXzXpk+1hgXLT0Vynm8elO4itpvNxPC2xK656Hv1hQx7lPWnDIDrJGNlzYfr/8dEGU3J+OWNie8Xk3oHomDMDpyZgt5M2PWn9wJR4yVf4ZHqPhfT0T2h+KDzMeo2AfK0dvyil9JSy2BKjBfsRU3aYB+v3QOuSGPC6eZfGly6MZNwS1nX+CuIxRv+QkrMPWkz+tAEb/ZqNv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Elgx6zpnvglF2jEoTMbZbQCW1y+bYnilVBgZHZI5uBHt5yGUZDHWFZjJ5U3biAoF2qlmbCbKcJULC/PSvoL92m9r8pZPqPy3KQ09d53LmzoJ0ZRzoPKbIEzS6E2rAbRZzPZmNXqNlSHch7BN7Ov6GcaP2bcJ4CPs+NpsbKMLLqCede3yVnt3qa6pw14wdXpXTRmKXzwskPHH73DPdk9g1g7yg7o2CU01jWPNEAMlycjC2fVbV8FtqFAA+uPaAysYkQIIWDkolqWGgeLZwk9T4lCWorkVMbpP5/y+/ugzZWwehl/trIQP/nKe/l7yLYNsRO72y923kG4Z5/Q== 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 --- mm/memcontrol.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 0c0e74188e90..828e670e721a 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));