[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CA+CLi1gtgwa7JZC_NvynOKhM59j_hYpAnc+ivTjXobOqHkQb-A@mail.gmail.com>
Date: Wed, 13 Sep 2023 09:17:12 +0200
From: Domenico Cerasuolo <cerasuolodomenico@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: dan.carpenter@...aro.org, kernel-team@...a.com,
linux-kernel@...r.kernel.org, cgroups@...r.kernel.org,
linux-kselftest@...r.kernel.org
Subject: Re: [PATCH] selftests: cgroup: fix test_zswap error path and
meaningless check
On Tue, Sep 12, 2023 at 7:18 PM Andrew Morton <akpm@...ux-foundation.org> wrote:
>
> On Tue, 12 Sep 2023 10:38:00 +0200 Domenico Cerasuolo <cerasuolodomenico@...il.com> wrote:
>
> > Replace destruction paths with simple returns before the test cgroup is
> > created, there is nothing to free or destroy at that point.
> >
> > Remove pointless check, stored_pages is a size_t and cannot be < 0.
> >
> > ...
> >
> > @@ -208,8 +208,6 @@ static int test_no_kmem_bypass(const char *root)
> > free(trigger_allocation);
> > if (get_zswap_stored_pages(&stored_pages))
> > break;
> > - if (stored_pages < 0)
> > - break;
> > /* If memory was pushed to zswap, verify it belongs to memcg */
> > if (stored_pages > stored_pages_threshold) {
> > int zswapped = cg_read_key_long(test_group, "memory.stat", "zswapped ");
>
> stored_pages will be set to -1 on error. It would be better to cast
> stored_pages to ssize_t in the check, rather than simply ignoring
> errors?
I'm not sure I understood, isn't it safe to just rely on the return value of
get_zswap_stored_pages a few lines above? In that case we break the loop and
the value of stored_pages is not used.
Powered by blists - more mailing lists