From: Lorenzo Stoakes <lstoakes@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, Baoquan He <bhe@redhat.com>,
Uladzislau Rezki <urezki@gmail.com>,
Matthew Wilcox <willy@infradead.org>,
David Hildenbrand <david@redhat.com>,
Liu Shixin <liushixin2@huawei.com>, Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH v2 2/4] mm: vmalloc: use rwsem, mutex for vmap_area_lock and vmap_block->lock
Date: Sun, 19 Mar 2023 20:29:16 +0000 [thread overview]
Message-ID: <fadd8558-8917-4012-b5ea-c6376c835cc8@lucifer.local> (raw)
In-Reply-To: <20230319131047.174fa4e29cabe4371b298ed0@linux-foundation.org>
On Sun, Mar 19, 2023 at 01:10:47PM -0700, Andrew Morton wrote:
> On Sun, 19 Mar 2023 07:09:31 +0000 Lorenzo Stoakes <lstoakes@gmail.com> wrote:
>
> > vmalloc() is, by design, not permitted to be used in atomic context and
> > already contains components which may sleep, so avoiding spin locks is not
> > a problem from the perspective of atomic context.
> >
> > The global vmap_area_lock is held when the red/black tree rooted in
> > vmap_are_root is accessed and thus is rather long-held and under
> > potentially high contention. It is likely to be under contention for reads
> > rather than write, so replace it with a rwsem.
> >
> > Each individual vmap_block->lock is likely to be held for less time but
> > under low contention, so a mutex is not an outrageous choice here.
> >
> > A subset of test_vmalloc.sh performance results:-
> >
> > fix_size_alloc_test 0.40%
> > full_fit_alloc_test 2.08%
> > long_busy_list_alloc_test 0.34%
> > random_size_alloc_test -0.25%
> > random_size_align_alloc_test 0.06%
> > ...
> > all tests cycles 0.2%
> >
> > This represents a tiny reduction in performance that sits barely above
> > noise.
> >
> > The reason for making this change is to build a basis for vread() to be
> > usable asynchronously, this eliminating the need for a bounce buffer when
> > copying data to userland in read_kcore() and allowing that to be converted
> > to an iterator form.
> >
>
> I'm not understanding the final paragraph. How and where is vread()
> used "asynchronously"?
The basis for saying asynchronous was based on Documentation/filesystems/vfs.rst
describing read_iter() as 'possibly asynchronous read with iov_iter as
destination', and read_iter() is what is (now) invoked when accessing
/proc/kcore.
However I agree this is vague and it is clearer to refer to the fact that we are
now directly writing to user memory and thus wish to avoid spinlocks as we may
need to fault in user memory in doing so.
Would it be ok for you to go ahead and replace that final paragraph with the
below?:-
The reason for making this change is to build a basis for vread() to write
to user memory directly via an iterator; as a result we may cause page
faults during which we must not hold a spinlock. Doing this eliminates the
need for a bounce buffer in read_kcore() and thus permits that to be
converted to also use an iterator, as a read_iter() handler.
next prev parent reply other threads:[~2023-03-19 20:31 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-19 7:09 [PATCH v2 0/4] convert read_kcore(), vread() to use iterators Lorenzo Stoakes
2023-03-19 7:09 ` [PATCH v2 1/4] fs/proc/kcore: Avoid bounce buffer for ktext data Lorenzo Stoakes
2023-03-20 9:58 ` David Hildenbrand
2023-03-19 7:09 ` [PATCH v2 2/4] mm: vmalloc: use rwsem, mutex for vmap_area_lock and vmap_block->lock Lorenzo Stoakes
2023-03-19 20:10 ` Andrew Morton
2023-03-19 20:29 ` Lorenzo Stoakes [this message]
2023-03-19 20:47 ` Matthew Wilcox
2023-03-19 21:16 ` Lorenzo Stoakes
2023-03-20 8:40 ` Lorenzo Stoakes
2023-03-20 7:54 ` Uladzislau Rezki
2023-03-20 8:25 ` Lorenzo Stoakes
2023-03-20 8:32 ` Uladzislau Rezki
2023-03-20 8:35 ` Lorenzo Stoakes
2023-03-20 11:20 ` Uladzislau Rezki
2023-03-21 1:09 ` Dave Chinner
2023-03-21 5:23 ` Uladzislau Rezki
2023-03-21 7:45 ` Lorenzo Stoakes
2023-03-21 8:54 ` Uladzislau Rezki
2023-03-21 10:05 ` Dave Chinner
2023-03-21 10:24 ` Uladzislau Rezki
2023-03-22 13:18 ` Uladzislau Rezki
2023-03-22 17:47 ` Matthew Wilcox
2023-03-22 18:01 ` Uladzislau Rezki
2023-03-22 19:15 ` Uladzislau Rezki
2023-03-23 12:47 ` Uladzislau Rezki
2023-03-24 5:25 ` Dave Chinner
2023-03-24 5:31 ` Matthew Wilcox
2023-03-27 0:38 ` Dave Chinner
2023-03-27 17:22 ` Uladzislau Rezki
2023-03-28 2:53 ` Dave Chinner
2023-03-28 12:40 ` Uladzislau Rezki
2023-03-19 7:09 ` [PATCH v2 3/4] fs/proc/kcore: convert read_kcore() to read_kcore_iter() Lorenzo Stoakes
2023-03-19 7:09 ` [PATCH v2 4/4] mm: vmalloc: convert vread() to vread_iter() 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=fadd8558-8917-4012-b5ea-c6376c835cc8@lucifer.local \
--to=lstoakes@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=david@redhat.com \
--cc=jolsa@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liushixin2@huawei.com \
--cc=urezki@gmail.com \
--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