From: Michal Hocko <mhocko-IBi9RG/b67k@public.gmane.org>
To: Yosry Ahmed <yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: "Andrew Morton"
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
"Johannes Weiner"
<hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>,
"Roman Gushchin"
<roman.gushchin-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>,
"Shakeel Butt" <shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
"Muchun Song"
<muchun.song-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>,
"Ivan Babrou" <ivan-lDpJ742SOEtZroRs9YW3xA@public.gmane.org>,
"Tejun Heo" <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"Michal Koutný" <mkoutny-IBi9RG/b67k@public.gmane.org>,
"Waiman Long" <longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v4 2/4] mm: memcg: add a helper for non-unified stats flushing
Date: Mon, 4 Sep 2023 16:45:14 +0200 [thread overview]
Message-ID: <ZPXtejIUIKg/IyZ6@dhcp22.suse.cz> (raw)
In-Reply-To: <20230831165611.2610118-3-yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
On Thu 31-08-23 16:56:09, Yosry Ahmed wrote:
> Some contexts flush memcg stats outside of unified flushing, directly
> using cgroup_rstat_flush(). Add a helper for non-unified flushing, a
> counterpart for do_unified_stats_flush(), and use it in those contexts,
> as well as in do_unified_stats_flush() itself.
>
> This abstracts the rstat API and makes it easy to introduce
> modifications to either unified or non-unified flushing functions
> without changing callers.
>
> No functional change intended.
>
> Signed-off-by: Yosry Ahmed <yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Acked-by: Michal Hocko <mhocko-IBi9RG/b67k@public.gmane.org>
> ---
> mm/memcontrol.c | 21 +++++++++++++++++----
> 1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 2d0ec828a1c4..8c046feeaae7 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -639,6 +639,17 @@ static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val)
> }
> }
>
> +/*
> + * do_stats_flush - do a flush of the memory cgroup statistics
> + * @memcg: memory cgroup to flush
> + *
> + * Only flushes the subtree of @memcg, does not skip under any conditions.
> + */
> +static void do_stats_flush(struct mem_cgroup *memcg)
> +{
> + cgroup_rstat_flush(memcg->css.cgroup);
> +}
> +
> /*
> * do_unified_stats_flush - do a unified flush of memory cgroup statistics
> *
> @@ -656,7 +667,7 @@ static void do_unified_stats_flush(void)
>
> WRITE_ONCE(flush_next_time, jiffies_64 + 2*FLUSH_TIME);
>
> - cgroup_rstat_flush(root_mem_cgroup->css.cgroup);
> + do_stats_flush(root_mem_cgroup);
>
> atomic_set(&stats_flush_threshold, 0);
> atomic_set(&stats_unified_flush_ongoing, 0);
> @@ -7790,7 +7801,7 @@ bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)
> break;
> }
>
> - cgroup_rstat_flush(memcg->css.cgroup);
> + do_stats_flush(memcg);
> pages = memcg_page_state(memcg, MEMCG_ZSWAP_B) / PAGE_SIZE;
> if (pages < max)
> continue;
> @@ -7855,8 +7866,10 @@ void obj_cgroup_uncharge_zswap(struct obj_cgroup *objcg, size_t size)
> static u64 zswap_current_read(struct cgroup_subsys_state *css,
> struct cftype *cft)
> {
> - cgroup_rstat_flush(css->cgroup);
> - return memcg_page_state(mem_cgroup_from_css(css), MEMCG_ZSWAP_B);
> + struct mem_cgroup *memcg = mem_cgroup_from_css(css);
> +
> + do_stats_flush(memcg);
> + return memcg_page_state(memcg, MEMCG_ZSWAP_B);
> }
>
> static int zswap_max_show(struct seq_file *m, void *v)
> --
> 2.42.0.rc2.253.gd59a3bf2b4-goog
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2023-09-04 14:45 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-31 16:56 [PATCH v4 0/4] memcg: non-unified flushing for userspace stats Yosry Ahmed
2023-08-31 16:56 ` [PATCH v4 1/4] mm: memcg: properly name and document unified stats flushing Yosry Ahmed
[not found] ` <20230831165611.2610118-2-yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2023-09-04 14:44 ` Michal Hocko
[not found] ` <ZPXtVLNIXk8trj2k-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2023-09-05 15:55 ` Yosry Ahmed
2023-08-31 16:56 ` [PATCH v4 3/4] mm: memcg: let non-unified root stats flushes help unified flushes Yosry Ahmed
2023-09-04 14:50 ` Michal Hocko
[not found] ` <ZPXupwjewuLgksAI-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2023-09-04 15:29 ` Michal Koutný
2023-09-04 15:41 ` Michal Hocko
[not found] ` <ZPX6luPGqypp68+L-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2023-09-05 14:10 ` Michal Koutný
2023-09-05 15:54 ` Yosry Ahmed
[not found] ` <CAJD7tkaHVtMiMYFocNiABuyhPcqt77gei0UeaDq4J7V-=tMFYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-09-05 16:07 ` Michal Koutný
2023-09-12 11:03 ` Michal Hocko
[not found] ` <20230831165611.2610118-1-yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2023-08-31 16:56 ` [PATCH v4 2/4] mm: memcg: add a helper for non-unified stats flushing Yosry Ahmed
[not found] ` <20230831165611.2610118-3-yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2023-09-04 14:45 ` Michal Hocko [this message]
2023-08-31 16:56 ` [PATCH v4 4/4] mm: memcg: use non-unified stats flushing for userspace reads Yosry Ahmed
[not found] ` <20230831165611.2610118-5-yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2023-09-04 15:15 ` Michal Hocko
[not found] ` <ZPX0kCKd4TaVLJY7-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2023-09-05 15:57 ` Yosry Ahmed
2023-09-08 0:52 ` Wei Xu
[not found] ` <CAAPL-u9D2b=iF5Lf_cRnKxUfkiEe0AMDTu6yhrUAzX0b6a6rDg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-09-08 1:02 ` Ivan Babrou
[not found] ` <CABWYdi1WNp9f20nRFEExn8QB1MwP7QXwvD6Q8xHHuTO2SUTLkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-09-08 1:11 ` Yosry Ahmed
2023-09-11 13:11 ` Michal Hocko
2023-09-11 19:15 ` Wei Xu
2023-09-11 19:34 ` Michal Hocko
2023-09-11 20:01 ` Wei Xu
2023-09-11 20:21 ` Tejun Heo
2023-09-11 20:28 ` Yosry Ahmed
[not found] ` <ZP92xP5rdKdeps7Z-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2023-09-12 11:03 ` Michal Hocko
[not found] ` <ZQBFZMRL8WmqRgrM-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2023-09-12 11:09 ` Yosry Ahmed
2023-08-31 17:18 ` [PATCH v4 0/4] memcg: non-unified flushing for userspace stats Waiman Long
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=ZPXtejIUIKg/IyZ6@dhcp22.suse.cz \
--to=mhocko-ibi9rg/b67k@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=ivan-lDpJ742SOEtZroRs9YW3xA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=mkoutny-IBi9RG/b67k@public.gmane.org \
--cc=muchun.song-fxUVXftIFDnyG1zEObXtfA@public.gmane.org \
--cc=roman.gushchin-fxUVXftIFDnyG1zEObXtfA@public.gmane.org \
--cc=shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
/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