[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20121009144842.a4f161c9.akpm@linux-foundation.org>
Date: Tue, 9 Oct 2012 14:48:42 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Lai Jiangshan <laijs@...fujitsu.com>
Cc: linux-kernel@...r.kernel.org,
Alexander Viro <viro@...iv.linux.org.uk>,
Rusty Russell <rusty@...tcorp.com.au>,
Andi Kleen <ak@...ux.intel.com>, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 3/3] lglock: add DEFINE_STATIC_LGLOCK()
On Tue, 9 Oct 2012 11:46:40 +0800
Lai Jiangshan <laijs@...fujitsu.com> wrote:
> When if the lglock don't to be exported,
> we can use DEFINE_STATIC_LGLOCK().
>
> --- a/include/linux/lglock.h
> +++ b/include/linux/lglock.h
> @@ -32,7 +32,8 @@
> #define br_write_lock(name) lg_global_lock(name)
> #define br_write_unlock(name) lg_global_unlock(name)
>
> -#define DEFINE_BRLOCK(name) DEFINE_LGLOCK(name)
> +#define DEFINE_BRLOCK(name) DEFINE_LGLOCK(name)
> +#define DEFINE_STATIC_BRLOCK(name) DEFINE_STATIC_LGLOCK(name)
>
> #ifdef CONFIG_DEBUG_LOCK_ALLOC
> #define LOCKDEP_INIT_MAP lockdep_init_map
> @@ -53,6 +54,11 @@ struct lglock {
> = __ARCH_SPIN_LOCK_UNLOCKED; \
> struct lglock name = { .lock = &name ## _lock }
>
> +#define DEFINE_STATIC_LGLOCK(name) \
> + static DEFINE_PER_CPU(arch_spinlock_t, name ## _lock) \
> + = __ARCH_SPIN_LOCK_UNLOCKED; \
> + static struct lglock name = { .lock = &name ## _lock }
> +
> void lg_lock_init(struct lglock *lg, char *name);
> void lg_local_lock(struct lglock *lg);
> void lg_local_unlock(struct lglock *lg);
hm, this is a bit sad. It would be better if we could do
static DEFINE_LGLOCK(foo);
but I don't immediately see a way in which we can rework
DEFINE_LGLOCK() to permit that.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists