From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Baolin Wang <baolin.wang@linux.alibaba.com>,
Lance Yang <lance.yang@linux.dev>
Cc: baohua@kernel.org, akpm@linux-foundation.org, ljs@kernel.org,
riel@surriel.com, liam@infradead.org, vbabka@kernel.org,
harry@kernel.org, jannh@google.com, qi.zheng@linux.dev,
pfalcato@suse.de, ayushr@modal.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: synchronize with PTE table reclaim for all folio sizes
Date: Sat, 7 Nov 2026 21:05:52 +0100 [thread overview]
Message-ID: <47fee2b0-091f-4c20-9496-eff844ab2f6f@kernel.org> (raw)
In-Reply-To: <9916bea5-3b53-43a0-8f65-cc33995adb23@linux.alibaba.com>
On 11/6/26 03:54, Baolin Wang wrote:
>
>
> On 11/6/26 10:33 AM, Lance Yang wrote:
>>
>> On Fri, Nov 06, 2026 at 09:57:47AM +0800, Baolin Wang wrote:
>>>
>>>
>>>
>>> Thanks.
>>
>> Cheers!
>>
>
> .......
>
>>>
>>> I'm afraid the memory barrier here is subtle. __folio_remove_rmap() is
>>> complex, and in the CONFIG_NO_PAGE_MAPCOUNT branch,
>>> folio_sub_return_large_mapcount() doesn't provide full ordering, so we
>>> may still need smp_wmb().
>>
>> Yeah, agreed for large folios. In the diff above, only order-0 folios
>> use smp_rmb().
>>
>> Note that order-0 folios take the fully ordered atomic_add_negative()
>> branch and skip the CONFIG_NO_PAGE_MAPCOUNT branch entirely.
>
> Yes.
>
>> static __always_inline void __folio_remove_rmap(struct folio *folio,
>> struct page *page, int nr_pages, struct vm_area_struct *vma,
>> enum pgtable_level level)
>> {
>> ...
>> switch (level) {
>> case PGTABLE_LEVEL_PTE:
>> if (!folio_test_large(folio)) {
>> nr = atomic_add_negative(-1, &folio->_mapcount);
>> break;
>> }
>>
>> if (IS_ENABLED(CONFIG_NO_PAGE_MAPCOUNT)) {
>> nr = folio_sub_return_large_mapcount(folio, nr_pages, vma);
>> ...
>> }
>> ...
>> }
>> ...
>> }
>>
>> And large folios still take the PMD lock :D
>
> IIUC, the memory barrier optimization targets all non-PMD-sized folios
> (including large folios). That is, for PMD-sized large folios we still
> use the original PMD lock, while for other non-PMD-sized folios we can
> use memory barriers to sync.
It would be nice to prototype a patch and document the required memory barriers
and how it is expected to work.
--
Cheers,
David
next prev parent reply other threads:[~2026-11-07 20:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 2:56 Baolin Wang
2026-11-05 3:22 ` Qi Zheng
2026-11-05 4:54 ` Lance Yang
2026-11-05 5:48 ` Lance Yang
2026-11-05 9:00 ` Baolin Wang
2026-11-05 10:06 ` David Hildenbrand (Arm)
2026-11-05 11:18 ` Baolin Wang
2026-11-05 13:22 ` Lance Yang
2026-11-05 19:35 ` David Hildenbrand (Arm)
2026-11-06 1:57 ` Baolin Wang
2026-11-06 2:33 ` Lance Yang
2026-11-06 2:54 ` Baolin Wang
2026-11-07 20:05 ` David Hildenbrand (Arm) [this message]
2026-11-06 6:24 ` Barry Song
2026-11-06 8:54 ` Baolin Wang
2026-11-06 9:15 ` Lance Yang
2026-11-06 9:29 ` Lance Yang
2026-11-06 9:50 ` Baolin Wang
2026-11-06 9:56 ` Barry Song
2026-11-06 13:56 ` Baolin Wang
2026-11-05 11:37 ` Pedro Falcato
2026-11-06 2:12 ` Baolin Wang
2026-11-07 19:58 ` David Hildenbrand (Arm)
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=47fee2b0-091f-4c20-9496-eff844ab2f6f@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ayushr@modal.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=harry@kernel.org \
--cc=jannh@google.com \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=pfalcato@suse.de \
--cc=qi.zheng@linux.dev \
--cc=riel@surriel.com \
--cc=vbabka@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®