From: Shakeel Butt <shakeel.butt@linux.dev>
To: Nhat Pham <nphamcs@gmail.com>
Cc: Jesper Dangaard Brouer <hawk@kernel.org>,
Yosry Ahmed <yosryahmed@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Muchun Song <muchun.song@linux.dev>, Yu Zhao <yuzhao@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Meta kernel team <kernel-team@meta.com>,
cgroups@vger.kernel.org
Subject: Re: [PATCH v2] memcg: use ratelimited stats flush in the reclaim
Date: Wed, 14 Aug 2024 16:42:31 -0700 [thread overview]
Message-ID: <5psrsuvzabh2gwj7lmf6p2swgw4d4svi2zqr4p6bmmfjodspcw@fexbskbtchs7> (raw)
In-Reply-To: <CAKEwX=Mc9U_eEqoEYtwdfOUZTa=gboLtbF5FGy4pL--A54JJDw@mail.gmail.com>
On Wed, Aug 14, 2024 at 04:03:13PM GMT, Nhat Pham wrote:
> On Wed, Aug 14, 2024 at 9:32 AM Shakeel Butt <shakeel.butt@linux.dev> wrote:
> >
> >
> > Ccing Nhat
> >
> > On Wed, Aug 14, 2024 at 02:57:38PM GMT, Jesper Dangaard Brouer wrote:
> > > I suspect the next whac-a-mole will be the rstat flush for the slab code
> > > that kswapd also activates via shrink_slab, that via
> > > shrinker->count_objects() invoke count_shadow_nodes().
> > >
> >
> > Actually count_shadow_nodes() is already using ratelimited version.
> > However zswap_shrinker_count() is still using the sync version. Nhat is
> > modifying this code at the moment and we can ask if we really need most
> > accurate values for MEMCG_ZSWAP_B and MEMCG_ZSWAPPED for the zswap
> > writeback heuristic.
>
> You are referring to this, correct:
>
> mem_cgroup_flush_stats(memcg);
> nr_backing = memcg_page_state(memcg, MEMCG_ZSWAP_B) >> PAGE_SHIFT;
> nr_stored = memcg_page_state(memcg, MEMCG_ZSWAPPED);
>
> It's already a bit less-than-accurate - as you pointed out in another
> discussion, it takes into account the objects and sizes of the entire
> subtree, rather than just the ones charged to the current (memcg,
> node) combo. Feel free to optimize this away!
>
> In fact, I should probably replace this with another (atomic?) counter
> in zswap_lruvec_state struct, which tracks the post-compression size.
> That way, we'll have a better estimate of the compression factor -
> total post-compression size / (length of LRU * page size), and
> perhaps avoid the whole stat flushing path altogether...
>
That sounds like much better solution than relying on rstat for accurate
stats.
next prev parent reply other threads:[~2024-08-14 23:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 21:53 Shakeel Butt
2024-08-13 21:58 ` Yosry Ahmed
2024-08-13 22:30 ` Shakeel Butt
2024-08-14 12:57 ` Jesper Dangaard Brouer
2024-08-14 16:32 ` Shakeel Butt
2024-08-14 23:03 ` Nhat Pham
2024-08-14 23:42 ` Shakeel Butt [this message]
2024-08-14 23:48 ` Yosry Ahmed
2024-08-15 0:19 ` Nhat Pham
2024-08-15 0:22 ` Yosry Ahmed
2024-08-15 0:29 ` 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=5psrsuvzabh2gwj7lmf6p2swgw4d4svi2zqr4p6bmmfjodspcw@fexbskbtchs7 \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hawk@kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=nphamcs@gmail.com \
--cc=roman.gushchin@linux.dev \
--cc=yosryahmed@google.com \
--cc=yuzhao@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