Message ID | 20230330191801.1967435-9-yosryahmed@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp82099vqo; Thu, 30 Mar 2023 12:22:12 -0700 (PDT) X-Google-Smtp-Source: AKy350abZOc65Vl+j0v34uqQqtw2zzzuwb8YLJY0zx6lyuU4RtEuN2QU252tpLHHgeiRtzJCAtF9 X-Received: by 2002:a17:90b:388e:b0:23f:7d05:8762 with SMTP id mu14-20020a17090b388e00b0023f7d058762mr25928598pjb.23.1680204132127; Thu, 30 Mar 2023 12:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680204132; cv=none; d=google.com; s=arc-20160816; b=0GDsUi5bhQKLGD1eyUAMSRF8KtAzOJH1wv1UA7rDrD/9u/8/Xkcz/Qb85mx7gDwZss Se64cownAeD+3m9e9myaxmt6fGn4mBx5r8oRrUBaMQKXfqtex7bWH9sunCgn5UDQnqU5 LbNzQU+rhJQfNhvVJ9SJG+T5N9D6VHEiv9PWHXEvsrtsIZ79y020i+iUnNsFbUjq+0zL /iVfTQ8pso5/08fF22pQxUHEP4glPbocdPK/bm/0RfanspBTanh4YpkG0qeOzzlUQaZO IHtn8xNCeQco7GfiiB9KX8BTud9dxSVtZRoIIwLBJJEGwzv3rYmXooCDmCCDpupvNYWO XuAA== 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 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.21.58; Thu, 30 Mar 2023 12:22:12 -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 S231876AbjC3TTJ (ORCPT <rfc822;rua109.linux@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; Thu, 30 Mar 2023 12:18:19 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-536a4eba107so199127387b3.19 for <linux-kernel@vger.kernel.org>; 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 <yosryahmed@google.com> To: Tejun Heo <tj@kernel.org>, Josef Bacik <josef@toxicpanda.com>, Jens Axboe <axboe@kernel.dk>, Zefan Li <lizefan.x@bytedance.com>, Johannes Weiner <hannes@cmpxchg.org>, Michal Hocko <mhocko@kernel.org>, Roman Gushchin <roman.gushchin@linux.dev>, Shakeel Butt <shakeelb@google.com>, Muchun Song <muchun.song@linux.dev>, Andrew Morton <akpm@linux-foundation.org>, " =?utf-8?q?Michal_Koutn=C3=BD?= " <mkoutny@suse.com> Cc: Vasily Averin <vasily.averin@linux.dev>, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, Yosry Ahmed <yosryahmed@google.com>, Michal Hocko <mhocko@suse.com> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761821728258293069?= X-GMAIL-MSGID: =?utf-8?q?1761821728258293069?= |
Series |
memcg: avoid flushing stats atomically where possible
|
|
Commit Message
Yosry Ahmed
March 30, 2023, 7:18 p.m. UTC
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 <yosryahmed@google.com> Acked-by: Shakeel Butt <shakeelb@google.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Michal Hocko <mhocko@suse.com> --- mm/memcontrol.c | 3 +++ 1 file changed, 3 insertions(+)
Comments
On Thu, Mar 30, 2023 at 07:18:01PM +0000, Yosry Ahmed <yosryahmed@google.com> wrote: > mm/memcontrol.c | 3 +++ > 1 file changed, 3 insertions(+) Reviewed-by: Michal Koutný <mkoutny@suse.com>
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));