linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosryahmed@google.com>
To: Nhat Pham <nphamcs@gmail.com>
Cc: akpm@linux-foundation.org, shuah@kernel.org, hannes@cmpxchg.org,
	 tj@kernel.org, lizefan.x@bytedance.com, linux-mm@kvack.org,
	 kernel-team@meta.com, linux-kernel@vger.kernel.org,
	cgroups@vger.kernel.org,  linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 3/3] selftests: add test for zswapin
Date: Tue, 30 Jan 2024 18:54:31 +0000	[thread overview]
Message-ID: <ZblF54ZpiUzzsbbf@google.com> (raw)
In-Reply-To: <CAKEwX=Pj+ncE=wZTOBVzT8E-=YVbqr-1CtsMNuZWLAhuaf7wAg@mail.gmail.com>

On Tue, Jan 30, 2024 at 10:31:24AM -0800, Nhat Pham wrote:
> On Mon, Jan 29, 2024 at 5:24 PM Yosry Ahmed <yosryahmed@google.com> wrote:
> >
[..]
> > > -static int allocate_bytes(const char *cgroup, void *arg)
> > > +static int allocate_bytes_and_read(const char *cgroup, void *arg, bool read)
> > >  {
> > >       size_t size = (size_t)arg;
> > >       char *mem = (char *)malloc(size);
> > > +     int ret = 0;
> > >
> > >       if (!mem)
> > >               return -1;
> > >       for (int i = 0; i < size; i += 4095)
> > >               mem[i] = 'a';
> > > +
> > > +     if (read) {
> > > +             /* cycle through the allocated memory to (z)swap in and out pages */
> > > +             for (int t = 0; t < 5; t++) {
> >
> > What benefit does the iteration serve here? I would guess one iteration
> > is enough to swap everything in at least once, no?
> 
> There might be data races etc. that might not appear in one iteration.
> Running multiple iterations increases the probability of these bugs
> cropping up.

Hmm this is a test running in a single process, and I assume the rest of
the system would be idle (at least from a zswap perspective). Did the
iterations actually catch problems in this scenario (not specifically in
this test, but generally in similar testing)?

> 
> Admittedly, the same effect could, perhaps, also be achieved by
> running the same test multiple times, so this is not a hill I will die
> on :) This is just a bit more convenient - CI infra often runs these
> tests once every time a new kernel is built.
> 
[..]
> > > +
> > > +static int test_swapin(const char *root)
> > > +{
> > > +     return test_zswapin_size(root, "0");
> > > +}
> >
> > Why are we testing the no zswap case? I am all for testing but it seems
> > out of scope here. It would have been understandable if we are testing
> > memory.zswap.max itself, but we are not doing that.
> 
> Eh it's just by convenience. We already have the workload - any test
> for zswap can pretty much be turned into a test for swap by disabling
> zswap (and enabling swap), so I was trying to kill two birds with one
> stone and cover a bit more of the codebase.

We can check that no data is actually in zswap after
test_zswapin_size(root, "0"), in which case it becomes more of a zswap
test and we get a sanity check for memory.zswap.max == 0. WDYT?

Perhaps we can rename it to test_swpain_nozswap() or so.

> 
> >
> > FWIW, I think the tests here should really be separated from cgroup
> > tests, but I understand why they were added here. There is a lot of
> > testing for memcg interface and control for zswap, and a lot of nice
> > helpers present.
> 
> Yeah FWIW, I agree :) I wonder if there's an easy way to inherit
> helpers from one test suite to another. Some sort of kselftest
> dependency? Or maybe move these cgroup helpers up the hierarchy (so
> that it can be shared by multiple selftest suites).

I am not fluent in kselftest so I can't claim to know the answer here.
There are a lot of things to do testing-wise for zswap, but I am not
asking anyone to do it because I don't have the time to do it myself. It
would be nice though :)


      reply	other threads:[~2024-01-30 18:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-29 22:45 [PATCH 0/3] fix and extend zswap kselftests Nhat Pham
2024-01-29 22:45 ` [PATCH 1/3] selftests: zswap: add zswap selftest file to zswap maintainer entry Nhat Pham
2024-01-30  1:02   ` Yosry Ahmed
2024-01-30 18:37     ` Nhat Pham
2024-01-30 18:55       ` Yosry Ahmed
2024-01-29 22:45 ` [PATCH 2/3] selftests: fix the zswap invasive shrink test Nhat Pham
2024-01-30  1:05   ` Yosry Ahmed
2024-01-29 22:45 ` [PATCH 3/3] selftests: add test for zswapin Nhat Pham
2024-01-30  1:24   ` Yosry Ahmed
2024-01-30 18:31     ` Nhat Pham
2024-01-30 18:54       ` Yosry Ahmed [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=ZblF54ZpiUzzsbbf@google.com \
    --to=yosryahmed@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizefan.x@bytedance.com \
    --cc=nphamcs@gmail.com \
    --cc=shuah@kernel.org \
    --cc=tj@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).