linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>,
	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 12:32:36 +0200	[thread overview]
Message-ID: <aeb43195-64c0-464d-995d-0fe53d5674fe@redhat.com> (raw)
In-Reply-To: <d18b67f8-92a4-4e10-9341-fb7e075a885f@gmail.com>

Hi,

please don't top-post.

On 16.08.25 12:05, Giorgi Tchankvetadze wrote:
> Since the compiler can prove the expression will always be false in one
> branch, there's no need to execute that computation at all in that
> branch, right?

It's mostly a matter of making the code easier to read. The way we have 
it right now, we calculate partially_mapped in all cases just before the 
end of the case.

For example, partially_mapped is irrelevant for !folio_test_anon() and 
!folio_test_large(), but we rely on the compiler to figure that out and 
optimize the code accordingly.

Having something like

if (folio_test_large(folio) && folio_test_anon(folio) &&
     !folio_test_partially_mapped(folio)) {
	switch (level) {
	case PGTABLE_LEVEL_PTE:
		if (IS_ENABLED(CONFIG_NO_PAGE_MAPCOUNT)) {
			...
			break;
		}
		partially_mapped = ...
	case PGTABLE_LEVEL_PMD:
		...
	}
	if (partially_mapped)
		deferred_split_folio(folio, true);
}

Could be done, but it's arguably harder to read.

> 
> On 8/16/2025 1:16 PM, David Hildenbrand wrote:
>> 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.
> 


-- 
Cheers

David / dhildenb



  reply	other threads:[~2025-08-16 10:32 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
2025-08-16 10:05           ` Giorgi Tchankvetadze
2025-08-16 10:32             ` David Hildenbrand [this message]
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=aeb43195-64c0-464d-995d-0fe53d5674fe@redhat.com \
    --to=david@redhat.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=giorgitchankvetadze1997@gmail.com \
    --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