From: David Hildenbrand <david@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-mm@kvack.org
Cc: Vlastimil Babka <vbabka@suse.cz>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] mm/rmap: Fix misplaced parenthesis of a likely()
Date: Fri, 1 Dec 2023 21:06:22 +0100 [thread overview]
Message-ID: <2d691c11-fa97-4f56-a4c4-c7f466c81d3a@redhat.com> (raw)
In-Reply-To: <20231201145936.5ddfdb50@gandalf.local.home>
On 01.12.23 20:59, Steven Rostedt wrote:
> From: Steven Rostedt (Google) <rostedt@goodmis.org>
>
> Running my yearly branch profiler to see where likely/unlikely annotation
> may be added or removed, I discovered this:
>
> correct incorrect % Function File Line
> ------- --------- - -------- ---- ----
> 0 457918 100 page_try_dup_anon_rmap rmap.h 264
> [..]
> 458021 0 0 page_try_dup_anon_rmap rmap.h 265
>
That looks like a handy tool!
> I thought it was interesting that line 264 of rmap.h had a 100% incorrect
> annotation, but the line directly below it was 100% correct. Looking at the
> code:
>
> if (likely(!is_device_private_page(page) &&
> unlikely(page_needs_cow_for_dma(vma, page))))
>
> It didn't make sense. The "likely()" was around the entire if statement
> (not just the "!is_device_private_page(page)"), which also included the
> "unlikely()" portion of that if condition.
Yes, that was clearly misplaced.
>
> If the unlikely portion is unlikely to be true, that would make the entire
> if condition unlikely to be true, so it made no sense at all to say the
> entire if condition is true.
>
> What is more likely to be likely is just the first part of the if statement
> before the && operation. It's likely to be a misplaced parenthesis. And
> after making the if condition broken into a likely() && unlikely(), both
> now appear to be correct!
>
Reviewed-by: David Hildenbrand <david@redhat.com>
But
> Cc: stable@vger.kernel.org
stable, really? Why?
> Fixes:fb3d824d1a46c ("mm/rmap: split page_dup_rmap() into page_dup_file_rmap() and page_try_dup_anon_rmap()")
and does it even fix a real bug?
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2023-12-01 20:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-01 19:59 Steven Rostedt
2023-12-01 20:06 ` David Hildenbrand [this message]
2023-12-01 20:15 ` Steven Rostedt
2023-12-01 20:18 ` David Hildenbrand
2023-12-04 15:28 ` Vlastimil Babka
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=2d691c11-fa97-4f56-a4c4-c7f466c81d3a@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rostedt@goodmis.org \
--cc=vbabka@suse.cz \
/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