f6bb2a2c0b
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. Link: http://lkml.kernel.org/r/20180313132639.17387-8-willy@infradead.org Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Cc: Darrick J. Wong <darrick.wong@oracle.com> Cc: Dave Chinner <david@fromorbit.com> Cc: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
24 lines
818 B
C
24 lines
818 B
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
#ifndef _LINUX_XARRAY_H
|
|
#define _LINUX_XARRAY_H
|
|
/*
|
|
* eXtensible Arrays
|
|
* Copyright (c) 2017 Microsoft Corporation
|
|
* Author: Matthew Wilcox <mawilcox@microsoft.com>
|
|
*/
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#define xa_trylock(xa) spin_trylock(&(xa)->xa_lock)
|
|
#define xa_lock(xa) spin_lock(&(xa)->xa_lock)
|
|
#define xa_unlock(xa) spin_unlock(&(xa)->xa_lock)
|
|
#define xa_lock_bh(xa) spin_lock_bh(&(xa)->xa_lock)
|
|
#define xa_unlock_bh(xa) spin_unlock_bh(&(xa)->xa_lock)
|
|
#define xa_lock_irq(xa) spin_lock_irq(&(xa)->xa_lock)
|
|
#define xa_unlock_irq(xa) spin_unlock_irq(&(xa)->xa_lock)
|
|
#define xa_lock_irqsave(xa, flags) \
|
|
spin_lock_irqsave(&(xa)->xa_lock, flags)
|
|
#define xa_unlock_irqrestore(xa, flags) \
|
|
spin_unlock_irqrestore(&(xa)->xa_lock, flags)
|
|
|
|
#endif /* _LINUX_XARRAY_H */
|