linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Ujwal Kundur <ujwal.kundur@gmail.com>,
	shuah@kernel.org, jackmanb@google.com,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH v5 1/1] selftests/mm/uffd: Refactor non-composite global vars into struct
Date: Tue, 17 Jun 2025 13:22:30 -0400	[thread overview]
Message-ID: <aFGkVh-rs2ZqcL6g@x1.local> (raw)
In-Reply-To: <aFGPVPDKGLOIEucg@x1.local>

On Tue, Jun 17, 2025 at 11:52:52AM -0400, Peter Xu wrote:
> On Mon, Jun 16, 2025 at 05:26:18PM -0700, Andrew Morton wrote:
> > On Mon, 16 Jun 2025 15:34:06 +0530 Ujwal Kundur <ujwal.kundur@gmail.com> wrote:
> > 
> > > Refactor macros and non-composite global variable definitions into a
> > > struct that is defined at the start of a test and is passed around
> > > instead of relying on global vars.
> > 
> > Well I guess that's nicer.
> > 
> > >  5 files changed, 616 insertions(+), 542 deletions(-)
> > 
> > It needs to be!
> > 
> > Thanks, I'll queue it for testing while Peter thinks about it :)
> 
> I didn't pay much attention on this one as I saw Brandan was actively
> reviewing it, which was great.
> 
> This is definitely an improvement to the test.  Thanks both!

I did give it a quick run today, but I found I hit this:

$ ./uffd-unit-tests
Testing UFFDIO_API (with syscall)... done
Testing UFFDIO_API (with /dev/userfaultfd)... done
Testing register-ioctls on anon... done
ERROR: munmap (errno=22, @uffd-common.c:277)

IIUC it's because after moving most globals to stack, they are not properly
zero-initialized anymore. In this case it failed at MEM_ANON of
register-ioctls test, trying to munmap() some address that will start to be
random garbage since it's on the stack.  So maybe we at least need
something like this?

diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index bed96f41c578..0b66ca3e7b82 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -1744,7 +1744,7 @@ int main(int argc, char *argv[])
                        mem_type = &mem_types[j];
 
                        /* Initialize global test options */
-                       uffd_global_test_opts_t gopts;
+                       uffd_global_test_opts_t gopts = { 0 };
 
                        gopts.map_shared = mem_type->shared;
                        uffd_test_ops = mem_type->mem_ops;

Even with that, it fails somewhere later.

Ujwal, can you reproduce these issues and have a look?

Thanks,

-- 
Peter Xu


  reply	other threads:[~2025-06-17 17:22 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-01 16:38 [PATCH 0/4] selftests/mm/uffd: refactor global variables Ujwal Kundur
2025-05-01 16:38 ` [PATCH 1/4] selftests/mm/uffd: Refactor non-composite global vars into struct Ujwal Kundur
2025-05-02 12:16   ` Brendan Jackman
2025-05-02 12:28     ` Brendan Jackman
2025-05-03 18:16       ` Ujwal Kundur
2025-05-04  2:25         ` Andrew Morton
2025-05-01 16:38 ` [PATCH 2/4] selftests/mm/uffd: Swap global vars with global test options Ujwal Kundur
2025-05-01 16:38 ` [PATCH 3/4] selftests/mm/uffd: Swap global variables with global test opts Ujwal Kundur
2025-05-01 16:38 ` [PATCH 4/4] " Ujwal Kundur
2025-05-02 12:18 ` [PATCH 0/4] selftests/mm/uffd: refactor global variables Brendan Jackman
2025-05-04  9:48 ` [PATCH v2 1/1] selftests/mm/uffd: Refactor non-composite global vars into struct Ujwal Kundur
2025-05-06  0:57   ` Andrew Morton
2025-05-10 16:03 ` [PATCH v3 " Ujwal Kundur
2025-05-13 12:12   ` Brendan Jackman
2025-05-19 13:50     ` Ujwal Kundur
2025-05-19 21:40       ` Andrew Morton
2025-05-20  9:16       ` Brendan Jackman
2025-05-25 19:19         ` Ujwal Kundur
2025-05-26  9:08           ` Brendan Jackman
2025-05-30  7:45             ` Ujwal Kundur
2025-05-31  7:46 ` [PATCH v4 " Ujwal Kundur
2025-06-10  6:57   ` Ujwal Kundur
2025-06-10 11:32   ` Brendan Jackman
2025-06-16  6:38     ` Ujwal Kundur
2025-06-16 10:04 ` [PATCH v5 " Ujwal Kundur
2025-06-17  0:26   ` Andrew Morton
2025-06-17 15:52     ` Peter Xu
2025-06-17 17:22       ` Peter Xu [this message]
2025-06-18 10:00         ` Brendan Jackman
2025-06-26  5:22           ` Ujwal Kundur
2025-06-26 14:12             ` Peter Xu
2025-06-30 11:25               ` Ujwal Kundur
2025-07-02 15:20 ` [PATCH v6 " Ujwal Kundur
2025-07-04 16:20   ` Peter Xu
2025-07-10  5:07     ` Ujwal Kundur
2025-08-06 15:03       ` Ujwal Kundur
2025-08-07 16:45         ` Peter Xu
2025-08-13 11:33         ` Brendan Jackman
2025-08-16 14:12           ` Ujwal Kundur

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=aFGkVh-rs2ZqcL6g@x1.local \
    --to=peterx@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=jackmanb@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shuah@kernel.org \
    --cc=ujwal.kundur@gmail.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;
as well as URLs for NNTP newsgroup(s).