From: Li Wang <liwang@redhat.com>
To: "Yosry Ahmed" <yosryahmed@google.com>,
"Michal Koutný" <mkoutny@suse.com>
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Muchun Song <muchun.song@linux.dev>,
Nhat Pham <nphamcs@gmail.com>, Tejun Heo <tj@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>
Subject: Re: [PATCH 1/5] selftests/cgroup: detect and handle global zswap state in test_zswap
Date: Thu, 12 Mar 2026 09:41:26 +0800 [thread overview]
Message-ID: <abIZxqi62VPec3W2@redhat.com> (raw)
In-Reply-To: <CAJD7tkad2Q5Dt4On91tgsXDcmORYQsBAB-CbM=EY270nJ5y_Pw@mail.gmail.com>
On Wed, Mar 11, 2026 at 11:47:22AM -0700, Yosry Ahmed wrote:
...
> > --- a/tools/testing/selftests/cgroup/test_zswap.c
> > +++ b/tools/testing/selftests/cgroup/test_zswap.c
> > @@ -594,18 +594,88 @@ static bool zswap_configured(void)
> > return access("/sys/module/zswap", F_OK) == 0;
> > }
> >
> > +static int zswap_enabled_state(void)
>
> Just zswap_enabled() is good.
+1
>
> > +{
> > + char buf[16];
> > + ssize_t n;
> > +
> > + if (!zswap_configured())
> > + return -1;
>
> Return 0 here, zswap is disabled for all intents and purposes.
>
> > +
> > + n = read_text("/sys/module/zswap/parameters/enabled", buf, sizeof(buf));
> > + if (n < 0 || n == 0)
> > + return -1;
>
> if (read_text(..) <= 0)
>
> > +
> > + switch (buf[0]) {
> > + case 'Y':
> > + case 'y':
> > + case '1':
> > + return 1;
> > + case 'N':
> > + case 'n':
> > + case '0':
>
> Can a read really return any of these values? Or just Y/N?
On my side it just returns 'Y/N', but I use more chars only for
safe/compatiable consideration. Maybe we don't need others.
> > int main(int argc, char **argv)
> > {
> > char root[PATH_MAX];
> > - int i;
> > + int i, orig_zswap_state;
> >
> > ksft_print_header();
> > ksft_set_plan(ARRAY_SIZE(tests));
> > if (cg_find_unified_root(root, sizeof(root), NULL))
> > ksft_exit_skip("cgroup v2 isn't mounted\n");
> >
> > - if (!zswap_configured())
> > + orig_zswap_state = zswap_enabled_state();
> > +
> > + if (orig_zswap_state == -1)
> > ksft_exit_skip("zswap isn't configured\n");
> > + else if (orig_zswap_state == 0 && !enable_zswap())
> > + ksft_exit_skip("zswap is disabled and cannot be enabled\n");
>
> As Michal mentioned, skip the test if zswap is not enabled.
Sure, that would be simpler and we can remove the enable/disable_zswap() functions.
> Assuming zswap_enabled() only returns -1 if it fails to read the
> module param (and zswap_configured() is true), then we should probably
> fail instead of skip, as it means something is wrong with the test or
> the module param.
Absoultely right. Thanks for reviewing.
--
Regards,
Li Wang
prev parent reply other threads:[~2026-03-12 1:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 11:05 [PATCH 1/5] selftests/cgroup: detect and handle global zswap state in test_zswap Li Wang
2026-03-11 11:05 ` [PATCH 2/5] selftests/cgroup: avoid OOM in test_swapin_nozswap Li Wang
2026-03-11 18:50 ` Yosry Ahmed
2026-03-12 4:01 ` Li Wang
2026-03-12 17:09 ` Nhat Pham
2026-03-13 2:59 ` Li Wang
2026-03-11 11:05 ` [PATCH 3/5] selftests/cgroup: use runtime page size for zswpin check Li Wang
2026-03-11 18:56 ` Yosry Ahmed
2026-03-12 2:35 ` Li Wang
2026-03-11 11:05 ` [PATCH 4/5] selftest/cgroup: fix zswap test_no_invasive_cgroup_shrink on 64K pagesize system Li Wang
2026-03-11 19:01 ` Yosry Ahmed
2026-03-12 2:36 ` Li Wang
2026-03-11 11:05 ` [PATCH 5/5] selftest/cgroup: fix zswap attempt_writeback() " Li Wang
2026-03-11 18:58 ` Yosry Ahmed
2026-03-12 2:38 ` Li Wang
2026-03-11 13:20 ` [PATCH 1/5] selftests/cgroup: detect and handle global zswap state in test_zswap Michal Koutný
2026-03-11 18:41 ` Yosry Ahmed
2026-03-11 18:47 ` Yosry Ahmed
2026-03-12 1:41 ` Li Wang [this message]
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=abIZxqi62VPec3W2@redhat.com \
--to=liwang@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=muchun.song@linux.dev \
--cc=nphamcs@gmail.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=tj@kernel.org \
--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