linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Oscar Salvador <osalvador@suse.de>
Cc: akpm@linux-foundation.org, hughd@google.com, willy@infradead.org,
	david@redhat.com, 21cnbao@gmail.com, ryan.roberts@arm.com,
	ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] mm: mincore: use folio_pte_batch() to batch process large folios
Date: Thu, 27 Mar 2025 19:54:55 +0800	[thread overview]
Message-ID: <2f44fda6-c20c-4d90-ae83-e650c43a16ff@linux.alibaba.com> (raw)
In-Reply-To: <Z-UtOF97qjcm4Hgu@localhost.localdomain>



On 2025/3/27 18:49, Oscar Salvador wrote:
> On Wed, Mar 26, 2025 at 11:38:11AM +0800, Baolin Wang wrote:
>> @@ -118,16 +120,31 @@ static int mincore_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
>>   		walk->action = ACTION_AGAIN;
>>   		return 0;
>>   	}
>> -	for (; addr != end; ptep++, addr += PAGE_SIZE) {
>> +	for (; addr != end; ptep += step, addr += step * PAGE_SIZE) {
>>   		pte_t pte = ptep_get(ptep);
>>   
>> +		step = 1;
>>   		/* We need to do cache lookup too for pte markers */
>>   		if (pte_none_mostly(pte))
>>   			__mincore_unmapped_range(addr, addr + PAGE_SIZE,
>>   						 vma, vec);
>> -		else if (pte_present(pte))
>> -			*vec = 1;
>> -		else { /* pte is a swap entry */
>> +		else if (pte_present(pte)) {
>> +			if (pte_batch_hint(ptep, pte) > 1) {
> 
> AFAIU, you will only batch if the CONT_PTE is set, but that is only true for arm64,
> and so we lose the ability to batch in e.g: x86 when we have contiguous
> entries, right?
> 
> So why not have folio_pte_batch take care of it directly without involving
> pte_batch_hint here?

Good question, this was the first approach I tried.

However, I found there was a obvious performance regression with small 
folios (where CONT_PTE is not set). I think the overhead introduced by 
vm_normal_folio() and folio_pte_batch() is greater than the optimization 
gained from batch processing small folios.

For large folios where CONT_PTE is set, ptep_get()--->contpte_ptep_get() 
wastes a significant amount of CPU time, so using folio_pte_batch() can 
improve the performance obviously.


  reply	other threads:[~2025-03-27 11:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-26  3:38 [PATCH 0/2] Fix mincore() tmpfs test failure Baolin Wang
2025-03-26  3:38 ` [PATCH 1/2] selftests: mincore: fix tmpfs mincore " Baolin Wang
2025-03-27 14:36   ` Zi Yan
2025-03-30 19:47     ` Baolin Wang
2025-04-01 12:54   ` David Hildenbrand
2025-04-07  3:49     ` Baolin Wang
2025-04-07  7:49       ` David Hildenbrand
2025-04-07  8:35         ` Baolin Wang
2025-03-26  3:38 ` [PATCH 2/2] mm: mincore: use folio_pte_batch() to batch process large folios Baolin Wang
2025-03-27 10:49   ` Oscar Salvador
2025-03-27 11:54     ` Baolin Wang [this message]
2025-03-27 14:08   ` Ryan Roberts
2025-03-28 13:10     ` Oscar Salvador
2025-03-30 19:57     ` Baolin Wang
2025-04-01 10:45       ` Ryan Roberts
2025-04-01 13:04         ` David Hildenbrand
2025-04-07  6:33           ` Baolin Wang
2025-04-14 13:46             ` Ryan Roberts
2025-05-07  5:12   ` Dev Jain
2025-05-07  9:48     ` Baolin Wang
2025-05-07  9:54       ` David Hildenbrand
2025-05-07 10:03         ` Baolin Wang
2025-05-07 11:14           ` Ryan Roberts

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=2f44fda6-c20c-4d90-ae83-e650c43a16ff@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=osalvador@suse.de \
    --cc=ryan.roberts@arm.com \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.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;
as well as URLs for NNTP newsgroup(s).