kernel: introduce brlock
PATCH 1/2 kernel: introduce brlock
This second patchset scales the vfsmount lock. When it was last posted, you were worried about commenting of lock requirements, and impact on the slowpath. I have added comments and also done some slowpath measurements.
--
brlock: introduce special brlocks
This patch introduces special brlocks, these can only be used as global locks, and use some preprocessor trickery to allow us to retain a more optimal per-cpu lock implementation. We don't bother working around lockdep yet.
The other thing we can do in future is a really neat atomic-free implementation like Dave M did for the old brlocks, so we might actually be able to speed up the single-thread path for these things.
--- include/linux/brlock.h | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+)
include/linux/brlock.h new file +112 -0
@@ -0,0 +1,112 @@ +/* +* Specialised big-reader spinlock. Can only be declared as global variables +* to avoid overhead and keep things simple (and we don't want to start using +* these inside dynamically allocated structures). +* +* Copyright 2009, Nick Piggin, Novell Inc. +*/ +#ifndef __LINUX_BRLOCK_H +#define __LINUX_BRLOCK_H + +#include <linux/spinlock.h> +#include <linux/percpu.h> +#include <asm/atomic.h> + +#if defined(CONFIG_SMP ) && !defined(CONFIG_LOCKDEP ) +#define DECLARE_BRLOCK (name) \ + DECLARE_PER_CPU(spinlock_t, name##_lock); \ + extern void name##_lock_init(void); \ + static inline void name##_rlock(void) { \ + spinlock_t *lock; \ + lock = &get_cpu_var(name##_lock); \ + spin_lock(lock); \ + put_cpu_var(name##_lock); \ + } \ + static inline void name##_runlock(void) { \ + spinlock_t *lock; \ + lock = &__get_cpu_var(name##_lock); \ + spin_unlock(lock); \ + } \ + extern void name##_wlock(void); \ + extern void name##_wunlock(void); \ + static inline int name##_atomic_dec_and_rlock(atomic_t *a) { \ + int ret; \ + spinlock_t *lock; \ + lock = &get_cpu_var(name##_lock); \ + ret = atomic_dec_and_lock(a, lock); \ + put_cpu_var(name##_lock); \ + return ret; \ + } \ + extern int name##_atomic_dec_and_wlock__failed(atomic_t *a); \ + static inline int name##_atomic_dec_and_wlock(atomic_t *a) { \ + if (atomic_add_unless(a, -1, 1)) \ + return 0; \ + return name##_atomic_dec_and_wlock__failed(a); \ + } + +#define DEFINE_BRLOCK (name) \ + DEFINE_PER_CPU(spinlock_t, name##_lock); \ + void name##_lock_init(void) { \ + int i; \ + for_each_possible_cpu(i) { \ + spinlock_t *lock; \ + lock = &per_cpu(name##_lock, i); \ + spin_lock_init(lock); \ + } \ + } \ + void name##_wlock(void) { \ + int i; \ + for_each_online_cpu(i) { \ + spinlock_t *lock; \ + lock = &per_cpu(name##_lock, i); \ + spin_lock(lock); \ + } \ + } \ + void name##_wunlock(void) { \ + int i; \ + for_each_online_cpu(i) { \ + spinlock_t *lock; \ + lock = &per_cpu(name##_lock, i); \ + spin_unlock(lock); \ + } \ + } \ + int name##_atomic_dec_and_wlock__failed(atomic_t *a) { \ + name##_wlock(); \ + if (!atomic_dec_and_test(a)) { \ + name##_wunlock(); \ + return 0; \ + } \ + return 1; \ + } + +#else + +#define DECLARE_BRLOCK (name) \ + extern spinlock_t name##_lock; \ + static inline void name##_lock_init(void) { \ + spin_lock_init(&name##_lock); \ + } \ + static inline void name##_rlock(void) { \ + spin_lock(&name##_lock); \ + } \ + static inline void name##_runlock(void) { \ + spin_unlock(&name##_lock); \ + } \ + static inline void name##_wlock(void) { \ + spin_lock(&name##_lock); \ + } \ + static inline void name##_wunlock(void) { \ + spin_unlock(&name##_lock); \ + } \ + static inline int name##_atomic_dec_and_rlock(atomic_t *a) { \ + return atomic_dec_and_lock(a, &name##_lock); \ + } \ + static inline int name##_atomic_dec_and_wlock(atomic_t *a) { \ + return atomic_dec_and_lock(a, &name##_lock); \ + } + +#define DEFINE_BRLOCK (name) \ + spinlock_t name##_lock +#endif + +#endif
PATCH 2/2 fs: scale vfsmount_lock
fs: scale vfsmount_lock
Use a brlock for the vfsmount lock. It must be taken for write whenever modifying the mount hash or associated fields, and may be taken for read when performing mount hash lookups.
The slowpath will be made significantly slower due to use of brlock. On a 64 core, 64 socket, 32 node Altix system (so a decent amount of latency to remote nodes), a simple umount microbenchmark (mount --bind mnt mnt2 ; umount mnt2 loop 1000 times), before this patch it took 6.8s, afterwards took 7.1s, for about 5% increase in elapsed time.
Number of atomics should remain the same for fastpath rlock cases, though code will be slightly larger due to per-cpu access. Scalability will probably not be much improved in common cases yet, due to other locks getting in the way. However independent path lookups over mountpoints should be one case where scalability is improved.
--- fs/dcache.c | 4 - fs/namei.c | 13 +-- fs/namespace.c | 178 ++++++++++++++++++++++++++++----------------- fs/pnode.c | 11 ++ fs/proc/base.c | 4 - include/linux/mount.h | 4 - kernel/audit_tree.c | 6 - security/tomoyo/realpath.c | 4 - 8 files changed, 141 insertions(+), 83 deletions(-)
fs/dcache.c +6 -5
@@ -1928,7 +1928,7 @@ char *__d_path(const struct path *path,char *end = buffer + buflen;char *retval; -spin_lock (&vfsmount_lock); +vfsmount_rlock ();prepend (&end, &buflen,"\0" ,1 );if (d_unlinked (dentry) && (prepend (&end, &buflen," (deleted)" ,10 ) !=0 ))
@@ -1964,7 +1964,7 @@ char *__d_path(const struct path *path, } out: -spin_unlock (&vfsmount_lock); +vfsmount_runlock ();return retval; global_root:
@@ -2195,11 +2195,12 @@ int path_is_under(struct path *path1, ststruct vfsmount *mnt = path1->mnt;struct dentry *dentry = path1->dentry;int res; -spin_lock (&vfsmount_lock); + +vfsmount_rlock ();if (mnt != path2->mnt) {for (;;) {if (mnt->mnt_parent == mnt) { -spin_unlock (&vfsmount_lock); +vfsmount_runlock ();return 0 ; }if (mnt->mnt_parent == path2->mnt)
@@ -2209,7 +2210,7 @@ int path_is_under(struct path *path1, st dentry = mnt->mnt_mountpoint; } res =is_subdir (dentry, path2->dentry); -spin_unlock (&vfsmount_lock); +vfsmount_runlock ();return res; }EXPORT_SYMBOL (path_is_under);
fs/namei.c +4 -3
@@ -600,15 +600,16 @@ int follow_up(struct path *path) {struct vfsmount *parent;struct dentry *mountpoint; -spin_lock (&vfsmount_lock); + +vfsmount_rlock (); parent = path->mnt->mnt_parent;if (parent == path->mnt) { -spin_unlock (&vfsmount_lock); +vfsmount_runlock ();return 0 ; }mntget (parent); mountpoint =dget (path->mnt->mnt_mountpoint); -spin_unlock (&vfsmount_lock); +vfsmount_runlock ();dput (path->dentry); path->dentry = mountpoint;mntput (path->mnt);
fs/namespace.c +108 -66
487 lines not on this page · raw message
fs/pnode.c +9 -2
@@ -126,6 +126,9 @@ static int do_make_slave(struct vfsmountreturn 0 ; } +/* +* vfsmount lock must be held for write +*/ void change_mnt_propagation (struct vfsmount *mnt,int type) {if (type ==MS_SHARED ) {
@@ -270,12 +273,12 @@ int propagate_mnt(struct vfsmount *dest_ prev_src_mnt = child; } out: -spin_lock (&vfsmount_lock); +vfsmount_wlock ();while (!list_empty (&tmp_list)) { child = list_first_entry(&tmp_list, struct vfsmount, mnt_hash);umount_tree (child,0 , &umount_list); } -spin_unlock (&vfsmount_lock); +vfsmount_wunlock ();release_mounts (&umount_list);return ret; }
@@ -296,6 +299,8 @@ static inline int do_refcount_check(stru* other mounts its parent propagates to. * Check if any of these mounts that **do not have submounts** * have more references than 'refcnt'. If so return busy. +* +* vfsmount lock must be held for read or write */ int propagate_mount_busy (struct vfsmount *mnt,int refcnt) {
@@ -353,6 +358,8 @@ static void __propagate_umount(struct vf* collect all mounts that receive propagation from the mount in @list, * and return these additional mounts in the same list. * @list: the list of mounts to be unmounted. +* +* vfsmount lock must be held for write */ int propagate_umount (struct list_head *list) {
fs/internal.h +4 -1
@@ -9,6 +9,8 @@* 2 of the License, or (at your option) any later version. */ +#include <linux/brlock.h> +struct super_block ;struct linux_binprm ;struct path ;
@@ -70,7 +72,8 @@ extern struct vfsmount *copy_tree(structextern void __init mnt_init (void ); -extern spinlock_t vfsmount_lock; +DECLARE_BRLOCK (vfsmount); +/* * fs_struct.c
Re: [patch 2/2] fs: scale vfsmount_lock
Quoted 19 lines · Nick Piggin
fs: scale
vfsmount_lockUse a brlock for the vfsmount lock. It must be taken for write whenever modifying the mount hash or associated fields, and may be taken for read when performing mount hash lookups.
The slowpath will be made significantly slower due to use of brlock. On a 64 core, 64 socket, 32 node Altix system (so a decent amount of latency to remote nodes), a simple umount microbenchmark (mount --bind mnt mnt2 ; umount mnt2 loop 1000 times), before this patch it took 6.8s, afterwards took 7.1s, for about 5% increase in elapsed time.
Number of atomics should remain the same for fastpath rlock cases, though code will be slightly larger due to per-cpu access. Scalability will probably not be much improved in common cases yet, due to other locks getting in the way. However independent path lookups over mountpoints should be one case where scalability is improved.
Signed-off-by Nick Piggin <[email protected]>
Quoted 10 lines
--- fs/dcache.c | 4 - fs/namei.c | 13 +-- fs/namespace.c | 178 ++++++++++++++++++++++++++++----------------- fs/pnode.c | 11 ++ fs/proc/base.c | 4 - include/linux/mount.h | 4 - kernel/audit_tree.c | 6 - security/tomoyo/realpath.c | 4 - 8 files changed, 141 insertions(+), 83 deletions(-)
This diffstat is obviously not refreshed since your vfsmount lock cleanup, sorry.
Re: [patch 2/2] fs: scale vfsmount_lock
In reply to Nick PigginHere is patch 2 with the new syntax.
--
fs: brlock vfsmount_lock
Use a brlock for the vfsmount lock. It must be taken for write whenever modifying the mount hash or associated fields, and may be taken for read when performing mount hash lookups.
The slowpath will be made significantly slower due to use of brlock. On a 64 core, 64 socket, 32 node Altix system (so a decent amount of latency to remote nodes), a simple umount microbenchmark (mount --bind mnt mnt2 ; umount mnt2 loop 1000 times), before this patch it took 6.8s, afterwards took 7.1s, for about 5% increase in elapsed time.
Number of atomics should remain the same for fastpath rlock cases, though code will be slightly larger due to per-cpu access. Scalability will probably not be much improved in common cases yet, due to other locks getting in the way. However independent path lookups over mountpoints should be one case where scalability is improved.
--- fs/dcache.c | 11 +-- fs/internal.h | 5 + fs/namei.c | 7 +- fs/namespace.c | 174 +++++++++++++++++++++++++++++++++++---------------------- fs/pnode.c | 11 ++- 5 files changed, 131 insertions(+), 77 deletions(-)
fs/dcache.c +6 -5
@@ -1928,7 +1928,7 @@ char *__d_path(const struct path *path,char *end = buffer + buflen;char *retval; -spin_lock (&vfsmount_lock); +br_read_lock (vfsmount_lock);prepend (&end, &buflen,"\0" ,1 );if (d_unlinked (dentry) && (prepend (&end, &buflen," (deleted)" ,10 ) !=0 ))
@@ -1964,7 +1964,7 @@ char *__d_path(const struct path *path, } out: -spin_unlock (&vfsmount_lock); +br_read_unlock (vfsmount_lock);return retval; global_root:
@@ -2195,11 +2195,12 @@ int path_is_under(struct path *path1, ststruct vfsmount *mnt = path1->mnt;struct dentry *dentry = path1->dentry;int res; -spin_lock (&vfsmount_lock); + +br_read_lock (vfsmount_lock);if (mnt != path2->mnt) {for (;;) {if (mnt->mnt_parent == mnt) { -spin_unlock (&vfsmount_lock); +br_read_unlock (vfsmount_lock);return 0 ; }if (mnt->mnt_parent == path2->mnt)
@@ -2209,7 +2210,7 @@ int path_is_under(struct path *path1, st dentry = mnt->mnt_mountpoint; } res =is_subdir (dentry, path2->dentry); -spin_unlock (&vfsmount_lock); +br_read_unlock (vfsmount_lock);return res; }EXPORT_SYMBOL (path_is_under);
fs/namei.c +4 -3
@@ -600,15 +600,16 @@ int follow_up(struct path *path) {struct vfsmount *parent;struct dentry *mountpoint; -spin_lock (&vfsmount_lock); + +br_read_lock (vfsmount_lock); parent = path->mnt->mnt_parent;if (parent == path->mnt) { -spin_unlock (&vfsmount_lock); +br_read_unlock (vfsmount_lock);return 0 ; }mntget (parent); mountpoint =dget (path->mnt->mnt_mountpoint); -spin_unlock (&vfsmount_lock); +br_read_unlock (vfsmount_lock);dput (path->dentry); path->dentry = mountpoint;mntput (path->mnt);
fs/namespace.c +108 -66
487 lines not on this page · raw message
fs/pnode.c +9 -2
@@ -126,6 +126,9 @@ static int do_make_slave(struct vfsmountreturn 0 ; } +/* +* vfsmount lock must be held for write +*/ void change_mnt_propagation (struct vfsmount *mnt,int type) {if (type ==MS_SHARED ) {
@@ -270,12 +273,12 @@ int propagate_mnt(struct vfsmount *dest_ prev_src_mnt = child; } out: -spin_lock (&vfsmount_lock); +br_write_lock (vfsmount_lock);while (!list_empty (&tmp_list)) { child = list_first_entry(&tmp_list, struct vfsmount, mnt_hash);umount_tree (child,0 , &umount_list); } -spin_unlock (&vfsmount_lock); +br_write_unlock (vfsmount_lock);release_mounts (&umount_list);return ret; }
@@ -296,6 +299,8 @@ static inline int do_refcount_check(stru* other mounts its parent propagates to. * Check if any of these mounts that **do not have submounts** * have more references than 'refcnt'. If so return busy. +* +* vfsmount lock must be held for read or write */ int propagate_mount_busy (struct vfsmount *mnt,int refcnt) {
@@ -353,6 +358,8 @@ static void __propagate_umount(struct vf* collect all mounts that receive propagation from the mount in @list, * and return these additional mounts in the same list. * @list: the list of mounts to be unmounted. +* +* vfsmount lock must be held for write */ int propagate_umount (struct list_head *list) {
fs/internal.h +4 -1
@@ -9,6 +9,8 @@* 2 of the License, or (at your option) any later version. */ +#include <linux/brlock.h> +struct super_block ;struct linux_binprm ;struct path ;
@@ -70,7 +72,8 @@ extern struct vfsmount *copy_tree(structextern void __init mnt_init (void ); -extern spinlock_t vfsmount_lock; +DECLARE_BRLOCK (vfsmount_lock); +/* * fs_struct.c
Re: [patch 2/2] fs: scale vfsmount_lock
fs/namespace.c char *__d_path(const struct path *path, · line 1930
Quoted 9 lines · Nick Piggin
Here is patch 2 with the new syntax.
--
fs: brlockvfsmount_lockfs/namespace.c +2
-1@@ -1928,7 +1928,7 @@ char *__d_path(const struct path *path, -spin_lock (&vfsmount_lock); +br_read_lock (vfsmount_lock); +DECLARE_BRLOCK (vfsmount_lock);
This is definitely a lot nicer usage. Thanks.
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
Quoted 6 lines · Nick Piggin
+#define
DEFINE_BRLOCK(name)\
+DEFINE_PER_CPU(spinlock_t, name##_lock); \
+ void name##_lock_init(void) { \
+ void name##_wlock(void) { \
+ void name##_wunlock(void) { \
+ int name##_atomic_dec_and_wlock__failed(atomic_t *a) {
What makes these macros unpleasant is that it is no longer possible to tag to the implementation to see what it does, since there is no real declaration for these locks.
Is it possible to change the macros to take the lock name as a parameter, like normal lock/unlock functions do, and then have a single declaration for br_lock_init(), br_wlock(), etc. macros?
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
Quoted 8 lines · Andreas Dilger
Quoted 6 lines · Nick Piggin
+#define
DEFINE_BRLOCK(name)\
+DEFINE_PER_CPU(spinlock_t, name##_lock); \
+ void name##_lock_init(void) { \
+ void name##_wlock(void) { \
+ void name##_wunlock(void) { \
+ int name##_atomic_dec_and_wlock__failed(atomic_t *a) {
Quoted 7 lines
What makes these macros unpleasant is that it is no longer possible to tag to the implementation to see what it does, since there is no real declaration for these locks.
Is it possible to change the macros to take the lock name as a parameter, like normal lock/unlock functions do, and then have a single declaration for
br_lock_init(),br_wlock(), etc. macros?
This gets my vote as well. (I've been repeatedly annoyed by some of the buffer routines that are constructed this way.)
Signature · 2 lines
Frank Mayhar <[email protected]> Google, Inc.
Quoted 8 lines · Andreas Dilger
Quoted 6 lines · Nick Piggin
+#define
DEFINE_BRLOCK(name)\
+DEFINE_PER_CPU(spinlock_t, name##_lock); \
+ void name##_lock_init(void) { \
+ void name##_wlock(void) { \
+ void name##_wunlock(void) { \
+ int name##_atomic_dec_and_wlock__failed(atomic_t *a) {
Quoted 7 lines
What makes these macros unpleasant is that it is no longer possible to tag to the implementation to see what it does, since there is no real declaration for these locks.
Is it possible to change the macros to take the lock name as a parameter, like normal lock/unlock functions do, and then have a single declaration for
br_lock_init(),br_wlock(), etc. macros?
The problem is that then you can't do out of line functions, and things like wlock/wunlock are rather large.
What I think I can do is add macros in the brlock.h file
#define br_rlock(name) ##name_rlock()
So the macro calls the right function and your tag should take you pretty close to the right place.
Any better ideas how to implement this nicely would be welcome. It must be as light-weight as possible in the rlock path though.
Quoted 15 lines · Nick Piggin
Quoted 8 lines · Andreas Dilger
On 2010-03-16, at 06:22, Nick Piggin wrote:
What makes these macros unpleasant is that it is no longer possible to tag to the implementation to see what it does, since there is no real declaration for these locks.Is it possible to change the macros to take the lock name as a parameter, like normal lock/unlock functions do, and then have a single declaration for
br_lock_init(),br_wlock(), etc. macros?The problem is that then you can't do out of line functions, and things like wlock/wunlock are rather large.
What I think I can do is add macros in the
brlock.hfile
Quoted 7 lines
#define
br_rlock(name)##name_rlock()So the macro calls the right function and your tag should take you pretty close to the right place.
Any better ideas how to implement this nicely would be welcome. It must be as light-weight as possible in the rlock path though.
It looks like this. Is it better?
--
brlock: introduce special brlocks
This patch introduces special brlocks, these can only be used as global locks, and use some preprocessor trickery to allow us to retain a more optimal per-cpu lock implementation. We don't bother working around lockdep yet.
The other thing we can do in future is a really neat atomic-free implementation like Dave M did for the old brlocks, so we might actually be able to speed up the single-thread path for these things.
--- include/linux/brlock.h | 120 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+)
include/linux/brlock.h new file +120 -0
@@ -0,0 +1,120 @@ +/* +* Specialised big-reader spinlock. Can only be declared as global variables +* to avoid overhead and keep things simple (and we don't want to start using +* these inside dynamically allocated structures). +* +* Copyright 2009, Nick Piggin, Novell Inc. +*/ +#ifndef __LINUX_BRLOCK_H +#define __LINUX_BRLOCK_H + +#include <linux/spinlock.h> +#include <linux/percpu.h> +#include <asm/atomic.h> + +#define br_lock_init (name) name##_lock_init() +#define br_read_lock (name) name##_read_lock() +#define br_read_unlock (name) name##_read_unlock() +#define br_write_lock (name) name##_write_lock() +#define br_write_unlock (name) name##_write_unlock() +#define atomic_dec_and_br_read_lock (atomic, name) name##_atomic_dec_and_read_lock(atomic) +#define atomic_dec_and_br_write_lock (atomic, name) name##_atomic_dec_and_write_lock(atomic) + +#if defined(CONFIG_SMP ) && !defined(CONFIG_LOCKDEP ) +#define DECLARE_BRLOCK (name) \ + DECLARE_PER_CPU(spinlock_t, name##_lock); \ + extern void name##_lock_init(void); \ + static inline void name##_read_lock(void) { \ + spinlock_t *lock; \ + lock = &get_cpu_var(name##_lock); \ + spin_lock(lock); \ + put_cpu_var(name##_lock); \ + } \ + static inline void name##_read_unlock(void) { \ + spinlock_t *lock; \ + lock = &__get_cpu_var(name##_lock); \ + spin_unlock(lock); \ + } \ + extern void name##_write_lock(void); \ + extern void name##_write_unlock(void); \ + static inline int name##_atomic_dec_and_read_lock(atomic_t *a) { \ + int ret; \ + spinlock_t *lock; \ + lock = &get_cpu_var(name##_lock); \ + ret = atomic_dec_and_lock(a, lock); \ + put_cpu_var(name##_lock); \ + return ret; \ + } \ + extern int name##_atomic_dec_and_write_lock__failed(atomic_t *a); \ + static inline int name##_atomic_dec_and_write_lock(atomic_t *a) { \ + if (atomic_add_unless(a, -1, 1)) \ + return 0; \ + return name##_atomic_dec_and_write_lock__failed(a); \ + } + +#define DEFINE_BRLOCK (name) \ + DEFINE_PER_CPU(spinlock_t, name##_lock); \ + void name##_lock_init(void) { \ + int i; \ + for_each_possible_cpu(i) { \ + spinlock_t *lock; \ + lock = &per_cpu(name##_lock, i); \ + spin_lock_init(lock); \ + } \ + } \ + void name##_write_lock(void) { \ + int i; \ + for_each_online_cpu(i) { \ + spinlock_t *lock; \ + lock = &per_cpu(name##_lock, i); \ + spin_lock(lock); \ + } \ + } \ + void name##_write_unlock(void) { \ + int i; \ + for_each_online_cpu(i) { \ + spinlock_t *lock; \ + lock = &per_cpu(name##_lock, i); \ + spin_unlock(lock); \ + } \ + } \ + int name##_atomic_dec_and_write_lock__failed(atomic_t *a) { \ + name##_write_lock(); \ + if (!atomic_dec_and_test(a)) { \ + name##_write_unlock(); \ + return 0; \ + } \ + return 1; \ + } + +#else + +#define DECLARE_BRLOCK (name) \ + extern spinlock_t name##_lock; \ + static inline void name##_lock_init(void) { \ + spin_lock_init(&name##_lock); \ + } \ + static inline void name##_read_lock(void) { \ + spin_lock(&name##_lock); \ + } \ + static inline void name##_read_unlock(void) { \ + spin_unlock(&name##_lock); \ + } \ + static inline void name##_write_lock(void) { \ + spin_lock(&name##_lock); \ + } \ + static inline void name##_write_unlock(void) { \ + spin_unlock(&name##_lock); \ + } \ + static inline int name##_atomic_dec_and_read_lock(atomic_t *a) { \ + return atomic_dec_and_lock(a, &name##_lock); \ + } \ + static inline int name##_atomic_dec_and_write_lock(atomic_t *a) { \ + return atomic_dec_and_lock(a, &name##_lock); \ + } + +#define DEFINE_BRLOCK (name) \ + spinlock_t name##_lock +#endif + +#endif