* [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
@ 2024-08-14 17:20 Mike Yuan
2024-08-14 19:52 ` Nhat Pham
0 siblings, 1 reply; 18+ messages in thread
From: Mike Yuan @ 2024-08-14 17:20 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, cgroups, Andrew Morton, Muchun Song, Shakeel Butt,
Roman Gushchin, Michal Hocko, Johannes Weiner, Nhat Pham,
Mike Yuan
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.
[1] https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Disable_zswap_writeback_to_use_the_swap_space_only_for_hibernation
[2] https://github.com/systemd/systemd/pull/31734
Signed-off-by: Mike Yuan <me@yhndnzj.com>
---
mm/memcontrol.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 8f2f1bb18c9c..2dcdaaf358ce 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -8423,7 +8423,14 @@ void obj_cgroup_uncharge_zswap(struct obj_cgroup *objcg, size_t size)
bool mem_cgroup_zswap_writeback_enabled(struct mem_cgroup *memcg)
{
/* if zswap is disabled, do not block pages going to the swapping device */
- return !is_zswap_enabled() || !memcg || READ_ONCE(memcg->zswap_writeback);
+ if (!is_zswap_enabled())
+ return true;
+
+ for (; memcg; memcg = parent_mem_cgroup(memcg))
+ if (!READ_ONCE(memcg->zswap_writeback))
+ return false;
+
+ return true;
}
static u64 zswap_current_read(struct cgroup_subsys_state *css,
--
2.46.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-14 17:20 [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too Mike Yuan
@ 2024-08-14 19:52 ` Nhat Pham
2024-08-14 19:53 ` Nhat Pham
2024-08-14 20:22 ` Yosry Ahmed
0 siblings, 2 replies; 18+ messages in thread
From: Nhat Pham @ 2024-08-14 19:52 UTC (permalink / raw)
To: Mike Yuan
Cc: linux-kernel, linux-mm, cgroups, Andrew Morton, Muchun Song,
Shakeel Butt, Roman Gushchin, Michal Hocko, Johannes Weiner
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?
Code looks solid to me - I think the upward tree traversal should be
safe, as long as memcg is valid (since memcg holds reference to its
parent IIRC).
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-14 19:52 ` Nhat Pham
@ 2024-08-14 19:53 ` Nhat Pham
2024-08-15 18:39 ` Mike Yuan
2024-08-14 20:22 ` Yosry Ahmed
1 sibling, 1 reply; 18+ messages in thread
From: Nhat Pham @ 2024-08-14 19:53 UTC (permalink / raw)
To: Mike Yuan
Cc: linux-kernel, linux-mm, cgroups, Andrew Morton, Muchun Song,
Shakeel Butt, Roman Gushchin, Michal Hocko, Johannes Weiner
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:
>
> May I ask you to add/clarify this new expected behavior in
> Documentation/admin-guide/cgroup-v2.rst?
(and a selftest too, if it's not too much to ask :))
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-14 19:52 ` Nhat Pham
2024-08-14 19:53 ` Nhat Pham
@ 2024-08-14 20:22 ` Yosry Ahmed
2024-08-14 20:43 ` Mike Yuan
2024-08-21 16:14 ` Michal Koutný
1 sibling, 2 replies; 18+ messages in thread
From: Yosry Ahmed @ 2024-08-14 20:22 UTC (permalink / raw)
To: Nhat Pham
Cc: Mike Yuan, linux-kernel, linux-mm, cgroups, Andrew Morton,
Muchun Song, Shakeel Butt, Roman Gushchin, Michal Hocko,
Johannes Weiner
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).
What we do today dismisses inheritance completely, so it seems to me
like it should be changed anyway.
I am thinking out loud here, let me know if my reasoning makes sense to you.
>
> Code looks solid to me - I think the upward tree traversal should be
> safe, as long as memcg is valid (since memcg holds reference to its
> parent IIRC).
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-14 20:22 ` Yosry Ahmed
@ 2024-08-14 20:43 ` Mike Yuan
2024-08-15 19:12 ` Nhat Pham
2024-08-21 16:14 ` Michal Koutný
1 sibling, 1 reply; 18+ messages in thread
From: Mike Yuan @ 2024-08-14 20:43 UTC (permalink / raw)
To: Yosry Ahmed, Nhat Pham
Cc: linux-kernel, linux-mm, cgroups, Andrew Morton, Muchun Song,
Shakeel Butt, Roman Gushchin, Michal Hocko, Johannes Weiner
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.
> What we do today dismisses inheritance completely, so it seems to me
> like it should be changed anyway.
>
> I am thinking out loud here, let me know if my reasoning makes sense
> to you.
>
> >
> > Code looks solid to me - I think the upward tree traversal should
> > be
> > safe, as long as memcg is valid (since memcg holds reference to its
> > parent IIRC).
> >
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-14 19:53 ` Nhat Pham
@ 2024-08-15 18:39 ` Mike Yuan
2024-08-15 19:10 ` Nhat Pham
0 siblings, 1 reply; 18+ messages in thread
From: Mike Yuan @ 2024-08-15 18:39 UTC (permalink / raw)
To: Nhat Pham
Cc: linux-kernel, linux-mm, cgroups, Andrew Morton, Muchun Song,
Shakeel Butt, Roman Gushchin, Michal Hocko, Johannes Weiner,
Yosry Ahmed
On 2024-08-14 at 12:53 -0700, Nhat Pham 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:
> >
> > May I ask you to add/clarify this new expected behavior in
> > Documentation/admin-guide/cgroup-v2.rst?
>
> (and a selftest too, if it's not too much to ask :))
Hmm, I tried to, but the test_zswap_writeback_enabled and
test_zswap_writeback_disabled tests in the current tree already
fail for me... Should I still add new test cases under this
circumstance?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-15 18:39 ` Mike Yuan
@ 2024-08-15 19:10 ` Nhat Pham
2024-08-16 13:25 ` Mike Yuan
0 siblings, 1 reply; 18+ messages in thread
From: Nhat Pham @ 2024-08-15 19:10 UTC (permalink / raw)
To: Mike Yuan
Cc: linux-kernel, linux-mm, cgroups, Andrew Morton, Muchun Song,
Shakeel Butt, Roman Gushchin, Michal Hocko, Johannes Weiner,
Yosry Ahmed
On Thu, Aug 15, 2024 at 11:39 AM Mike Yuan <me@yhndnzj.com> wrote:
>
>
> Hmm, I tried to, but the test_zswap_writeback_enabled and
> test_zswap_writeback_disabled tests in the current tree already
> fail for me... Should I still add new test cases under this
> circumstance?
Hmm interesting. We need to fix it - could you forward me the details
of the failure mode?
But yeah, for now let's skip the selftest. Could you send a fixlet or
a follow up patch to update the documentation :)
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-14 20:43 ` Mike Yuan
@ 2024-08-15 19:12 ` Nhat Pham
2024-08-15 22:08 ` Andrew Morton
0 siblings, 1 reply; 18+ messages in thread
From: Nhat Pham @ 2024-08-15 19:12 UTC (permalink / raw)
To: Mike Yuan
Cc: Yosry Ahmed, linux-kernel, linux-mm, cgroups, Andrew Morton,
Muchun Song, Shakeel Butt, Roman Gushchin, Michal Hocko,
Johannes Weiner
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>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-15 19:12 ` Nhat Pham
@ 2024-08-15 22:08 ` Andrew Morton
2024-08-15 22:10 ` Yosry Ahmed
0 siblings, 1 reply; 18+ messages in thread
From: Andrew Morton @ 2024-08-15 22:08 UTC (permalink / raw)
To: Nhat Pham
Cc: Mike Yuan, Yosry Ahmed, linux-kernel, linux-mm, cgroups,
Muchun Song, Shakeel Butt, Roman Gushchin, Michal Hocko,
Johannes Weiner
On Thu, 15 Aug 2024 12:12:26 -0700 Nhat Pham <nphamcs@gmail.com> wrote:
> > 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>
But you'd still like an update to Documentation/admin-guide/cgroup-v2.rst?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-15 22:08 ` Andrew Morton
@ 2024-08-15 22:10 ` Yosry Ahmed
2024-08-15 23:31 ` Nhat Pham
0 siblings, 1 reply; 18+ messages in thread
From: Yosry Ahmed @ 2024-08-15 22:10 UTC (permalink / raw)
To: Andrew Morton
Cc: Nhat Pham, Mike Yuan, linux-kernel, linux-mm, cgroups,
Muchun Song, Shakeel Butt, Roman Gushchin, Michal Hocko,
Johannes Weiner
On Thu, Aug 15, 2024 at 3:08 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Thu, 15 Aug 2024 12:12:26 -0700 Nhat Pham <nphamcs@gmail.com> wrote:
>
> > > 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>
>
> But you'd still like an update to Documentation/admin-guide/cgroup-v2.rst?
Yeah I'd rather see a v2 with updated docs, and hopefully a selftest
if the existing tests problem is resolved.
Also, do we want a Fixes tag and to backport this so that current
users get the new behavior ASAP?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-15 22:10 ` Yosry Ahmed
@ 2024-08-15 23:31 ` Nhat Pham
2024-08-19 19:05 ` Yosry Ahmed
0 siblings, 1 reply; 18+ messages in thread
From: Nhat Pham @ 2024-08-15 23:31 UTC (permalink / raw)
To: Yosry Ahmed
Cc: Andrew Morton, Mike Yuan, linux-kernel, linux-mm, cgroups,
Muchun Song, Shakeel Butt, Roman Gushchin, Michal Hocko,
Johannes Weiner
On Thu, Aug 15, 2024 at 3:10 PM Yosry Ahmed <yosryahmed@google.com> wrote:
>
> On Thu, Aug 15, 2024 at 3:08 PM Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > On Thu, 15 Aug 2024 12:12:26 -0700 Nhat Pham <nphamcs@gmail.com> wrote:
> >
> > > > 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>
> >
> > But you'd still like an update to Documentation/admin-guide/cgroup-v2.rst?
>
>
> Yeah I'd rather see a v2 with updated docs, and hopefully a selftest
> if the existing tests problem is resolved.
Ah yeah, I was thinking this could be done in a follow-up patch.
But yes, please - documentation. Preferably everything together as v2.
>
> Also, do we want a Fixes tag and to backport this so that current
> users get the new behavior ASAP?
Hmm, I wonder if it's more confusing for users to change the behavior
in older kernels.
(OTOH, if this already is what people expect, then yeah it's a good
idea to backport).
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-15 19:10 ` Nhat Pham
@ 2024-08-16 13:25 ` Mike Yuan
0 siblings, 0 replies; 18+ messages in thread
From: Mike Yuan @ 2024-08-16 13:25 UTC (permalink / raw)
To: Nhat Pham
Cc: linux-kernel, linux-mm, cgroups, Andrew Morton, Muchun Song,
Shakeel Butt, Roman Gushchin, Michal Hocko, Johannes Weiner,
Yosry Ahmed
On 2024-08-15 at 12:10 -0700, Nhat Pham wrote:
> On Thu, Aug 15, 2024 at 11:39 AM Mike Yuan <me@yhndnzj.com> wrote:
> >
> >
> > Hmm, I tried to, but the test_zswap_writeback_enabled and
> > test_zswap_writeback_disabled tests in the current tree already
> > fail for me... Should I still add new test cases under this
> > circumstance?
>
> Hmm interesting. We need to fix it - could you forward me the details
> of the failure mode?
>
> But yeah, for now let's skip the selftest. Could you send a fixlet or
> a follow up patch to update the documentation :)
Sorry for the noise. It seems to be local configuration issue from my
side.
I'll submit a v2 with Documentation update and selftest :)
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-15 23:31 ` Nhat Pham
@ 2024-08-19 19:05 ` Yosry Ahmed
2024-08-20 1:01 ` Andrew Morton
0 siblings, 1 reply; 18+ messages in thread
From: Yosry Ahmed @ 2024-08-19 19:05 UTC (permalink / raw)
To: Nhat Pham
Cc: Andrew Morton, Mike Yuan, linux-kernel, linux-mm, cgroups,
Muchun Song, Shakeel Butt, Roman Gushchin, Michal Hocko,
Johannes Weiner
On Thu, Aug 15, 2024 at 4:32 PM Nhat Pham <nphamcs@gmail.com> wrote:
>
> On Thu, Aug 15, 2024 at 3:10 PM Yosry Ahmed <yosryahmed@google.com> wrote:
> >
> > On Thu, Aug 15, 2024 at 3:08 PM Andrew Morton <akpm@linux-foundation.org> wrote:
> > >
> > > On Thu, 15 Aug 2024 12:12:26 -0700 Nhat Pham <nphamcs@gmail.com> wrote:
> > >
> > > > > 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>
> > >
> > > But you'd still like an update to Documentation/admin-guide/cgroup-v2.rst?
> >
> >
> > Yeah I'd rather see a v2 with updated docs, and hopefully a selftest
> > if the existing tests problem is resolved.
>
> Ah yeah, I was thinking this could be done in a follow-up patch.
>
> But yes, please - documentation. Preferably everything together as v2.
>
> >
> > Also, do we want a Fixes tag and to backport this so that current
> > users get the new behavior ASAP?
>
> Hmm, I wonder if it's more confusing for users to change the behavior
> in older kernels.
>
> (OTOH, if this already is what people expect, then yeah it's a good
> idea to backport).
My rationale is that if people will inevitably get the behavior change
when they upgrade their kernel, I'd rather they get it sooner rather
than later, before more users start depending on the old behavior.
I am guessing there is a chance this is not what backports are meant
for. Andrew, any thoughts on this?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-19 19:05 ` Yosry Ahmed
@ 2024-08-20 1:01 ` Andrew Morton
2024-08-20 1:06 ` Yosry Ahmed
0 siblings, 1 reply; 18+ messages in thread
From: Andrew Morton @ 2024-08-20 1:01 UTC (permalink / raw)
To: Yosry Ahmed
Cc: Nhat Pham, Mike Yuan, linux-kernel, linux-mm, cgroups,
Muchun Song, Shakeel Butt, Roman Gushchin, Michal Hocko,
Johannes Weiner
On Mon, 19 Aug 2024 12:05:44 -0700 Yosry Ahmed <yosryahmed@google.com> wrote:
> > Ah yeah, I was thinking this could be done in a follow-up patch.
> >
> > But yes, please - documentation. Preferably everything together as v2.
> >
> > >
> > > Also, do we want a Fixes tag and to backport this so that current
> > > users get the new behavior ASAP?
> >
> > Hmm, I wonder if it's more confusing for users to change the behavior
> > in older kernels.
> >
> > (OTOH, if this already is what people expect, then yeah it's a good
> > idea to backport).
>
> My rationale is that if people will inevitably get the behavior change
> when they upgrade their kernel, I'd rather they get it sooner rather
> than later, before more users start depending on the old behavior.
>
> I am guessing there is a chance this is not what backports are meant
> for. Andrew, any thoughts on this?
I agree. It does depend on how long the old behavior has been out in
the field, and on our assessment of how many people are likely to
inconvenienced. So... yes please, what is that Fixes:?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-20 1:01 ` Andrew Morton
@ 2024-08-20 1:06 ` Yosry Ahmed
2024-08-20 15:28 ` Nhat Pham
0 siblings, 1 reply; 18+ messages in thread
From: Yosry Ahmed @ 2024-08-20 1:06 UTC (permalink / raw)
To: Andrew Morton
Cc: Nhat Pham, Mike Yuan, linux-kernel, linux-mm, cgroups,
Muchun Song, Shakeel Butt, Roman Gushchin, Michal Hocko,
Johannes Weiner
On Mon, Aug 19, 2024 at 6:01 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Mon, 19 Aug 2024 12:05:44 -0700 Yosry Ahmed <yosryahmed@google.com> wrote:
>
> > > Ah yeah, I was thinking this could be done in a follow-up patch.
> > >
> > > But yes, please - documentation. Preferably everything together as v2.
> > >
> > > >
> > > > Also, do we want a Fixes tag and to backport this so that current
> > > > users get the new behavior ASAP?
> > >
> > > Hmm, I wonder if it's more confusing for users to change the behavior
> > > in older kernels.
> > >
> > > (OTOH, if this already is what people expect, then yeah it's a good
> > > idea to backport).
> >
> > My rationale is that if people will inevitably get the behavior change
> > when they upgrade their kernel, I'd rather they get it sooner rather
> > than later, before more users start depending on the old behavior.
> >
> > I am guessing there is a chance this is not what backports are meant
> > for. Andrew, any thoughts on this?
>
> I agree. It does depend on how long the old behavior has been out in
> the field, and on our assessment of how many people are likely to
> inconvenienced. So... yes please, what is that Fixes:?
>
It's commit 501a06fe8e4c ("zswap: memcontrol: implement zswap
writeback disabling"). It landed in v6.8.
I suspect there aren't many users that depend on the old behavior so
far, so I would prefer to get this backported so that it's less likely
that more (or any) users start depending on the old behavior.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-20 1:06 ` Yosry Ahmed
@ 2024-08-20 15:28 ` Nhat Pham
0 siblings, 0 replies; 18+ messages in thread
From: Nhat Pham @ 2024-08-20 15:28 UTC (permalink / raw)
To: Yosry Ahmed
Cc: Andrew Morton, Mike Yuan, linux-kernel, linux-mm, cgroups,
Muchun Song, Shakeel Butt, Roman Gushchin, Michal Hocko,
Johannes Weiner
On Mon, Aug 19, 2024 at 9:07 PM Yosry Ahmed <yosryahmed@google.com> wrote:
>
>
> It's commit 501a06fe8e4c ("zswap: memcontrol: implement zswap
> writeback disabling"). It landed in v6.8.
>
> I suspect there aren't many users that depend on the old behavior so
> far, so I would prefer to get this backported so that it's less likely
> that more (or any) users start depending on the old behavior.
Agree - let's backport it then. In hindsight, I feel like this is
already what users assume. We don't rely on the assumption internally,
but at least one client of ours has asked for clarifications about
this.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-14 20:22 ` Yosry Ahmed
2024-08-14 20:43 ` Mike Yuan
@ 2024-08-21 16:14 ` Michal Koutný
2024-08-22 17:49 ` Yosry Ahmed
1 sibling, 1 reply; 18+ messages in thread
From: Michal Koutný @ 2024-08-21 16:14 UTC (permalink / raw)
To: Yosry Ahmed
Cc: Nhat Pham, Mike Yuan, linux-kernel, linux-mm, cgroups,
Andrew Morton, Muchun Song, Shakeel Butt, Roman Gushchin,
Michal Hocko, Johannes Weiner
[-- Attachment #1: Type: text/plain, Size: 1610 bytes --]
On Wed, Aug 14, 2024 at 01:22:01PM GMT, Yosry Ahmed <yosryahmed@google.com> wrote:
> 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).
>
> What we do today dismisses inheritance completely, so it seems to me
> like it should be changed anyway.
I subscribe to inheritance (at cgroup creation) not proving well (in
general). Here's the case of expecting hierarchical semantic of the
attribute.
With this change -- is there any point in keeping the inheritance
around? (Simply default to enabled.)
Thanks,
Michal
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too
2024-08-21 16:14 ` Michal Koutný
@ 2024-08-22 17:49 ` Yosry Ahmed
0 siblings, 0 replies; 18+ messages in thread
From: Yosry Ahmed @ 2024-08-22 17:49 UTC (permalink / raw)
To: Michal Koutný
Cc: Nhat Pham, Mike Yuan, linux-kernel, linux-mm, cgroups,
Andrew Morton, Muchun Song, Shakeel Butt, Roman Gushchin,
Michal Hocko, Johannes Weiner
On Wed, Aug 21, 2024 at 9:14 AM Michal Koutný <mkoutny@suse.com> wrote:
>
> On Wed, Aug 14, 2024 at 01:22:01PM GMT, Yosry Ahmed <yosryahmed@google.com> wrote:
> > 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).
> >
> > What we do today dismisses inheritance completely, so it seems to me
> > like it should be changed anyway.
>
> I subscribe to inheritance (at cgroup creation) not proving well (in
> general). Here's the case of expecting hierarchical semantic of the
> attribute.
>
> With this change -- is there any point in keeping the inheritance
> around? (Simply default to enabled.)
Agreed, please feel free to include a patch in your next version that
does that, and add "Fixes" tags and Cc:stable so that the changes are
backported and users get these changes ASAP.
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2024-08-22 17:49 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-14 17:20 [PATCH] mm/memcontrol: respect zswap.writeback setting from parent cg too 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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox