mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 22:37:45 -04:00
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/[email protected] Signed-off-by: Matthew Wilcox <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Cc: Darrick J. Wong <[email protected]> Cc: Dave Chinner <[email protected]> Cc: Ryusuke Konishi <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
25 lines
818 B
C
25 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 <[email protected]>
|
|
*/
|
|
|
|
#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 */
|