linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Danilo Krummrich <dakr@redhat.com>
Cc: Peng Zhang <perlyzhang@gmail.com>,
	maple-tree@lists.infradead.org, linux-mm@kvack.org,
	Andrew Morton <akpm@linux-foundation.org>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	linux-kernel@vger.kernel.org,
	Peng Zhang <zhangpeng.00@bytedance.com>,
	David Airlie <airlied@redhat.com>,
	Boris Brezillon <boris.brezillon@collabora.com>
Subject: Re: [PATCH v2 14/16] maple_tree: Refine mas_preallocate() node calculations
Date: Mon, 26 Jun 2023 14:19:17 +0100	[thread overview]
Message-ID: <ZJmQVeiLtkFAGfW0@casper.infradead.org> (raw)
In-Reply-To: <43ce08db-210a-fec8-51b4-351625b3cdfb@redhat.com>

On Mon, Jun 26, 2023 at 02:38:06AM +0200, Danilo Krummrich wrote:
> On the other hand, unless I miss something (and if so, please let me know),
> something is bogus with the API then.
> 
> While the documentation of the Advanced API of the maple tree explicitly
> claims that the user of the API is responsible for locking, this should be
> limited to the bounds set by the maple tree implementation. Which means, the
> user must decide for either the internal (spin-) lock or an external lock
> (which possibly goes away in the future) and acquire and release it
> according to the rules maple tree enforces through lockdep checks.
> 
> Let's say one picks the internal lock. How is one supposed to ensure the
> tree isn't modified using the internal lock with mas_preallocate()?
> 
> Besides that, I think the documentation should definitely mention this
> limitation and give some guidance for the locking.
> 
> Currently, from an API perspective, I can't see how anyone not familiar with
> the implementation details would be able to recognize this limitation.
> 
> In terms of the GPUVA manager, unfortunately, it seems like I need to drop
> the maple tree and go back to using a rb-tree, since it seems there is no
> sane way doing a worst-case pre-allocation that does not suffer from this
> limitation.

I haven't been paying much attention here (too many other things going
on), but something's wrong.

First, you shouldn't need to preallocate.  Preallocation is only there
for really gnarly cases.  The way this is *supposed* to work is that
the store walks down to the leaf, attempts to insert into that leaf
and tries to allocate new nodes with __GFP_NOWAIT.  If that fails,
it drops the spinlock, allocates with the gfp flags you've specified,
then rewalks the tree to retry the store, this time with allocated
nodes in its back pocket so that the store will succeed.


  reply	other threads:[~2023-06-26 13:19 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 20:39 [PATCH v2 00/16] Reduce preallocations for maple tree Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 01/16] maple_tree: Add benchmarking for mas_for_each Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 02/16] maple_tree: Add benchmarking for mas_prev() Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 03/16] mm: Move unmap_vmas() declaration to internal header Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 04/16] mm: Change do_vmi_align_munmap() side tree index Liam R. Howlett
2023-06-20 12:26   ` Sergey Senozhatsky
2023-06-20 13:04     ` Liam R. Howlett
2023-06-21  0:10       ` Sergey Senozhatsky
2023-06-12 20:39 ` [PATCH v2 05/16] mm: Remove prev check from do_vmi_align_munmap() Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 06/16] maple_tree: Introduce __mas_set_range() Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 07/16] mm: Remove re-walk from mmap_region() Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 08/16] maple_tree: Adjust node allocation on mas_rebalance() Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 09/16] maple_tree: Re-introduce entry to mas_preallocate() arguments Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 10/16] mm: Use vma_iter_clear_gfp() in nommu Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 11/16] mm: Set up vma iterator for vma_iter_prealloc() calls Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 12/16] maple_tree: Move mas_wr_end_piv() below mas_wr_extend_null() Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 13/16] maple_tree: Update mas_preallocate() testing Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 14/16] maple_tree: Refine mas_preallocate() node calculations Liam R. Howlett
2023-06-22 16:41   ` Danilo Krummrich
2023-06-25  3:28     ` Peng Zhang
2023-06-26  0:38       ` Danilo Krummrich
2023-06-26 13:19         ` Matthew Wilcox [this message]
2023-06-26 14:27           ` Danilo Krummrich
2023-06-26 14:49             ` Peng Zhang
2023-06-26 18:21               ` Danilo Krummrich
2023-06-26 14:52             ` Matthew Wilcox
2023-06-26 18:37               ` Danilo Krummrich
2023-06-27  1:58                 ` Liam R. Howlett
2023-06-27 13:15                   ` Danilo Krummrich
2023-06-27 16:11                     ` Liam R. Howlett
2023-06-27 21:06                       ` Danilo Krummrich
2023-06-26 14:08         ` Peng Zhang
2023-06-26 14:30           ` Danilo Krummrich
2023-06-12 20:39 ` [PATCH v2 15/16] maple_tree: Reduce resets during store setup Liam R. Howlett
2023-06-12 20:39 ` [PATCH v2 16/16] mm/mmap: Change vma iteration order in do_vmi_align_munmap() Liam R. Howlett
2023-06-15  8:33 ` [PATCH v2 00/16] Reduce preallocations for maple tree Yin, Fengwei

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=ZJmQVeiLtkFAGfW0@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=airlied@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=boris.brezillon@collabora.com \
    --cc=dakr@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maple-tree@lists.infradead.org \
    --cc=perlyzhang@gmail.com \
    --cc=zhangpeng.00@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;
as well as URLs for NNTP newsgroup(s).