From: Qi Zheng <zhengqi.arch@bytedance.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Jann Horn <jannh@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Jonathan Corbet <corbet@lwn.net>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>,
Alice Ryhl <aliceryhl@google.com>,
Boqun Feng <boqun.feng@gmail.com>,
Matthew Wilcox <willy@infradead.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Hillf Danton <hdanton@sina.com>, SeongJae Park <sj@kernel.org>,
Bagas Sanjaya <bagasdotme@gmail.com>,
linux-mm@kvack.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
Matteo Rizzo <matteorizzo@google.com>
Subject: Re: [PATCH v2] docs/mm: add more warnings around page table access
Date: Tue, 19 Nov 2024 16:02:23 +0800 [thread overview]
Message-ID: <9c12aa68-47c5-4def-92ff-7f91502d85a5@bytedance.com> (raw)
In-Reply-To: <b915ff26-e90d-4151-ab2f-607f3c59f501@lucifer.local>
On 2024/11/19 15:48, Lorenzo Stoakes wrote:
> On Tue, Nov 19, 2024 at 02:53:52PM +0800, Qi Zheng wrote:
>>
>>
>> On 2024/11/19 00:47, Jann Horn wrote:
>>> Make it clearer that holding the mmap lock in read mode is not enough
>>> to traverse page tables, and that just having a stable VMA is not enough
>>> to read PTEs.
>>>
>>> Suggested-by: Matteo Rizzo <matteorizzo@google.com>
>>> Suggested-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>>> Signed-off-by: Jann Horn <jannh@google.com>
>>
>> Acked-by: Qi Zheng <zhengqi.arch@bytedance.com>
>>
>>> +
>>> +* On 32-bit architectures, they may be in high memory (meaning they need to be
>>> + mapped into kernel memory to be accessible).
>>> +* When empty, they can be unlinked and RCU-freed while holding an mmap lock or
>>> + rmap lock for reading in combination with the PTE and PMD page table locks.
>>> + In particular, this happens in :c:func:`!retract_page_tables` when handling
>>> + :c:macro:`!MADV_COLLAPSE`.
>>> + So accessing PTE-level page tables requires at least holding an RCU read lock;
>>> + but that only suffices for readers that can tolerate racing with concurrent
>>> + page table updates such that an empty PTE is observed (in a page table that
>>> + has actually already been detached and marked for RCU freeing) while another
>>> + new page table has been installed in the same location and filled with
>>> + entries. Writers normally need to take the PTE lock and revalidate that the
>>> + PMD entry still refers to the same PTE-level page table.
>>> +
>>
>> In practice, this also happens in the retract_page_tables(). Maybe can
>> add a note about this after my patch[1] is merged. ;)
>>
>> [1]. https://lore.kernel.org/lkml/e5b321ffc3ebfcc46e53830e917ad246f7d2825f.1731566457.git.zhengqi.arch@bytedance.com/
>
> You could even queue the doc change up there? :>)
OK, I can add this note to my patch after this patch is merged.
>
> I think one really nice thing with having docs in-tree like this is when we
> change things that alter the doc's accuracy we can queue them up with the
> patch so the doc always stays in sync.
Agree.
>
> I feel you may have accidentally self-volunteered there ;)
>
>>
>> Thanks!
>>
>>>
prev parent reply other threads:[~2024-11-19 8:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-18 16:47 Jann Horn
2024-11-18 17:33 ` Lorenzo Stoakes
2024-11-19 6:53 ` Qi Zheng
2024-11-19 7:48 ` Lorenzo Stoakes
2024-11-19 8:02 ` Qi Zheng [this message]
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=9c12aa68-47c5-4def-92ff-7f91502d85a5@bytedance.com \
--to=zhengqi.arch@bytedance.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.com \
--cc=bagasdotme@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=corbet@lwn.net \
--cc=hdanton@sina.com \
--cc=jannh@google.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=matteorizzo@google.com \
--cc=rppt@kernel.org \
--cc=sj@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.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