[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAF8kJuPXBLpG2d4sje6ntrA+U-AnLzu3sNpJK02YxNcg04YNng@mail.gmail.com>
Date: Fri, 10 Nov 2023 15:09:56 -0800
From: Chris Li <chrisl@...nel.org>
To: Nhat Pham <nphamcs@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, tj@...nel.org,
lizefan.x@...edance.com, Johannes Weiner <hannes@...xchg.org>,
Domenico Cerasuolo <cerasuolodomenico@...il.com>,
Yosry Ahmed <yosryahmed@...gle.com>,
Seth Jennings <sjenning@...hat.com>,
Dan Streetman <ddstreet@...e.org>,
Vitaly Wool <vitaly.wool@...sulko.com>, mhocko@...nel.org,
roman.gushchin@...ux.dev, Shakeel Butt <shakeelb@...gle.com>,
muchun.song@...ux.dev, Hugh Dickins <hughd@...gle.com>,
corbet@....net, Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
senozhatsky@...omium.org, rppt@...nel.org,
linux-mm <linux-mm@...ck.org>, kernel-team@...a.com,
LKML <linux-kernel@...r.kernel.org>, linux-doc@...r.kernel.org,
david@...t.cz
Subject: Re: [PATCH v4] zswap: memcontrol: implement zswap writeback disabling
Hi Nhat,
Acked-by: Chris Li <chrisl@...nel.org>
On Mon, Nov 6, 2023 at 3:12 PM Nhat Pham <nphamcs@...il.com> wrote:
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -219,6 +219,12 @@ struct mem_cgroup {
#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP)
unsigned long zswap_max;
+
+ /*
+ * Prevent pages from this memcg from being written back from zswap to
+ * swap, and from being swapped out on zswap store failures.
+ */
+ bool zswap_writeback;
#endif
I notice the bool is between two integers.
mem_cgroup structure has a few bool sprinkle in different locations.
Arrange them together might save a few padding bytes. We can also
consider using bit fields.
It is a very minor point, the condition also exists before your change.
> #endif /* _LINUX_ZSWAP_H */
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index e43b5aba8efc..9cb3ea912cbe 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -5545,6 +5545,11 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
> WRITE_ONCE(memcg->soft_limit, PAGE_COUNTER_MAX);
> #if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP)
> memcg->zswap_max = PAGE_COUNTER_MAX;
> +
> + if (parent)
> + WRITE_ONCE(memcg->zswap_writeback, READ_ONCE(parent->zswap_writeback));
> + else
> + WRITE_ONCE(memcg->zswap_writeback, true);
You can combine this two WRITE_ONCE to one
bool writeback = !parent || READ_ONCE(parent->zswap_writeback);
WRITE_ONCE(memcg->zswap_writeback, writeback);
Chris
Powered by blists - more mailing lists