From: Yosry Ahmed <yosryahmed@google.com>
To: JP Kobryn <inwardvessel@gmail.com>
Cc: shakeel.butt@linux.dev, hannes@cmpxchg.org,
akpm@linux-foundation.org, rostedt@goodmis.org,
linux-mm@kvack.org, cgroups@vger.kernel.org
Subject: Re: [PATCH 1/2 v3] memcg: rename do_flush_stats and add force flag
Date: Mon, 28 Oct 2024 19:43:04 -0700 [thread overview]
Message-ID: <CAJD7tkZo0oAh1L7OVGZkLi+EDw0pjQ8dpsC1oQbLQS6KNvymKw@mail.gmail.com> (raw)
In-Reply-To: <20241029021106.25587-2-inwardvessel@gmail.com>
On Mon, Oct 28, 2024 at 7:11 PM JP Kobryn <inwardvessel@gmail.com> wrote:
>
> Change the name to something more consistent with others in the file and
> use double unders to signify it is associated with the
> mem_cgroup_flush_stats() API call. Additionally include a new flag that
> call sites use to indicate a forced flush; skipping checks and flushing
> unconditionally. There are no changes in functionality.
>
> Signed-off-by: JP Kobryn <inwardvessel@gmail.com>
Reviewed-by: Yosry Ahmed <yosryahmed@google.com>
> ---
> mm/memcontrol.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 18c3f513d766..59f6f247fc13 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -588,8 +588,11 @@ static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val)
> }
> }
>
> -static void do_flush_stats(struct mem_cgroup *memcg)
> +static void __mem_cgroup_flush_stats(struct mem_cgroup *memcg, bool force)
> {
> + if (!force && !memcg_vmstats_needs_flush(memcg->vmstats))
> + return;
> +
> if (mem_cgroup_is_root(memcg))
> WRITE_ONCE(flush_last_time, jiffies_64);
>
> @@ -613,8 +616,7 @@ void mem_cgroup_flush_stats(struct mem_cgroup *memcg)
> if (!memcg)
> memcg = root_mem_cgroup;
>
> - if (memcg_vmstats_needs_flush(memcg->vmstats))
> - do_flush_stats(memcg);
> + __mem_cgroup_flush_stats(memcg, false);
> }
>
> void mem_cgroup_flush_stats_ratelimited(struct mem_cgroup *memcg)
> @@ -630,7 +632,7 @@ static void flush_memcg_stats_dwork(struct work_struct *w)
> * Deliberately ignore memcg_vmstats_needs_flush() here so that flushing
> * in latency-sensitive paths is as cheap as possible.
> */
> - do_flush_stats(root_mem_cgroup);
> + __mem_cgroup_flush_stats(root_mem_cgroup, true);
> queue_delayed_work(system_unbound_wq, &stats_flush_dwork, FLUSH_TIME);
> }
>
> @@ -5281,11 +5283,8 @@ bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)
> break;
> }
>
> - /*
> - * mem_cgroup_flush_stats() ignores small changes. Use
> - * do_flush_stats() directly to get accurate stats for charging.
> - */
> - do_flush_stats(memcg);
> + /* Force flush to get accurate stats for charging */
> + __mem_cgroup_flush_stats(memcg, true);
> pages = memcg_page_state(memcg, MEMCG_ZSWAP_B) / PAGE_SIZE;
> if (pages < max)
> continue;
> --
> 2.47.0
>
next prev parent reply other threads:[~2024-10-29 2:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-29 2:11 [PATCH 0/2 v3] memcg: tracepoint for flushing stats JP Kobryn
2024-10-29 2:11 ` [PATCH 1/2 v3] memcg: rename do_flush_stats and add force flag JP Kobryn
2024-10-29 2:43 ` Yosry Ahmed [this message]
2024-10-29 5:25 ` Shakeel Butt
2024-10-29 2:11 ` [PATCH 2/2 v3] memcg: add flush tracepoint JP Kobryn
2024-10-29 2:44 ` Yosry Ahmed
2024-10-29 5:27 ` Shakeel Butt
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=CAJD7tkZo0oAh1L7OVGZkLi+EDw0pjQ8dpsC1oQbLQS6KNvymKw@mail.gmail.com \
--to=yosryahmed@google.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=inwardvessel@gmail.com \
--cc=linux-mm@kvack.org \
--cc=rostedt@goodmis.org \
--cc=shakeel.butt@linux.dev \
/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