From: Cyan Yang <cyan.yang@sifive.com>
To: David Hildenbrand <david@redhat.com>
Cc: akpm@linux-foundation.org, shuah@kernel.org, linux-mm@kvack.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/mm/cow: Fix the incorrect error handling
Date: Tue, 11 Mar 2025 18:38:25 +0800 [thread overview]
Message-ID: <Z9ASoTIastiD7utL@cyan-mbp> (raw)
In-Reply-To: <4a068856-328f-48ae-9b1c-0ec7d65dde6b@redhat.com>
On Tue, Mar 11, 2025 at 10:19:32AM +0100, David Hildenbrand wrote:
> On 11.03.25 03:37, Cyan Yang wrote:
> > There are two error handlings did not check the correct return value.
> > This patch will fix them.
> >
> > Fixes: f4b5fd6946e244cdedc3bbb9a1f24c8133b2077a ("selftests/vm: anon_cow: THP tests")
> > Signed-off-by: Cyan Yang <cyan.yang@sifive.com>
> > ---
> > tools/testing/selftests/mm/cow.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
> > index 9446673645eb..16fcadc090a4 100644
> > --- a/tools/testing/selftests/mm/cow.c
> > +++ b/tools/testing/selftests/mm/cow.c
> > @@ -876,13 +876,13 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize)
> > mremap_size = thpsize / 2;
> > mremap_mem = mmap(NULL, mremap_size, PROT_NONE,
> > MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
> > - if (mem == MAP_FAILED) {
> > + if (mremap_mem == MAP_FAILED) {
> > ksft_test_result_fail("mmap() failed\n");
> > goto munmap;
> > }
>
> Yes, that check is wrong.
>
> > tmp = mremap(mem + mremap_size, mremap_size, mremap_size,
> > MREMAP_MAYMOVE | MREMAP_FIXED, mremap_mem);
> > - if (tmp != mremap_mem) {
> > + if (tmp == MAP_FAILED) {
> > ksft_test_result_fail("mremap() failed\n");
> > goto munmap;
> > }
>
> As Dev says, this one is just fine. Leave it as it is.
>
Thank you for the review.
I agree with you and Dev this is just fine. The reason I prefer to modify it is
- usually caller checks the return value directly and "tmp == mremap_mem"
should be determined by "mremap".
If you still prefer to leave it as it is, I will send out the v2 to remove it.
> --
> Cheers,
>
> David / dhildenb
>
next prev parent reply other threads:[~2025-03-11 10:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 2:37 [PATCH] selftests/mm/cow: Fix the incorrect error handling Cyan Yang
2025-03-11 4:53 ` Dev Jain
2025-03-11 9:19 ` David Hildenbrand
2025-03-11 10:38 ` Cyan Yang [this message]
2025-03-11 19:48 ` David Hildenbrand
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=Z9ASoTIastiD7utL@cyan-mbp \
--to=cyan.yang@sifive.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.