Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2264482rdb; Mon, 9 Oct 2023 20:21:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEA5NinNXYsgZwA12g4tpOKWlKFEJRZH+55yWJD4LmVrvVv5pqTl3dmg55J9ThWiIwfpwMp X-Received: by 2002:a05:6870:e6d3:b0:1dc:bccf:b840 with SMTP id s19-20020a056870e6d300b001dcbccfb840mr20432427oak.32.1696908092244; Mon, 09 Oct 2023 20:21:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696908092; cv=none; d=google.com; s=arc-20160816; b=heEN4gLMuNTbDOaXXSUFT7to6CTjSfjYdSI1+njMg5io+nLNDn7rnAeedgQHTi3y3A Me2usv9PWoqdAdaEopP43PR2ZlzoW4ssC02kWwdK2STiOYd+07390uFHG92kDws5Q+xm xh6EkaVNnWD1tidsvbZ0qgVGb+ov4CsG51V1qisvUExU0wugWUZBLBpPdjyo0WuSBe4p hdfDoH1ntqCT5VEFN/dUAqtvY8d6zBYQrohNsQukLWjv8Yo6fFW3LV9f3LvQzoWVw04c 6AbK1z9tRL37ZOcEqFgE3H5tq1HrquIOaZxruwMeiMIyXbNTgJIA3U7N/H4jPDhEt/GC 6Hng== 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:mime-version:date :dkim-signature; bh=LVnT/y0R3LkPemDBgYVR7UpcgonMc+8VI5Wxeio9uFU=; fh=i6r7D8Tbv5L0V2RUiJXfGU+sNI1eFV0UjCNL0oNyQ80=; b=bby/oE3XcggZeJITpjsil5083V7/gxQNsThsPQbuWx+kM4WixRALf/WvU/PP/wK7rf HTzE0P9p1PcGzm7HJFpomrKcqXzN4SmEsWUihY+RyVeZlJ/uEFLvoNBl30Q2azuSz7EL 4k6TIVVunsDVELimRhFoEYk473jOe4xt9QzReFr+y08K5k34EoONmue+YbDnvrXpNfdr /aQ+bH1d44UzUGQ6WKAC/WV8td7TfWxeDi95C29q9V8MYeM+04EnPyPO0W8dwLp3BrBS 6vcDXutOcD3BonpSLnUPrIzIMHsFmHodYl++oX7TJwFH+vP5UszocpnY1/CzBV2qax/D ud4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DDTplump; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x186-20020a6386c3000000b00565db2812a0si11057035pgd.60.2023.10.09.20.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 20:21:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DDTplump; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B2536810C2C9; Mon, 9 Oct 2023 20:21:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441961AbjJJDVY (ORCPT + 99 others); Mon, 9 Oct 2023 23:21:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441955AbjJJDVX (ORCPT ); Mon, 9 Oct 2023 23:21:23 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E3F3A9 for ; Mon, 9 Oct 2023 20:21:21 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d86dac81f8fso7274050276.1 for ; Mon, 09 Oct 2023 20:21:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696908080; x=1697512880; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=LVnT/y0R3LkPemDBgYVR7UpcgonMc+8VI5Wxeio9uFU=; b=DDTplumpkAsBSj1wMFy7c5Xu/eZeK5L0WE3BWXEU28l0WQd47bh3gcVt10frS5ivf8 6SWIQGCMxwhkKXqxqoGm/qEHOc5Zk92HRTFUCMriOJ1AeA9S0JsAaOWDLfFDFLwX20sm fEFVjrM0vcfrGmc5byB+8lABCIGIZk5hkYS1YyccWEOmwplr8fAQUzzbcK7cTFzKzh6b 4cd3rdsu8qVwWbqh68IvFEmQE52P663uguBjWBYM7kSWRb965vR/VtUZtbnKgu2FlAoP jCdpnsvdD1Z0CAKlOXwb5v4qEZFGNWBBcDR5eXv0hDxLmVnpilYbSEPbgwusEXGsn3LB 2g4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696908080; x=1697512880; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=LVnT/y0R3LkPemDBgYVR7UpcgonMc+8VI5Wxeio9uFU=; b=c3K/RfOWt+psHrsAYoUUM14TgHQSX6jsNMkHrdNe1nkm13UCs9woO3xLD2W+Leu6En zwR2i8Gwo15ejRq/IgJYakHbW3nhGMFVdK1XzDqiht6z7tKybvC9cWSHhyBiG31yA7Ql jgs/SOef8prEB3aNxqz0EAeoCYEV+589KtCGOKDqh1k0SfoIfEEMHuAVkzoB/Y0FhN1S 7fakLYSIiT5M+qFe0X5qcl3dIRrmvy19LuulYEH2PwBGlTBjXCcrlZtgoGab0+xsXRKk 85pp31M2zhBoLUsKPCY6unqMnSTt88mo5lB7zmo+UIEMuxoMeRI9YazINYAOJtlGXkZU hvsg== X-Gm-Message-State: AOJu0YxPbdZevP03xxgzJUUjiBra4e5DjIrWOAdolVoky9YrVcSdIbZ2 Ljh7T7vKI4FYQV14bSWVP5TxMCkbs/8AUGBs X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:212:b0:d89:b072:d06f with SMTP id j18-20020a056902021200b00d89b072d06fmr265146ybs.7.1696908080471; Mon, 09 Oct 2023 20:21:20 -0700 (PDT) Date: Tue, 10 Oct 2023 03:21:11 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Message-ID: <20231010032117.1577496-1-yosryahmed@google.com> Subject: [PATCH v2 0/5] mm: memcg: subtree stats flushing and thresholds From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Ivan Babrou , Tejun Heo , "=?UTF-8?q?Michal=20Koutn=C3=BD?=" , Waiman Long , kernel-team@cloudflare.com, Wei Xu , Greg Thelen , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 09 Oct 2023 20:21:30 -0700 (PDT) This series attempts to address shortages in today's approach for memcg stats flushing, namely occasionally stale or expensive stat reads. The series does so by changing the threshold that we use to decide whether to trigger a flush to be per memcg instead of global (patch 3), and then changing flushing to be per memcg (i.e. subtree flushes) instead of global (patch 5). Patch 3 & 5 are the core of the series, and they include more details and testing results. The rest are either cleanups or prep work. This series replaces the "memcg: more sophisticated stats flushing" series [1], which also replaces another series, in a long list of attempts to improve memcg stats flushing. It is not a new version of the same patchset as it is a completely different approach. This is based on collected feedback from discussions on lkml in all previous attempts. Hopefully, this is the final attempt. [1]https://lore.kernel.org/lkml/20230913073846.1528938-1-yosryahmed@google.com/ v1 -> v2: - Fixed compilation error reported by the kernel robot in patch 4, also added a missing rcu_read_unlock(). - More testing results in the commit message of patch 3. Yosry Ahmed (5): mm: memcg: change flush_next_time to flush_last_time mm: memcg: move vmstats structs definition above flushing code mm: memcg: make stats flushing threshold per-memcg mm: workingset: move the stats flush into workingset_test_recent() mm: memcg: restore subtree stats flushing include/linux/memcontrol.h | 8 +- mm/memcontrol.c | 269 +++++++++++++++++++++---------------- mm/vmscan.c | 2 +- mm/workingset.c | 42 ++++-- 4 files changed, 185 insertions(+), 136 deletions(-) -- 2.42.0.609.gbb76f46606-goog