From: Nhat Pham <nphamcs@gmail.com>
To: Mike Yuan <me@yhndnzj.com>
Cc: Yosry Ahmed <yosryahmed@google.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
cgroups@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Muchun Song <muchun.song@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Roman Gushchin <roman.gushchin@linux.dev>,
Michal Hocko <mhocko@kernel.org>,
Johannes Weiner <hannes@cmpxchg.org>
Subject: Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
Date: Thu, 15 Aug 2024 12:12:26 -0700 [thread overview]
Message-ID: <CAKEwX=MDZdAHei3=UyYrsgWqyt-41_vOdCvTxj35O62NZhcN2A@mail.gmail.com> (raw)
In-Reply-To: <a2f67cbcc987cdb2d907f9c133e7fcb6a848992d.camel@yhndnzj.com>
On Wed, Aug 14, 2024 at 1:43 PM Mike Yuan <me@yhndnzj.com> wrote:
>
> On 2024-08-14 at 13:22 -0700, Yosry Ahmed wrote:
> > On Wed, Aug 14, 2024 at 12:52 PM Nhat Pham <nphamcs@gmail.com> wrote:
> > >
> > > On Wed, Aug 14, 2024 at 10:20 AM Mike Yuan <me@yhndnzj.com> wrote:
> > > >
> > > > Currently, the behavior of zswap.writeback wrt.
> > > > the cgroup hierarchy seems a bit odd. Unlike zswap.max,
> > > > it doesn't honor the value from parent cgroups. This
> > > > surfaced when people tried to globally disable zswap writeback,
> > > > i.e. reserve physical swap space only for hibernation [1] -
> > > > disabling zswap.writeback only for the root cgroup results
> > > > in subcgroups with zswap.writeback=1 still performing writeback.
> > > >
> > > > The consistency became more noticeable after I introduced
> > > > the MemoryZSwapWriteback= systemd unit setting [2] for
> > > > controlling the knob. The patch assumed that the kernel would
> > > > enforce the value of parent cgroups. It could probably be
> > > > workarounded from systemd's side, by going up the slice unit
> > > > tree and inherit the value. Yet I think it's more sensible
> > > > to make it behave consistently with zswap.max and friends.
> > >
> > > May I ask you to add/clarify this new expected behavior in
> > > Documentation/admin-guide/cgroup-v2.rst?
> > >
> > > >
> > > > [1]
> > > > https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Disable_zswap_writeback_to_use_the_swap_space_only_for_hibernation
> > >
> > > This is an interesting use case. Never envisioned this when I
> > > developed this feature :)
> > >
> > > > [2] https://github.com/systemd/systemd/pull/31734
> > > >
> > > > Signed-off-by: Mike Yuan <me@yhndnzj.com>
> > > > ---
> > >
> > > Personally, I don't feel too strongly about this one way or
> > > another. I
> > > guess you can make a case that people want to disable zswap
> > > writeback
> > > by default, and only selectively enable it for certain descendant
> > > workloads - for convenience, they would set memory.zswap.writeback
> > > ==
> > > 0 at root, then enable it on selected descendants?
> > >
> > > It's not super expensive IMHO - we already perform upward traversal
> > > on
> > > every zswap store. This wouldn't be the end of the world.
> > >
> > > Yosry, Johannes - how do you two feel about this?
> >
> > I wasn't CC'd on this, but found it by chance :) I think there is a
> > way for the zswap maintainers entry to match any patch that mentions
> > "zswap", not just based on files, right?
> >
> > Anyway, both use cases make sense to me, disabling writeback
> > system-wide or in an entire subtree, and disabling writeback on the
> > root and then selectively enabling it. I am slightly inclined to the
> > first one (what this patch does).
> >
> > Considering the hierarchical cgroup knobs work, we usually use the
> > most restrictive limit among the ancestors. I guess it ultimately
> > depends on how we define "most restrictive". Disabling writeback is
> > restrictive in the sense that you don't have access to free some
> > zswap
> > space to reclaim more memory. OTOH, disabling writeback also means
> > that your zswapped memory won't go to disk under memory pressure, so
> > in that sense it would be restrictive to force writeback :)
> >
> > Usually, the "default" is the non-restrictive thing, and then you can
> > set restrictions that apply to all children (e.g. no limits are set
> > by
> > default). Since writeback is enabled by default, it seems like the
> > restriction would be disabling writeback. Hence, it would make sense
> > to inherit zswap disabling (i.e. only writeback if all ancestors
> > allow
> > it, like this patch does).
> >
>
> Yeah, I thought about the other way around and reached the same
> conclusion.
> And there's permission boundary in the mix too - if root disables zswap
> writeback for its cgroup, the subcgroups, which could possibly be owned
> by other users, should not be able to reenable this.
Hmm yeah, I think I agree with your and Yosry's reasonings :) It
doesn't affect our use case AFAICS, and the code looks solid to me,
so:
Reviewed-by: Nhat Pham <nphamcs@gmail.com>
next prev parent reply other threads:[~2024-08-15 19:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-14 17:20 Mike Yuan
2024-08-14 19:52 ` Nhat Pham
2024-08-14 19:53 ` Nhat Pham
2024-08-15 18:39 ` Mike Yuan
2024-08-15 19:10 ` Nhat Pham
2024-08-16 13:25 ` Mike Yuan
2024-08-14 20:22 ` Yosry Ahmed
2024-08-14 20:43 ` Mike Yuan
2024-08-15 19:12 ` Nhat Pham [this message]
2024-08-15 22:08 ` Andrew Morton
2024-08-15 22:10 ` Yosry Ahmed
2024-08-15 23:31 ` Nhat Pham
2024-08-19 19:05 ` Yosry Ahmed
2024-08-20 1:01 ` Andrew Morton
2024-08-20 1:06 ` Yosry Ahmed
2024-08-20 15:28 ` Nhat Pham
2024-08-21 16:14 ` Michal Koutný
2024-08-22 17:49 ` Yosry Ahmed
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='CAKEwX=MDZdAHei3=UyYrsgWqyt-41_vOdCvTxj35O62NZhcN2A@mail.gmail.com' \
--to=nphamcs@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=me@yhndnzj.com \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=yosryahmed@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