Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp73934rwl; Thu, 30 Mar 2023 12:20:56 -0700 (PDT) X-Google-Smtp-Source: AKy350Yf8KLuhYnyXd36r59TuAA86Tt9kE79Dd+RzXA24IhsFunYjPTO518Ym5ZfuMN32X+Z+cCE X-Received: by 2002:a17:90a:788f:b0:23d:2b53:1ae2 with SMTP id x15-20020a17090a788f00b0023d2b531ae2mr3114130pjk.3.1680204056520; Thu, 30 Mar 2023 12:20:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680204056; cv=none; d=google.com; s=arc-20160816; b=CFZBTpT5Db2qLX8hd/+ldsJ2SuZ8eFVeBnoUyQc75sXPRckkK8umVXpWO38T3kKo6P Nu+A23PA1hqgKs48+7SDwtsTkE2hQXOYlhvWWKiaNg3y1f/DvOK3Lv8+kxzpC30WgzVb cwROiguDH5jTfJy8tz49wtD9K16/wobS+yi7R8Vr+MygdbFoOLI8M+CWxHZT2+7q00zi mE8vlopACb9oPs5Dbo3gJnRctgBwxDaAa/GkHPMzf/leV83jMkXwU1OdLzzvXZYyMchd 8hAlPhLXEJn+EWapmKTr8nc29cxFeUiALiYWOl3sxGc88pRQEZy1ByMiGFcoPb/FY6ni 7ZMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=WbNC07VGnJucfMQdaVru/HWxeCTMcNM6hFkgQ/MCeFU=; b=IntlrJxtKu7BM9qPsb+hJo3IpC7p2DXO7a7T7aztAjGXl9uxy0G7o05wgQw7S7a4ig 6EDD/zBcM7X6LpG0NhBzpkIEToX02AulenQ3RBUvBXxNAETWzs0RbIep/MkbFKp+g+Qt IBXzEqSWxl7/grSpKutL/9CnZRQDuNNNSVGB4TxaMcs7uE/WJFlxFasE307mSgtn/VVl c2OgdlSdmdaX1oAlFE7o6AloXqi/b2kPio8H97Mch4qNfKRbtEJ06y6ZbH+JLE2YWzbw IRmOER+wMoOQ9/FL6ZoHzrMt3d4KrjKa7+WkrxN1gUnNck0pvRwKgFESDY6rLIkBsS2i sb6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PUv9MA0n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ls7-20020a17090b350700b0023369af18e2si113376pjb.72.2023.03.30.12.20.24; Thu, 30 Mar 2023 12:20:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PUv9MA0n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231765AbjC3TTJ (ORCPT + 99 others); Thu, 30 Mar 2023 15:19:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232224AbjC3TSj (ORCPT ); Thu, 30 Mar 2023 15:18:39 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A235410259 for ; Thu, 30 Mar 2023 12:18:19 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-536a4eba107so199127387b3.19 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=tOz4v1yYLzEzlMUzAOAqarTvkyysRXrn0DkGvLvp4KsUJr4a/lEUlPuJedGq3A20tM CiuupulDq9kngdFtAzoxMM0eyxrBhGkv5ysL6aNiTZ0ZbBrbjeiCM7HiJ54hHGcZtmT8 LQnuhEkJP2+EBtDfWigvgggk7eUOErqAN59o1cjz5YSqtI68WTAL8V5e4O0OU1vJN5tl EwITSFyH/yhFxpPb4Q8ssxYUjOY+GriuZu2a6o4ULD9PU1X7DRS8O93MFVCzsufHl0Pc zjVQVD411ndepVqoywEzhs8UugxWVuC1SutfpXE7xhwOQpodwgCMVevHkpyb87UaAL9b M3ww== X-Gm-Message-State: AAQBX9et5wStuWm3CuZTeLGVkKBnQZBieK+t2HHniP39sCUteQz+HErZ RTL7dJvsFZOFA5UksfMRppNBAuWMefl/yiFq 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=20Koutn=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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)); -- 2.40.0.348.gf938b09366-goog