From: David Hildenbrand <david@redhat.com>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
akpm@linux-foundation.org, riel@surriel.com,
Liam.Howlett@oracle.com, vbabka@suse.cz, harry.yoo@oracle.com,
linux-mm@kvack.org
Subject: Re: [PATCH 2/3] mm/rmap: could be partially_mapped only after no entire map
Date: Sat, 16 Aug 2025 11:16:37 +0200 [thread overview]
Message-ID: <88117e56-6b81-4601-a954-26d5f630aabd@redhat.com> (raw)
In-Reply-To: <20250816090654.u5eoys2vkpswe553@master>
On 16.08.25 11:06, Wei Yang wrote:
> On Sat, Aug 16, 2025 at 08:31:59AM +0200, David Hildenbrand wrote:
>> On 15.08.25 12:08, Lorenzo Stoakes wrote:
>>> On Fri, Aug 15, 2025 at 08:49:42AM +0000, Wei Yang wrote:
>>>> If it is not the last entire map, we are sure the folio is not partially
>>>> mapped.
>>>>
>>>> Move the check when there is no entire map.
>>>>
>>>
>>> This one I don't like, you're having to sit and think about why it is that
>>> this would be the case, vs. just unconditionally doing it.
>>>
>>> Again, as mentioned on previous series, just because we could do something
>>> doesn't mean we should, unless there's statistically reliable perf data on
>>> something real-world indicating we _must_, code clarity absolutely beats
>>> everything else on importance.
>>>
>>> So yeah, sorry but no to this patch, please resend with just the two
>>> reviewed (unless David radically disagrees with me :)
>>
>> The compiler can figure out that "nr == 0" if the "if (last)" branch is not
>> taken.
>>
>
> Per my understanding, last is a run time value. I don't figure out how
> compiler could help here.
>
> I may miss something. Would you mind giving more hint?
The compiler can figure out that it can move the whole statement to the "if (last)" branch because it knows that nr == 0 otherwise and partially_mapped == 0 already.
Best to see if there is any actual change in generated code, though.
Note that if we're already moving that around, couldn't we move it further in?
diff --git a/mm/rmap.c b/mm/rmap.c
index 0e9c4041f8687..fb83db88cd1fd 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1753,13 +1753,13 @@ static __always_inline void __folio_remove_rmap(struct folio *folio,
/* Raced ahead of another remove and an add? */
if (unlikely(nr < 0))
nr = 0;
+ partially_mapped = nr && nr < nr_pmdmapped;
} else {
/* An add of ENTIRELY_MAPPED raced ahead */
nr = 0;
}
}
- partially_mapped = nr && nr < nr_pmdmapped;
break;
default:
BUILD_BUG();
--
Cheers
David / dhildenb
next prev parent reply other threads:[~2025-08-16 9:16 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 8:49 [PATCH 0/3] mm/rmap: small cleanup for __folio_remove_rmap() Wei Yang
2025-08-15 8:49 ` [PATCH 1/3] mm/rmap: not necessary to mask off FOLIO_PAGES_MAPPED Wei Yang
2025-08-15 9:38 ` Lorenzo Stoakes
2025-08-16 0:33 ` Wei Yang
2025-08-16 6:29 ` David Hildenbrand
2025-08-15 8:49 ` [PATCH 2/3] mm/rmap: could be partially_mapped only after no entire map Wei Yang
2025-08-15 10:08 ` Lorenzo Stoakes
2025-08-16 6:31 ` David Hildenbrand
2025-08-16 9:06 ` Wei Yang
2025-08-16 9:16 ` David Hildenbrand [this message]
2025-08-16 10:05 ` Giorgi Tchankvetadze
2025-08-16 10:32 ` David Hildenbrand
2025-08-16 14:03 ` Wei Yang
2025-08-15 8:49 ` [PATCH 3/3] mm/rmap: use folio_large_nr_pages() when we are sure it is a large folio Wei Yang
2025-08-15 10:04 ` Lorenzo Stoakes
2025-08-16 6:32 ` David Hildenbrand
2025-08-15 10:11 ` [PATCH 0/3] mm/rmap: small cleanup for __folio_remove_rmap() Lorenzo Stoakes
2025-08-16 0:36 ` Wei Yang
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=88117e56-6b81-4601-a954-26d5f630aabd@redhat.com \
--to=david@redhat.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=harry.yoo@oracle.com \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=richard.weiyang@gmail.com \
--cc=riel@surriel.com \
--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