Re: [PATCH v9 07/61] xarray: Add the xa_lock to the radix_tree_root

From: Ross Zwisler
Date: Thu Apr 12 2018 - 16:59:41 EST


On Tue, Mar 13, 2018 at 7:25 AM, Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
> From: Matthew Wilcox <mawilcox@xxxxxxxxxxxxx>
>
> This results in no change in structure size on 64-bit machines as it
> fits in the padding between the gfp_t and the void *. 32-bit machines
> will grow the structure from 8 to 12 bytes. Almost all radix trees
> are protected with (at least) a spinlock, so as they are converted from
> radix trees to xarrays, the data structures will shrink again.
>
> Initialising the spinlock requires a name for the benefit of lockdep,
> so RADIX_TREE_INIT() now needs to know the name of the radix tree it's
> initialising, and so do IDR_INIT() and IDA_INIT().
>
> Also add the xa_lock() and xa_unlock() family of wrappers to make it
> easier to use the lock. If we could rely on -fplan9-extensions in
> the compiler, we could avoid all of this syntactic sugar, but that
> wasn't added until gcc 4.6.
>
> Signed-off-by: Matthew Wilcox <mawilcox@xxxxxxxxxxxxx>
> Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>

This is causing build breakage in the radix tree test suite in the
current linux/master:

5d1365940a68 (linux/master) Merge
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Here's the first breakage:

cc -I. -I../../include -g -O2 -Wall -D_LGPL_SOURCE -fsanitize=address
-c -o idr.o idr.c
In file included from ./linux/radix-tree.h:6:0,
from ./linux/../../../../include/linux/idr.h:15,
from ./linux/idr.h:1,
from idr.c:4:
./linux/../../../../include/linux/idr.h: In function âidr_init_baseâ:
./linux/../../../../include/linux/radix-tree.h:129:2: warning:
implicit declaration of function âspin_lock_initâ; did you mean
âspinlock_tâ? [-Wimplicit-function-declaration]
spin_lock_init(&(root)->xa_lock); \
^
./linux/../../../../include/linux/idr.h:126:2: note: in expansion of
macro âINIT_RADIX_TREEâ
INIT_RADIX_TREE(&idr->idr_rt, IDR_RT_MARKER);
^~~~~~~~~~~~~~~