From patchwork Thu Sep 21 08:10:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13393757 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 1ABD9E706E3 for ; Thu, 21 Sep 2023 08:11:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81D196B0188; Thu, 21 Sep 2023 04:11:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CD146B018A; Thu, 21 Sep 2023 04:11:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E3766B0192; Thu, 21 Sep 2023 04:11:04 -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 5D2176B0188 for ; Thu, 21 Sep 2023 04:11:04 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 34242A103E for ; Thu, 21 Sep 2023 08:11:04 +0000 (UTC) X-FDA: 81259884048.26.65383B5 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf18.hostedemail.com (Postfix) with ESMTP id 831AD1C0022 for ; Thu, 21 Sep 2023 08:11:02 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=QF0gjeq+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf18.hostedemail.com: domain of 3lfoLZQoKCOgiYcbiKRWONQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--yosryahmed.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3lfoLZQoKCOgiYcbiKRWONQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--yosryahmed.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695283862; 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: references:dkim-signature; bh=mOW1s/LOhiEKmGFQGGQ/gb7iNiCsFWbcKv8d4ZT/dpI=; b=HBTEwERXeRjkwe6NNCd308Oyp45pADHvJlTCc+vSeyw5qvP7UIxsFkKXduQNFe4mP/AM52 lRyhP0/aGC/7JLCDfBsZO9OQfUDULrmXamQtKyy+hu9N7kaIHXTf2Y11CT9Xrfouc/sD/j BsdQ1jhz1fOD6TTbsqen3H/1Jr0tRNo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=QF0gjeq+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf18.hostedemail.com: domain of 3lfoLZQoKCOgiYcbiKRWONQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--yosryahmed.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3lfoLZQoKCOgiYcbiKRWONQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--yosryahmed.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695283862; a=rsa-sha256; cv=none; b=Vp4ifcrGz10OpzleLM4PV7AtV/HW5vRRakl/MqSgfBTdTgWpEL/ONb3m5oPmIAqRYKR/Vz WwatRy0wKWyGTCobEvg7Jp7XFXsg+NhpsURfMFttrRaRzezFE1zSq/EtVHZcTz8BLtXFKN pXPJkHqKplyJVEL8Bz6GuSSfiE8/t5Y= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-59bee08c13aso9814947b3.0 for ; Thu, 21 Sep 2023 01:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695283861; x=1695888661; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=mOW1s/LOhiEKmGFQGGQ/gb7iNiCsFWbcKv8d4ZT/dpI=; b=QF0gjeq+Ye9ZC6Bo/cWPcdILKRnie8tIvAiWlrEigg8MHmkCKDey1sm9QvQfAbbd8Q SeHE6ZWBRH5lQ8dJBC580G71VF3h3soSqcQI7F2DCdEe8eSwarr4rPobW4cgq45P1aFi Y+HzOLMi6kkJuam2gYCVI+Q4+VRymZNNsHMwJIVT18sX0wIlJ2xVuGLcxHrrCinJ1CDi vMpJpEKPYkxe4vFdrcdXteg2He71dVrV/Zf7HwTZMHmuegxblcSHn8JPoNTCiPvTq9Fq JaY8lViHU/wPAVnAv9i5dThR+6SyNcxtPVlly4Sxb4eKoxhaltnYYHRaobFGxQEPKhwM b8mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695283861; x=1695888661; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=mOW1s/LOhiEKmGFQGGQ/gb7iNiCsFWbcKv8d4ZT/dpI=; b=Ch5tg3wZ/oBFqFp/LKkXg6/FScWAc0r/9WgAqGNCPigKg9Y0mHd0rL3szlxpWFU/b8 P73WcHKPy3qsEWo9eDGft+gHw129/E5aHl8hmGDYBzOXXM2WrbVNWsYuJP2aXWf0ForT fvalcmOU797TbVzcD0s5Yr4CpMff0mFPbkC+0h2HukOpf5FTd5D/7ZM5VGAnoiv5JPMJ LLepQpspcyBKW+EUnIo8CXSUAPak36nQJgVUELC7cIHmVLL5QOBoMSSe0CPfd+RBy4zX YBYlOPKu2A7CzIhY31MIoftRc54opliL33925vclbalIZG3GO7oeNZ6crMjf+uGZLotX xYKA== X-Gm-Message-State: AOJu0YwVvHaSvMMhgbM3l6Nq3iPIkVIzFEkeDbbbI9PDf/YxRKUpTsQO EXOim8wiZvwfz9UdcUfDudbqC4CJ/iS9Ku3L X-Google-Smtp-Source: AGHT+IFTPKV8hb5qPNKFt3PlKNQhm1PDDliL803lQAuNf6oYVsKA/DfLdwy4CO7/lb7z+piXyQB3c4gswMGqoV1s X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a81:ae59:0:b0:59b:ebe0:9fcd with SMTP id g25-20020a81ae59000000b0059bebe09fcdmr73922ywk.7.1695283861434; Thu, 21 Sep 2023 01:11:01 -0700 (PDT) Date: Thu, 21 Sep 2023 08:10:52 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230921081057.3440885-1-yosryahmed@google.com> Subject: [PATCH 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_Koutn=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 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 831AD1C0022 X-Stat-Signature: mbgx6mktg5ie5odfnn5r6zp9cygq5u6a X-Rspam-User: X-HE-Tag: 1695283862-202457 X-HE-Meta: U2FsdGVkX18IJSoNP8tuhh+w+IsTK1MeQSSa7LfSng07PBD0iJL/dC7mGq4XWVin+Eq+F7INHJvX505XwKx/U429gzdHhiDQUzAs5WXgioeIMrgxmcM7ds/qD9syG1LNf4JRw3ChIS59ijG/X9TWjt5gslnI5h98mnxqxaEvIcN3VBMbYKz1YgLHfFvdxmOLvhgQaZIA0YuxgMEXRVq17Rc6g2Tbw9uO0s0JD75Vs78Am1539TfzpHi51KtsYhi6bKVrEeOs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zhq0IzkoWHLodeN331N9lFYNsT7vnNw4owu7CTrIPIw9psSAH77S0RqrvJXk1nHE6HyzZOEQMREuyniz378WRwGFXmcGVEpU8pkRQjI/7AO/v/DAQBME0jW1KN/CN2i0VLXtfW60Ms736l+br7S47t/ppyNhBHqttbMZgLU/mAf5l1mMfFop1kcrpT6aiDU3QPUIH+HrqLN47GbePvQCN/oFwvEW9P0/YKWfr9BydfzvWE/ZE7RrOEjokpbj9SeVM2vHWD08VADYOZZvVdKWQrpmyNzHgEAB7KY7JI/ViGtr3XrIf/PUzbdx7AAEe/xxCiuI3+djYY3WQC9YDs2tSu5jia X-Bogosity: Ham, tests=bogofilter, spamicity=0.000096, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 v2 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/ 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 | 37 +++-- 4 files changed, 181 insertions(+), 135 deletions(-)