From: David Vernet <void@manifault.com>
To: Adam Sindelar <adam@wowsignal.io>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, Adam Sindelar <ats@fb.com>,
kernel-team@fb.com, surenb@google.com
Subject: Re: [PATCH v2] selftests/vm: fix errno handling in mrelease_test
Date: Tue, 5 Jul 2022 09:41:39 -0700 [thread overview]
Message-ID: <20220705150015.o3omwkc7c23dbtkh@dev0025.ash9.facebook.com> (raw)
In-Reply-To: <20220704173351.19595-1-adam@wowsignal.io>
On Mon, Jul 04, 2022 at 07:33:51PM +0200, Adam Sindelar wrote:
Thanks for fixing this, Adam.
> mrelease_test should return KSFT_SKIP when process_mrelease is not
> defined, but due to a perror call consuming the errno, it returns
> KSFT_FAIL.
>
> This patch decides the exit code before calling perror.
>
We should probably also include a "Fixes" line here (see [0]):
Fixes: 33776141b812 ("selftests: vm: add process_mrelease tests")
[0]: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes
> Signed-off-by: Adam Sindelar <adam@wowsignal.io>
> ---
> v1->v2: Fixed second instance in the same file
>
> tools/testing/selftests/vm/mrelease_test.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/vm/mrelease_test.c b/tools/testing/selftests/vm/mrelease_test.c
> index 96671c2f7d48..e8b17258579b 100644
> --- a/tools/testing/selftests/vm/mrelease_test.c
> +++ b/tools/testing/selftests/vm/mrelease_test.c
> @@ -100,8 +100,10 @@ int main(void)
>
> /* Test a wrong pidfd */
> if (!syscall(__NR_process_mrelease, -1, 0) || errno != EBADF) {
> + /* perror overwrites errno, so this line must be first */
> + res = (errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
> perror("process_mrelease with wrong pidfd");
> - exit(errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
> + exit(res);
> }
>
> /* Start the test with 1MB child memory allocation */
> @@ -156,8 +158,9 @@ int main(void)
> run_negative_tests(pidfd);
>
> if (kill(pid, SIGKILL)) {
> + res = (errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
> perror("kill");
> - exit(errno == ENOSYS ? KSFT_SKIP : KSFT_FAIL);
> + exit(res);
> }
>
> success = (syscall(__NR_process_mrelease, pidfd, 0) == 0);
> --
> 2.35.1
>
This looks good to me, but it looks like there are a couple of other places
where we're doing the wrong thing, i.e. in run_negative_tests() and after
calling waitpid(). Could you please fix those as well?
Also adding Suren to cc.
- David
next prev parent reply other threads:[~2022-07-05 16:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 17:33 Adam Sindelar
2022-07-05 16:41 ` David Vernet [this message]
2022-07-05 17:02 ` Suren Baghdasaryan
2022-07-06 9:55 ` Adam Sindelar
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=20220705150015.o3omwkc7c23dbtkh@dev0025.ash9.facebook.com \
--to=void@manifault.com \
--cc=adam@wowsignal.io \
--cc=akpm@linux-foundation.org \
--cc=ats@fb.com \
--cc=kernel-team@fb.com \
--cc=linux-mm@kvack.org \
--cc=surenb@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