All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] lglock: remove unused DEFINE_LGLOCK_LOCKDEP()
@ 2012-10-09  3:46 Lai Jiangshan
  2012-10-09  3:46 ` [PATCH 2/3] lglock: make the per_cpu locks static Lai Jiangshan
  2012-10-09  3:46 ` [PATCH 3/3] lglock: add DEFINE_STATIC_LGLOCK() Lai Jiangshan
  0 siblings, 2 replies; 5+ messages in thread
From: Lai Jiangshan @ 2012-10-09  3:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: Lai Jiangshan, Al Viro, Rusty Russell, Andrew Morton, Andi Kleen

struct lglocks use their own lock_key/lock_dep_map which are defined
in struct lglock. DEFINE_LGLOCK_LOCKDEP() is unused now, so we remove it
and save a small piece of memory.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 include/linux/lglock.h |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/include/linux/lglock.h b/include/linux/lglock.h
index f01e5f6..45eff71 100644
--- a/include/linux/lglock.h
+++ b/include/linux/lglock.h
@@ -36,16 +36,8 @@
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 #define LOCKDEP_INIT_MAP lockdep_init_map
-
-#define DEFINE_LGLOCK_LOCKDEP(name)					\
- struct lock_class_key name##_lock_key;					\
- struct lockdep_map name##_lock_dep_map;				\
- EXPORT_SYMBOL(name##_lock_dep_map)
-
 #else
 #define LOCKDEP_INIT_MAP(a, b, c, d)
-
-#define DEFINE_LGLOCK_LOCKDEP(name)
 #endif
 
 struct lglock {
@@ -57,7 +49,6 @@ struct lglock {
 };
 
 #define DEFINE_LGLOCK(name)						\
-	DEFINE_LGLOCK_LOCKDEP(name);					\
 	DEFINE_PER_CPU(arch_spinlock_t, name ## _lock)			\
 	= __ARCH_SPIN_LOCK_UNLOCKED;					\
 	struct lglock name = { .lock = &name ## _lock }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] lglock: make the per_cpu locks static
  2012-10-09  3:46 [PATCH 1/3] lglock: remove unused DEFINE_LGLOCK_LOCKDEP() Lai Jiangshan
@ 2012-10-09  3:46 ` Lai Jiangshan
  2012-10-09 21:46   ` Andrew Morton
  2012-10-09  3:46 ` [PATCH 3/3] lglock: add DEFINE_STATIC_LGLOCK() Lai Jiangshan
  1 sibling, 1 reply; 5+ messages in thread
From: Lai Jiangshan @ 2012-10-09  3:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: Lai Jiangshan, Al Viro, Rusty Russell, Andrew Morton, Andi Kleen

The per_cpu locks are not used outside nor exported.
Add a "static" linkage keyword to it.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 include/linux/lglock.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/lglock.h b/include/linux/lglock.h
index 45eff71..8f97451 100644
--- a/include/linux/lglock.h
+++ b/include/linux/lglock.h
@@ -49,7 +49,7 @@ struct lglock {
 };
 
 #define DEFINE_LGLOCK(name)						\
-	DEFINE_PER_CPU(arch_spinlock_t, name ## _lock)			\
+	static DEFINE_PER_CPU(arch_spinlock_t, name ## _lock)		\
 	= __ARCH_SPIN_LOCK_UNLOCKED;					\
 	struct lglock name = { .lock = &name ## _lock }
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] lglock: add DEFINE_STATIC_LGLOCK()
  2012-10-09  3:46 [PATCH 1/3] lglock: remove unused DEFINE_LGLOCK_LOCKDEP() Lai Jiangshan
  2012-10-09  3:46 ` [PATCH 2/3] lglock: make the per_cpu locks static Lai Jiangshan
@ 2012-10-09  3:46 ` Lai Jiangshan
  2012-10-09 21:48   ` Andrew Morton
  1 sibling, 1 reply; 5+ messages in thread
From: Lai Jiangshan @ 2012-10-09  3:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: Lai Jiangshan, Alexander Viro, Rusty Russell, Andrew Morton,
	Andi Kleen, linux-fsdevel

When if the lglock don't to be exported,
we can use DEFINE_STATIC_LGLOCK().

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 fs/file_table.c        |    2 +-
 include/linux/lglock.h |    8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/file_table.c b/fs/file_table.c
index 701985e..e26fd31 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -36,7 +36,7 @@ struct files_stat_struct files_stat = {
 	.max_files = NR_FILE
 };
 
-DEFINE_LGLOCK(files_lglock);
+DEFINE_STATIC_LGLOCK(files_lglock);
 
 /* SLAB cache for file structures */
 static struct kmem_cache *filp_cachep __read_mostly;
diff --git a/include/linux/lglock.h b/include/linux/lglock.h
index 8f97451..0d24e93 100644
--- 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);
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] lglock: make the per_cpu locks static
  2012-10-09  3:46 ` [PATCH 2/3] lglock: make the per_cpu locks static Lai Jiangshan
@ 2012-10-09 21:46   ` Andrew Morton
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2012-10-09 21:46 UTC (permalink / raw)
  To: Lai Jiangshan; +Cc: linux-kernel, Al Viro, Rusty Russell, Andi Kleen

On Tue, 9 Oct 2012 11:46:39 +0800
Lai Jiangshan <laijs@cn.fujitsu.com> wrote:

> The per_cpu locks are not used outside nor exported.
> Add a "static" linkage keyword to it.

I think a better description is:

: The per_cpu locks are not used outside the file which contains the
: DEFINE_LGLOCK(), so we can make these symbols static.

> --- a/include/linux/lglock.h
> +++ b/include/linux/lglock.h
> @@ -49,7 +49,7 @@ struct lglock {
>  };
>  
>  #define DEFINE_LGLOCK(name)						\
> -	DEFINE_PER_CPU(arch_spinlock_t, name ## _lock)			\
> +	static DEFINE_PER_CPU(arch_spinlock_t, name ## _lock)		\
>  	= __ARCH_SPIN_LOCK_UNLOCKED;					\
>  	struct lglock name = { .lock = &name ## _lock }
>  
> -- 
> 1.7.4.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] lglock: add DEFINE_STATIC_LGLOCK()
  2012-10-09  3:46 ` [PATCH 3/3] lglock: add DEFINE_STATIC_LGLOCK() Lai Jiangshan
@ 2012-10-09 21:48   ` Andrew Morton
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2012-10-09 21:48 UTC (permalink / raw)
  To: Lai Jiangshan
  Cc: linux-kernel, Alexander Viro, Rusty Russell, Andi Kleen, linux-fsdevel

On Tue, 9 Oct 2012 11:46:40 +0800
Lai Jiangshan <laijs@cn.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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-10-09 21:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-09  3:46 [PATCH 1/3] lglock: remove unused DEFINE_LGLOCK_LOCKDEP() Lai Jiangshan
2012-10-09  3:46 ` [PATCH 2/3] lglock: make the per_cpu locks static Lai Jiangshan
2012-10-09 21:46   ` Andrew Morton
2012-10-09  3:46 ` [PATCH 3/3] lglock: add DEFINE_STATIC_LGLOCK() Lai Jiangshan
2012-10-09 21:48   ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.