From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Jonathan Corbet <corbet@lwn.net>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>,
Alice Ryhl <aliceryhl@google.com>,
Boqun Feng <boqun.feng@gmail.com>,
Matthew Wilcox <willy@infradead.org>,
Mike Rapoport <rppt@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, Suren Baghdasaryan <surenb@google.com>,
Hillf Danton <hdanton@sina.com>,
Qi Zheng <zhengqi.arch@bytedance.com>,
SeongJae Park <sj@kernel.org>
Subject: Re: [PATCH] docs/mm: add VMA locks documentation
Date: Mon, 11 Nov 2024 10:31:50 +0000 [thread overview]
Message-ID: <a7653ed5-0acf-4ce7-a10b-6d146096e957@lucifer.local> (raw)
In-Reply-To: <20241111024244.5ro262uyorwhxq3v@master>
On Mon, Nov 11, 2024 at 02:42:44AM +0000, Wei Yang wrote:
> >+Read locks are acquired via :c:func:`!vma_start_read`, which is an optimistic
> >+operation, i.e. it tries to acquire a read lock but returns false if it is
> >+unable to do so. At the end of the read operation, :c:func:`!vma_end_read` is
> >+called to release the VMA read lock. This can be done under RCU alone.
> >+
> >+Writing requires the mmap to be write-locked and the VMA lock to be acquired via
> >+:c:func:`!vma_start_write`, however the write lock is released by the termination or
> >+downgrade of the mmap write lock so no :c:func:`!vma_end_write` is required.
> >+
> >+All this is achieved by the use of per-mm and per-VMA sequence counts, which are
> >+used in order to reduce complexity, especially for operations which write-lock
> >+multiple VMAs at once.
> >+
>
> Hi, Lorenzo
>
> I got a question more than a comment when trying to understand the mechanism.
p>
> I am thinking about the benefit of PER_VMA_LOCK.
>
> For write, we always need to grab mmap_lock w/o PER_VMA_LOCK.
> For read, seems we don't need to grab mmap_lock with PER_VMA_LOCK. So read
> operation benefit the most with PER_VMA_LOCK, right?
Yes this is the point of it, VMA fields are read-mostly and the most natural use
for this is page faulting.
The whole intent is to allow for the read lock under RCU.
next prev parent reply other threads:[~2024-11-11 10:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 19:01 Lorenzo Stoakes
2024-11-07 21:15 ` Jann Horn
2024-11-08 10:35 ` Lorenzo Stoakes
2024-11-08 8:26 ` Kirill A. Shutemov
2024-11-08 8:59 ` Lorenzo Stoakes
2024-11-08 12:25 ` Bagas Sanjaya
2024-11-08 12:29 ` Lorenzo Stoakes
2024-11-08 12:34 ` Lorenzo Stoakes
2024-11-12 1:12 ` Bagas Sanjaya
2024-11-11 2:42 ` Wei Yang
2024-11-11 10:31 ` Lorenzo Stoakes [this message]
2024-11-11 7:07 ` Wei Yang
2024-11-11 10:39 ` Lorenzo Stoakes
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=a7653ed5-0acf-4ce7-a10b-6d146096e957@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.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=richard.weiyang@gmail.com \
--cc=rppt@kernel.org \
--cc=sj@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
--cc=zhengqi.arch@bytedance.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