Message ID | 20230830175335.1536008-4-yosryahmed@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 C1A95C83F01 for <linux-mm@archiver.kernel.org>; Wed, 30 Aug 2023 17:53:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF1F828005E; Wed, 30 Aug 2023 13:53:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E9EE028005A; Wed, 30 Aug 2023 13:53:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF09D28005E; Wed, 30 Aug 2023 13:53:49 -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 BC70628005A for <linux-mm@kvack.org>; Wed, 30 Aug 2023 13:53:49 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 91E6C1C9221 for <linux-mm@kvack.org>; Wed, 30 Aug 2023 17:53:49 +0000 (UTC) X-FDA: 81181518978.30.421C976 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf30.hostedemail.com (Postfix) with ESMTP id B923B8001F for <linux-mm@kvack.org>; Wed, 30 Aug 2023 17:53:47 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=mqmvWFet; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of 3KoLvZAoKCBsPFJIP18D547FF7C5.3FDC9ELO-DDBM13B.FI7@flex--yosryahmed.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3KoLvZAoKCBsPFJIP18D547FF7C5.3FDC9ELO-DDBM13B.FI7@flex--yosryahmed.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693418027; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dJkwDc7Wxmywu9Yo0ZIK2ppmyNcYkDsKDS48R26U4fo=; b=2yE+vAhIbmiN9njd3FgBmGo1XKqyAaZFKH0B4eiDv2urA4VcmQiC85vur+++lknEu0UoJy ntn8S+a/HliryT0LYiMJE5uCE5R35wHRNfa6YCYy/v4DD9iEmrIoqwl5pR0AUt8Lv/dohR YqX4qNts/NTmtvX07fe0GtoOVUvaHG8= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=mqmvWFet; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of 3KoLvZAoKCBsPFJIP18D547FF7C5.3FDC9ELO-DDBM13B.FI7@flex--yosryahmed.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3KoLvZAoKCBsPFJIP18D547FF7C5.3FDC9ELO-DDBM13B.FI7@flex--yosryahmed.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693418027; a=rsa-sha256; cv=none; b=UZsZpjhiicgUCldKp4s1Bv2k7PMo+4QjIkpKl9znXRz6zIN49cHy+uUkVChr+moM5BE6l3 HOTCxlH4r8oX8vPTgE5e/51p0gHZWrMh98HSRaaoKbGChJ1jErnWvjzhXySEaHEzKb+Aei I17e7EQmILUERDhy0sVv0vmY+/FX7co= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-d7454a43541so6945969276.1 for <linux-mm@kvack.org>; Wed, 30 Aug 2023 10:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1693418027; x=1694022827; darn=kvack.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=dJkwDc7Wxmywu9Yo0ZIK2ppmyNcYkDsKDS48R26U4fo=; b=mqmvWFetNo6wNHYZKhe2MgjP4pr5CTas1cpwzuA9FxJyMJqztHb4UmSwACbQcxi6Be fqP62mNaHpZePYIvsvt4UBps4XoZG56cA1mXmTTvZim4ZyjtL6AlR8ipHex5QVGz1lwH lQi/uftCjPfs9ZqVVpjJqlmcGlh8s0ldCC9BLqorWJx8zXC3YSq/lit06TcYlZny8Fe5 i2xxQk4YmgyDaCTCKo/DOHYrP5PfpNru2bFlcQcJr5DklJekClb2U1FauD94YVxJX49D UNcIsMka26gsBvvSCc0zhs6K/Xtcvh6RvtgQTzpf+MspEzzdsK3BoaXL2SbvvMFnhNuS qTMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693418027; x=1694022827; h=content-transfer-encoding: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=dJkwDc7Wxmywu9Yo0ZIK2ppmyNcYkDsKDS48R26U4fo=; b=R3CUssrZqYI0rKpF9t3TkzO04x6mCCTr+gYFd1jF64aavR9bjHGxCkUzhre5YVLZq7 JWy7SudgWSJPw1JnzsF14k+prl36V0Mn+DDyCTF1ObAsjHBssNU2a/Gnzpc2zP8pdV4k a6Ki6YqMtii2Sq9TX5LvYAvPnWaD2MFDuB6xzTj3VN8eeuTXQWsBx8aUf+jSIOt6chvZ n5O6ZikcrlrlCWX5A4zwAUooMnY3ybKv6fHcWgMCxC/iCgk5EQrc2e+qjlZuH7U1FHYX vZd0cB6+kYlLCf1b/vzsBDtfRLF4933yZuz3FnLJIOYNNQ5o4I7vMIbi9kBTsy1gSe7n KViQ== X-Gm-Message-State: AOJu0YwVw5JTioON0GcNVuYpnVf6Iepqq7G5SKo6MGo5Jmzi40o9D9Se 6rZy7Dy+CQ6EHhPumX88YurxaxxAS8+yri5V X-Google-Smtp-Source: AGHT+IHXnF9jvMD/mtx9ACW7hIsA0mNc+2Mr0ZRpNzXABR3y52qvrgvfvPCgY3NH51AIMzA3Xb4AWwsKCWuq7vsA X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a25:e7d1:0:b0:d07:7001:495b with SMTP id e200-20020a25e7d1000000b00d077001495bmr79671ybh.11.1693418026898; Wed, 30 Aug 2023 10:53:46 -0700 (PDT) Date: Wed, 30 Aug 2023 17:53:34 +0000 In-Reply-To: <20230830175335.1536008-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20230830175335.1536008-1-yosryahmed@google.com> X-Mailer: git-send-email 2.42.0.rc2.253.gd59a3bf2b4-goog Message-ID: <20230830175335.1536008-4-yosryahmed@google.com> Subject: [PATCH v3 3/4] mm: memcg: let non-unified root stats flushes help unified flushes From: Yosry Ahmed <yosryahmed@google.com> To: Andrew Morton <akpm@linux-foundation.org> Cc: 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>, Ivan Babrou <ivan@cloudflare.com>, Tejun Heo <tj@kernel.org>, " =?utf-8?q?Michal_Koutn=C3=BD?= " <mkoutny@suse.com>, Waiman Long <longman@redhat.com>, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed <yosryahmed@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: B923B8001F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: q93dps83peo3zamwwsugsywtbp7oce4e X-HE-Tag: 1693418027-302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VEur0uJgReZqIXUS/4cnpnz0CjXRtLOKdxnwjrewnW1g0gawXOiRIXOEeUfjL0Wpe62FjUl+mDdTe+hF8PJ1wAcQ97DkuV+1zma9Zrgj+Lfjqv9TXIIl5ttOgUU8493U3slpBHbELnZ8q6h6K/DWiOpKds6Ue3nLmIfyx6R9uT8WGNOLCr0GvK6I+JzhXgXLEouxo143tcyR2RwyeHh3qSGE2CDPWUSv3jO9RawW0RYscbxfzedqWEYIxneBNvsu0HT87EMSdfIp8Q3k04f78hNL74oygok7Fua+VIUBYW2bJ90Bz9fN/GmuBufgZrkrj6iEe7f0kJmufu3tnaJeohIMjy9l8UOW97x3OH/LT3cPFy4LBPZvjf1ETVJeTzQG/3t9DAigrPi/TVrXCwYcNTgG+Mx6kHymAIFVWULIFHQVk027iPSSpJ1U6t1rMGezINpxQL059qZj8ItYw2uhWV24C3snywOFRY2P9PglPzjpU2/wkWJm1q4+k63VZK38+83s+j+4cVx7C6ycGONvw5Tt1Bpf0pUNM3IEPapwH1dLx6d/JezFeF4KP9bygL78M740uQY86zGA1gHKfooWzxw7kl4+7rMswT4BEWaHtLrZoFcAycNfQ37oZ6DF8= 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: <linux-mm.kvack.org> |
Series |
memcg: non-unified flushing for userspace stats
|
expand
|
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 8c046feeaae7..94d5a6751a9e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -647,6 +647,11 @@ static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val) */ static void do_stats_flush(struct mem_cgroup *memcg) { + /* for unified flushing, root non-unified flushing can help as well */ + if (mem_cgroup_is_root(memcg)) { + WRITE_ONCE(flush_next_time, jiffies_64 + 2*FLUSH_TIME); + atomic_set(&stats_flush_threshold, 0); + } cgroup_rstat_flush(memcg->css.cgroup); } @@ -665,11 +670,8 @@ static void do_unified_stats_flush(void) atomic_xchg(&stats_unified_flush_ongoing, 1)) return; - WRITE_ONCE(flush_next_time, jiffies_64 + 2*FLUSH_TIME); - do_stats_flush(root_mem_cgroup); - atomic_set(&stats_flush_threshold, 0); atomic_set(&stats_unified_flush_ongoing, 0); }
Unified flushing of memcg stats keeps track of the magnitude of pending updates, and only allows a flush if that magnitude exceeds a threshold. It also keeps track of the time at which ratelimited flushing should be allowed as flush_next_time. A non-unified flush on the root memcg has the same effect as a unified flush, so let it help unified flushing by resetting pending updates and kicking flush_next_time forward. Move the logic into the common do_stats_flush() helper, and do it for all root flushes, unified or not. There is a subtle change here, we reset stats_flush_threshold before a flush rather than after a flush. This probably okay because: (a) For flushers: only unified flushers check stats_flush_threshold, and those flushers skip anyway if there is another unified flush ongoing. Having them also skip if there is an ongoing non-unified root flush is actually more consistent. (b) For updaters: Resetting stats_flush_threshold early may lead to more atomic updates of stats_flush_threshold, as we start updating it earlier. This should not be significant in practice because we stop updating stats_flush_threshold when it reaches the threshold anyway. If we start early and stop early, the number of atomic updates remain the same. The only difference is the scenario where we reset stats_flush_threshold early, start doing atomic updates early, and then the periodic flusher kicks in before we reach the threshold. In this case, we will have done more atomic updates. However, since the threshold wasn't reached, then we did not do a lot of updates anyway. Suggested-by: Michal Koutný <mkoutny@suse.com> Signed-off-by: Yosry Ahmed <yosryahmed@google.com> --- mm/memcontrol.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)