linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ujwal Kundur <ujwal.kundur@gmail.com>
To: Brendan Jackman <jackmanb@google.com>
Cc: akpm@linux-foundation.org, peterx@redhat.com, shuah@kernel.org,
	 linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/1] selftests/mm/uffd: Refactor non-composite global vars into struct
Date: Mon, 19 May 2025 19:20:31 +0530	[thread overview]
Message-ID: <CALkFLLLfxT1pQ_ySB1NU4KXOEGLd2wB8pbhpBG2HfK3_mLOYAQ@mail.gmail.com> (raw)
In-Reply-To: <D9V0UTL5BCLM.1WHR6F4UN14QQ@google.com>

Thanks for the review and testing!

>> -static void retry_copy_page(int ufd, struct uffdio_copy *uffdio_copy,
>> -                         unsigned long offset)
>> +static void retry_copy_page(uffd_global_test_opts_t *gopts, struct uffdio_copy *uffdio_copy,
>> +                                                     unsigned long offset)
>>  {
>> -     uffd_test_ops->alias_mapping(&uffdio_copy->dst,
>> -                                  uffdio_copy->len,
>> -                                  offset);
>> -     if (ioctl(ufd, UFFDIO_COPY, uffdio_copy)) {
>> +     uffd_test_ops->alias_mapping(gopts,
>> +                                                             &uffdio_copy->dst,
>> +                                                             uffdio_copy->len,
>> +                                                             offset);

> Looks like your editor got a bit excited here :D
>
> There are a few other places where this happened too, e.g. the
> are_count() declaration and there's a pthread_create_call() that's quite
> messed up.

I use vim with `:set list` turned on to display control characters and
it looked fine to me when I submitted the patch :(
Here's the output of $ cat -A uffd-common.c | grep -A 15 retry_copy_page:
(where ^I represents a tab equivalent to 4 spaces)
static void retry_copy_page(uffd_global_test_opts_t *gopts, struct
uffdio_copy *uffdio_copy,$
^I^I^I^I^I^I^Iunsigned long offset)$
{$
^Iuffd_test_ops->alias_mapping(gopts,$
^I^I^I^I^I^I^I^I&uffdio_copy->dst,$
^I^I^I^I^I^I^I^Iuffdio_copy->len,$
^I^I^I^I^I^I^I^Ioffset);$
^Iif (ioctl(gopts->uffd, UFFDIO_COPY, uffdio_copy)) {$
^I^I/* real retval in ufdio_copy.copy */$
^I^Iif (uffdio_copy->copy != -EEXIST)$
^I^I^Ierr("UFFDIO_COPY retry error: %"PRId64,$
^I^I^I    (int64_t)uffdio_copy->copy);$
^I} else {$
^I^Ierr("UFFDIO_COPY retry unexpected: %"PRId64,$
^I^I    (int64_t)uffdio_copy->copy);$
^I}$

I checked this against master:
$ cat -A uffd-common.c | grep -A 15 retry_copy_page
static void retry_copy_page(int ufd, struct uffdio_copy *uffdio_copy,$
^I^I^I    unsigned long offset)$
{$
^Iuffd_test_ops->alias_mapping(&uffdio_copy->dst,$
^I^I^I^I     uffdio_copy->len,$
^I^I^I^I     offset);$
^Iif (ioctl(ufd, UFFDIO_COPY, uffdio_copy)) {$
^I^I/* real retval in ufdio_copy.copy */$
^I^Iif (uffdio_copy->copy != -EEXIST)$
^I^I^Ierr("UFFDIO_COPY retry error: %"PRId64,$
^I^I^I    (int64_t)uffdio_copy->copy);$
^I} else {$
^I^Ierr("UFFDIO_COPY retry unexpected: %"PRId64,$
^I^I    (int64_t)uffdio_copy->copy);$
^I}$
}$

and there seem to be spaces mixed in earlier causing the formatting
issues. It looks okay to me after I pulled in the patch to my local
repo.

> Unfortunately I don't know of any tool that can find/fix these issues
> automatically without also messing up the whole file. Could you just
> do a visual skim and fix what you can spot?

Yeah, I ran clang-format and it's playing by its own rules -- do we
have a standard .clang-format file?
Please let me know if there's a better way to find/fix whitespace
formatting issues, I found a few inconsistencies which I will fix.

>  static void sigalrm(int sig)
>  {
>       if (sig != SIGALRM)
>               abort();
> -     test_uffdio_copy_eexist = true;
> +     // TODO: Set this without access to global vars
> +     // gopts->test_uffdio_copy_eexist = true;
>
> Did you mean to leave this like that?

Nice catch! I was hoping someone would suggest a better way to handle
this. As far as I can tell, this was written the way it was as a
consequence of using global variables.
I think this sets up retries for copies in a racy way using alarm(2) /
signal(2), not sure how effective that has proven to be. I believe the
only way to keep this functionality would be to introduce some async
action (libev, libuv, etc.), but is that required?

> +                     /* TODO: remove this global var.. it's so ugly */
>
> That's done :)

Oh I misunderstood that as "remove nr_parallel" which is not the case, will fix.

> @@ -1734,6 +1737,27 @@ int main(int argc, char *argv[])
>               }
>               for (j = 0; j < n_mems; j++) {
>                       mem_type = &mem_types[j];
> +
> +                     // Initialize global test options
>
> Wrong comment style here

Will fix

I'm not sure about the protocol here, should I roll a PATCH v4 or a
new patch entirely?
Planning on addressing another TODO for dynamically setting the
BASE_PMD_ADDR, I can roll the fixes as part of that patch if required.

  reply	other threads:[~2025-05-19 13:50 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 [this message]
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
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=CALkFLLLfxT1pQ_ySB1NU4KXOEGLd2wB8pbhpBG2HfK3_mLOYAQ@mail.gmail.com \
    --to=ujwal.kundur@gmail.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=peterx@redhat.com \
    --cc=shuah@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).