From patchwork Tue Mar 28 22:16:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13191622 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 C110DC6FD18 for ; Tue, 28 Mar 2023 22:17:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57BD26B0082; Tue, 28 Mar 2023 18:17:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5085C6B0083; Tue, 28 Mar 2023 18:17:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B9E56B0085; Tue, 28 Mar 2023 18:17:10 -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 16D726B0082 for ; Tue, 28 Mar 2023 18:17:10 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EB5F2A039D for ; Tue, 28 Mar 2023 22:17:09 +0000 (UTC) X-FDA: 80619718578.20.2936FB5 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf21.hostedemail.com (Postfix) with ESMTP id 2B8D11C0004 for ; Tue, 28 Mar 2023 22:17:07 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Jh0ANfJd; spf=pass (imf21.hostedemail.com: domain of 3YmcjZAoKCOUfVZYfHOTLKNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--yosryahmed.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3YmcjZAoKCOUfVZYfHOTLKNVVNSL.JVTSPUbe-TTRcHJR.VYN@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=1680041828; 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=3EqK7sQZOfVTLBQ7dVPZO4hRmfVfAzm1laH3BYvfeCs=; b=5QtNHSq+7c2VQVpPQwamFQ6WwsO+uYFA1/U4WYLHv8j/nwmvYoopE9yzZnUU+QAeVjDQbi /F2obVbYm+70AciCQcxNInqNBpUpzkv7fbC8RXiXLJwoYhFIjgtRGbRXNg8KDcvlYT4U9K UK+FdMXVBoiYCIdDB6KDw39RQpB9E2o= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Jh0ANfJd; spf=pass (imf21.hostedemail.com: domain of 3YmcjZAoKCOUfVZYfHOTLKNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--yosryahmed.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3YmcjZAoKCOUfVZYfHOTLKNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680041828; a=rsa-sha256; cv=none; b=NCO7ZCpL+jexi5k9/9EtHtmfPFQD2LWHcKKgKWAQnPBdd2udJUuxt+YnO44Kd5IGHkPgkt BnJTJp7Ih741A114NNJAF8Nqu+cEsjCm+X4cgMHRTuoCwUtrzBb+DFGxIRrFbuwlunUwm7 WKz2wZIhaq/G+iLYZB/zoEiySzCuu64= Received: by mail-pf1-f201.google.com with SMTP id a6-20020aa795a6000000b006262c174d64so6315027pfk.7 for ; Tue, 28 Mar 2023 15:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680041827; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=3EqK7sQZOfVTLBQ7dVPZO4hRmfVfAzm1laH3BYvfeCs=; b=Jh0ANfJdLtvcj14Ycx8o0NJ4r9qhZa68Pa0uc2IX0QIjCZKetrfT/Nq/ZDVr5AllWU XClT4UcNh1sPOxMcsh6sWOQo9/2lETExd/HKLVBB2M4wtgPvzRmNcVBtdBrQWB7ALdhZ R5a35ECD7K8gif2eOzvhZ1FDX+1AdzcBxQSZ/AU6EUVqL3HECb2nu5rbm6oZEkaJmqE+ JiSGi5TQPR/5oszlj+b2yUkvaRVAqFo8Ka4HGQ6Ui7wSkXSWPGkTPTug5dc09uPeC/es /a05azr2/gL04QjqP7TTdBynMB9W71leZpwkNhiYtT2r27tRHGjbrwcjlQFLDRhwcOoU qhHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680041827; 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=3EqK7sQZOfVTLBQ7dVPZO4hRmfVfAzm1laH3BYvfeCs=; b=x2q8790ATHb4TBO1b9VpDqtlE/jFlqRzzvCNQX5hLg7/T0PxSiyp4PO5iXjUzA0WdW 4zQ4105MQt+ZIoGbJ2QYJuvoqKXlLI5tSnZv2QPIFDepIfnHngggFLEwcBR1CUEqirIG /EWVIDRyAn/W8uDZEDUHsXIlfwZmwK5RsOy/IEqfvyVr4tn8qSj1ma1CtOYfPTGq1VEz VF+EzHRZXOb4HLe0fWDCaEOG60NtsS42m0l7tTUNe0ULkbueIzHNQtrKxZeQGe+jUyD4 7Cf5SUGshujA2WuI77FgqtKbjd6tESrBXbfNelR7Yw6uLuJHDHcwrLuG9/6Hf6Q5Lpv6 of/A== X-Gm-Message-State: AAQBX9c3wXhHRSwhdyVl7UAyc2dSFo4WHXR4CDQ5z8GBICulrt4VUS/S JqbRy7OjBIP6Vuu11LGV92LddIheOKp9sXgp X-Google-Smtp-Source: AKy350b8EHObFwTAz134ielB7Lfw4iTDwRchFeXjbgsPVENWxNL5SgSGxt3wM+3XFB7OgKxVRznr5DrlZ29gVq8P X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a17:90a:fb57:b0:23d:30c2:c5b7 with SMTP id iq23-20020a17090afb5700b0023d30c2c5b7mr60436pjb.3.1680041826556; Tue, 28 Mar 2023 15:17:06 -0700 (PDT) Date: Tue, 28 Mar 2023 22:16:44 +0000 In-Reply-To: <20230328221644.803272-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20230328221644.803272-1-yosryahmed@google.com> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230328221644.803272-10-yosryahmed@google.com> Subject: [PATCH v2 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-Server: rspam05 X-Rspamd-Queue-Id: 2B8D11C0004 X-Stat-Signature: xkfp74dkqxdqtc6dufz97djqq9zgu365 X-Rspam-User: X-HE-Tag: 1680041827-380623 X-HE-Meta: U2FsdGVkX19UbVRlDZd7M2hPnoWU1MwFJZT/ufPTJhQDuQQuFbdzb9SK9czmaAFeBejvSgbo/kJexD2LEJB+ZXYCMDIwHrK0NC4uYXbCaPJa2W3ec3Hrn/IawcM2y69MbRWf0a99HwYqeCwO6SAo1xEn1Dh7d4jP+pIBpyI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S9iX6t2fCdf8i/rmGgBoyZX1NIoMxtNkYim3GUvIdM2pNCex4rsglaPzdqMrG+EKWjDK80HMBy2TvcE0JdYA217TbZW8v3XIxol0pv/wICelqA/iBPmWT279eprhbFKKroJ+fbyFRdpPgYVFzjUL3EovQgSgKKBk5vQYCsfRKmxx9zTRSfJfsLk6t0J/V6TTjjuX8a+P7zq+FMHWmkP+aExNy1JuNn5hbhPv/NPFo8edA2qm4BRuBW3zDytVK2P1CPuR86Iwb0QtwFo5X0aJbfgbJfBSfQOGXnjHvU+v0Z1X9reL5YKgxXmlQGL10Z8RQasqJCPdJ3y5Om31YUhJdVeVfHyIReVwhLtCAuTMlh3t+CkaM545/6V1Kge4TjOLIf3wpGkekXAYvk7YWq0q8eMAUNZ5K9UlyDYeOeaD73LqStrt7UDiBUarsVrxA/RRVKHJUegzhuF6i2LTfU2xEsBCHb7jNgm64/qOuvQV14/rA== 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 --- 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));