From: Chris Li <chrisl@kernel.org>
To: Nhat Pham <nphamcs@gmail.com>
Cc: Yosry Ahmed <yosryahmed@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
tj@kernel.org, lizefan.x@bytedance.com,
Johannes Weiner <hannes@cmpxchg.org>,
Domenico Cerasuolo <cerasuolodomenico@gmail.com>,
Seth Jennings <sjenning@redhat.com>,
Dan Streetman <ddstreet@ieee.org>,
Vitaly Wool <vitaly.wool@konsulko.com>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeelb@google.com>,
Muchun Song <muchun.song@linux.dev>,
Hugh Dickins <hughd@google.com>,
corbet@lwn.net, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
senozhatsky@chromium.org, rppt@kernel.org,
linux-mm <linux-mm@kvack.org>,
kernel-team@meta.com, LKML <linux-kernel@vger.kernel.org>,
linux-doc@vger.kernel.org, david@ixit.cz
Subject: Re: [PATCH v5] zswap: memcontrol: implement zswap writeback disabling
Date: Sun, 19 Nov 2023 18:41:32 -0800 [thread overview]
Message-ID: <ZVrHXJLxvs4_CUxc@google.com> (raw)
In-Reply-To: <CAF8kJuOCyd5r0LQ3m8fQp0GtxxNUKSmwURJH6V9aApefvX8xCA@mail.gmail.com>
Hi Nhat,
On Sun, Nov 19, 2023 at 01:50:17PM -0800, Chris Li wrote:
> On Sun, Nov 19, 2023 at 11:08 AM Nhat Pham <nphamcs@gmail.com> wrote:
> > I don't have any major argument against this. It just seems a bit
> > heavyweight for what we need at the moment (only disabling
> > swap-to-disk usage).
>
> The first milestone we just implement the reserved keywords without
> the custom swap tier list.
> That should be very similar to "zswap.writeback". Instead of writing 0
> to "zswap.writeback".
> You write "zswap" to "swap.tiers". Writing "none" will disable all
> swap. Writing "all" will allow all swap devices.
> I consider this conceptually cleaner than the "zswap.writeback" == 0
> will also disable other swap types behavior. "disabled zswap writeback
> == disable all swap" feels less natural.
I implement a minimal version of the "swap.tiers" to replace the "zswap.writeback".
It only implements the ABI level. Under the hook it is using the writeback bool.
This patch builds on top of your V5 patch.
implement memory.swap.tiers on top of memory.zswap.writeback.
"memory.swap.tiers" supports two key words for now:
all: all swap swap tiers are considered. (previously zswap.writback == 1)
zswap: only zswap tier are considered. (previously zswap.writeback == 0)
Index: linux/mm/memcontrol.c
===================================================================
--- linux.orig/mm/memcontrol.c
+++ linux/mm/memcontrol.c
@@ -7992,6 +7992,32 @@ static int swap_events_show(struct seq_f
return 0;
}
+static int swap_tiers_show(struct seq_file *m, void *v)
+{
+ struct mem_cgroup *memcg = mem_cgroup_from_seq(m);
+
+ seq_printf(m, "%s\n", READ_ONCE(memcg->zswap_writeback) ? "all" : "zswap");
+ return 0;
+}
+
+static ssize_t swap_tiers_write(struct kernfs_open_file *of,
+ char *buf, size_t nbytes, loff_t off)
+{
+ struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
+ int zswap_writeback;
+
+ buf = strstrip(buf);
+ if (!strcmp(buf, "all"))
+ zswap_writeback = 1;
+ else if (!strcmp(buf, "zswap"))
+ zswap_writeback = 0;
+ else
+ return -EINVAL;
+
+ WRITE_ONCE(memcg->zswap_writeback, zswap_writeback);
+ return nbytes;
+}
+
static struct cftype swap_files[] = {
{
.name = "swap.current",
@@ -8021,6 +8047,12 @@ static struct cftype swap_files[] = {
.file_offset = offsetof(struct mem_cgroup, swap_events_file),
.seq_show = swap_events_show,
},
+ {
+ .name = "swap.tiers",
+ .seq_show = swap_tiers_show,
+ .write = swap_tiers_write,
+ },
+
{ } /* terminate */
};
@@ -8183,31 +8215,6 @@ static ssize_t zswap_max_write(struct ke
return nbytes;
}
-static int zswap_writeback_show(struct seq_file *m, void *v)
-{
- struct mem_cgroup *memcg = mem_cgroup_from_seq(m);
-
- seq_printf(m, "%d\n", READ_ONCE(memcg->zswap_writeback));
- return 0;
-}
-
-static ssize_t zswap_writeback_write(struct kernfs_open_file *of,
- char *buf, size_t nbytes, loff_t off)
-{
- struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
- int zswap_writeback;
- ssize_t parse_ret = kstrtoint(strstrip(buf), 0, &zswap_writeback);
-
- if (parse_ret)
- return parse_ret;
-
- if (zswap_writeback != 0 && zswap_writeback != 1)
- return -EINVAL;
-
- WRITE_ONCE(memcg->zswap_writeback, zswap_writeback);
- return nbytes;
-}
-
static struct cftype zswap_files[] = {
{
.name = "zswap.current",
@@ -8220,11 +8227,6 @@ static struct cftype zswap_files[] = {
.seq_show = zswap_max_show,
.write = zswap_max_write,
},
- {
- .name = "zswap.writeback",
- .seq_show = zswap_writeback_show,
- .write = zswap_writeback_write,
- },
{ } /* terminate */
};
#endif /* CONFIG_MEMCG_KMEM && CONFIG_ZSWAP */
next prev parent reply other threads:[~2023-11-20 2:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 17:23 Nhat Pham
2023-11-16 20:53 ` Chris Li
2023-11-16 21:00 ` Yosry Ahmed
2023-11-17 0:39 ` Chris Li
2023-11-18 19:23 ` Nhat Pham
2023-11-19 9:39 ` Chris Li
2023-11-19 19:08 ` Nhat Pham
2023-11-19 21:50 ` Chris Li
2023-11-20 2:41 ` Chris Li [this message]
2023-11-21 18:13 ` Nhat Pham
2023-11-21 19:08 ` Chris Li
2023-11-22 1:19 ` Nhat Pham
2023-11-22 3:45 ` Chris Li
2023-11-22 15:01 ` Chris Li
2023-12-06 18:15 ` Nhat Pham
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=ZVrHXJLxvs4_CUxc@google.com \
--to=chrisl@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=cerasuolodomenico@gmail.com \
--cc=corbet@lwn.net \
--cc=david@ixit.cz \
--cc=ddstreet@ieee.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kernel-team@meta.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan.x@bytedance.com \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=nphamcs@gmail.com \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=senozhatsky@chromium.org \
--cc=shakeelb@google.com \
--cc=sjenning@redhat.com \
--cc=tj@kernel.org \
--cc=vitaly.wool@konsulko.com \
--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