From: Yosry Ahmed <yosryahmed@google.com>
To: Bagas Sanjaya <bagasdotme@gmail.com>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
"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>,
"Michal Koutný" <mkoutny@suse.com>,
"Waiman Long" <longman@redhat.com>,
kernel-team@cloudflare.com, "Wei Xu" <weixugc@google.com>,
"Greg Thelen" <gthelen@google.com>,
"Domenico Cerasuolo" <cerasuolodomenico@gmail.com>,
"Attreyee M" <tintinm2017@gmail.com>,
"Linux Memory Management List" <linux-mm@kvack.org>,
"Linux CGroups" <cgroups@vger.kernel.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: [mm-unstable v4 5/5] mm: memcg: restore subtree stats flushing
Date: Mon, 4 Dec 2023 11:51:29 -0800 [thread overview]
Message-ID: <CAJD7tkbk=AUfjuq+6HiPwNeoUi===h99rbJ2RkhN6dCk2E2xdg@mail.gmail.com> (raw)
In-Reply-To: <ZWqPBHCXz4nBIQFN@archie.me>
[..]
> > diff --git a/mm/workingset.c b/mm/workingset.c
> > index dce41577a49d2..7d3dacab8451a 100644
> > --- a/mm/workingset.c
> > +++ b/mm/workingset.c
> > @@ -464,8 +464,12 @@ bool workingset_test_recent(void *shadow, bool file, bool *workingset)
> >
> > rcu_read_unlock();
> >
> > - /* Flush stats (and potentially sleep) outside the RCU read section */
> > - mem_cgroup_flush_stats_ratelimited();
> > + /*
> > + * Flush stats (and potentially sleep) outside the RCU read section.
> > + * XXX: With per-memcg flushing and thresholding, is ratelimiting
> > + * still needed here?
> > + */
> > + mem_cgroup_flush_stats_ratelimited(eviction_memcg);
>
> What if flushing is not rate-limited (e.g. above line is commented)?
>
Hmm I think I might be misunderstanding the question. The call to
mem_cgroup_flush_stats_ratelimited() does not ratelimit other
flushers, it is rather a flush call that is itself ratelimited. IOW,
it may or may not flush based on when was the last time someone else
flushed.
This was introduced because flushing in the fault path was expensive
in some cases, so we wanted to avoid flushing if someone else recently
did a flush, as we don't expect a lot of pending changes in this case.
However, that was when flushing was always on the root level. Now that
we are flushing on the memcg level, it may no longer be needed as:
- The flush is more scoped, there should be less work to do.
- There is a per-memcg threshold now such that we only flush when
there are pending updates in this memcg.
This is why I added a comment that the ratelimited flush here may no
longer be needed. I didn't want to investigate this as part of this
series, especially that I do not have a reproducer for the fault
latency introduced by the flush before ratelimiting. Hence, I am
leaving the comment such that people know that this ratelimiting may
no longer be needed with this patch.
> >
> > eviction_lruvec = mem_cgroup_lruvec(eviction_memcg, pgdat);
> > refault = atomic_long_read(&eviction_lruvec->nonresident_age);
> > @@ -676,7 +680,7 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker,
> > struct lruvec *lruvec;
> > int i;
> >
> > - mem_cgroup_flush_stats();
> > + mem_cgroup_flush_stats(sc->memcg);
> > lruvec = mem_cgroup_lruvec(sc->memcg, NODE_DATA(sc->nid));
> > for (pages = 0, i = 0; i < NR_LRU_LISTS; i++)
> > pages += lruvec_page_state_local(lruvec,
>
> Confused...
Which part is confusing? The call to mem_cgroup_flush_stats() now
receives a memcg argument as flushing is scoped to that memcg only to
avoid doing unnecessary work to flush other memcgs with global
flushing.
next prev parent reply other threads:[~2023-12-04 19:52 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 3:21 [mm-unstable v4 0/5] mm: memcg: subtree stats flushing and thresholds Yosry Ahmed
2023-11-29 3:21 ` [mm-unstable v4 1/5] mm: memcg: change flush_next_time to flush_last_time Yosry Ahmed
2023-11-29 3:21 ` [mm-unstable v4 2/5] mm: memcg: move vmstats structs definition above flushing code Yosry Ahmed
2023-11-29 3:21 ` [mm-unstable v4 3/5] mm: memcg: make stats flushing threshold per-memcg Yosry Ahmed
2023-12-02 7:48 ` Shakeel Butt
2023-11-29 3:21 ` [mm-unstable v4 4/5] mm: workingset: move the stats flush into workingset_test_recent() Yosry Ahmed
2023-12-02 8:07 ` Shakeel Butt
2023-11-29 3:21 ` [mm-unstable v4 5/5] mm: memcg: restore subtree stats flushing Yosry Ahmed
2023-12-02 1:57 ` Bagas Sanjaya
2023-12-02 2:56 ` Waiman Long
2023-12-02 5:53 ` Bagas Sanjaya
2023-12-04 19:51 ` Yosry Ahmed [this message]
2023-12-02 8:31 ` Shakeel Butt
2023-12-04 20:12 ` Yosry Ahmed
2023-12-04 21:37 ` Yosry Ahmed
2023-12-04 23:31 ` Shakeel Butt
2023-12-04 23:46 ` Wei Xu
2023-12-04 23:49 ` Yosry Ahmed
2023-12-04 23:58 ` Shakeel Butt
2023-12-12 18:43 ` Andrew Morton
2023-12-12 19:11 ` Shakeel Butt
2023-12-12 20:44 ` Yosry Ahmed
2023-12-02 4:51 ` [mm-unstable v4 0/5] mm: memcg: subtree stats flushing and thresholds Bagas Sanjaya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJD7tkbk=AUfjuq+6HiPwNeoUi===h99rbJ2RkhN6dCk2E2xdg@mail.gmail.com' \
--to=yosryahmed@google.com \
--cc=akpm@linux-foundation.org \
--cc=bagasdotme@gmail.com \
--cc=cerasuolodomenico@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=gthelen@google.com \
--cc=hannes@cmpxchg.org \
--cc=ivan@cloudflare.com \
--cc=kernel-team@cloudflare.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=longman@redhat.com \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=tintinm2017@gmail.com \
--cc=tj@kernel.org \
--cc=weixugc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox