linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9 for-3.10] srcu: use-site fix and cleanups
@ 2013-03-15 16:50 Lai Jiangshan
  2013-03-15 16:50 ` [PATCH 1/9] powerpc,kvm: fix imbalance srcu_read_[un]lock() Lai Jiangshan
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Lai Jiangshan @ 2013-03-15 16:50 UTC (permalink / raw)
  To: Paul E. McKenney, Andrew Morton, linux-kernel; +Cc: Lai Jiangshan

All are simple cleanups(and one fix).

Patch1: fix imbalance srcu_read_[un]lock()
Patch2~6: use DEFINE[_STATIC]_SRCU macro
Patch7: use call_srcu() and remove a lot of code

Patch8~9: non-srcu related cleanup for fsnotify


Lai Jiangshan (9):
  powerpc,kvm: fix imbalance srcu_read_[un]lock()
  events: use DEFINE_STATIC_SRCU() to define pmus_srcu
  mmu_notifier: use DEFINE_STATIC_SRCU() to define srcu struct
  netpoll: use DEFINE_STATIC_SRCU() to define netpoll_srcu
  tomoyo: use DEFINE_SRCU() to define tomoyo_ss
  fsnotify: use DEFINE_SRCU() for srcu_struct
  fsnotify: use existed call_srcu()
  fsnotify: use BUILD_BUG_ON() to test ALL_FSNOTIFY_EVENTS
  fsnotify: remove fsnotify_init()

 arch/powerpc/kvm/book3s_hv.c     |    2 +-
 fs/notify/fsnotify.c             |   14 ---------
 fs/notify/mark.c                 |   61 +++++++-------------------------------
 fs/notify/notification.c         |    2 +
 include/linux/fsnotify_backend.h |    2 +-
 kernel/events/core.c             |    3 +-
 mm/mmu_notifier.c                |    8 +----
 net/core/netpoll.c               |    3 +-
 security/tomoyo/tomoyo.c         |    5 +--
 9 files changed, 20 insertions(+), 80 deletions(-)

-- 
1.7.4.4


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

* [PATCH 1/9] powerpc,kvm: fix imbalance srcu_read_[un]lock()
  2013-03-15 16:50 [PATCH 0/9 for-3.10] srcu: use-site fix and cleanups Lai Jiangshan
@ 2013-03-15 16:50 ` Lai Jiangshan
  2013-03-17 21:26   ` Paul Mackerras
  2013-03-15 16:50 ` [PATCH 2/9] events: use DEFINE_STATIC_SRCU() to define pmus_srcu Lai Jiangshan
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Lai Jiangshan @ 2013-03-15 16:50 UTC (permalink / raw)
  To: Paul E. McKenney, Andrew Morton, linux-kernel
  Cc: Lai Jiangshan, Marcelo Tosatti, Gleb Natapov, Alexander Graf,
	Benjamin Herrenschmidt, Paul Mackerras, kvm, kvm-ppc,
	linuxppc-dev

At the point of up_out label in kvmppc_hv_setup_htab_rma(),
srcu read lock is still held.

We have to release it before return.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Alexander Graf <agraf@suse.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: kvm@vger.kernel.org
Cc: kvm-ppc@vger.kernel.org
---
 arch/powerpc/kvm/book3s_hv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 80dcc53..c26740e 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -1799,7 +1799,7 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
 
  up_out:
 	up_read(&current->mm->mmap_sem);
-	goto out;
+	goto out_srcu;
 }
 
 int kvmppc_core_init_vm(struct kvm *kvm)
-- 
1.7.4.4


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

* [PATCH 2/9] events: use DEFINE_STATIC_SRCU() to define pmus_srcu
  2013-03-15 16:50 [PATCH 0/9 for-3.10] srcu: use-site fix and cleanups Lai Jiangshan
  2013-03-15 16:50 ` [PATCH 1/9] powerpc,kvm: fix imbalance srcu_read_[un]lock() Lai Jiangshan
@ 2013-03-15 16:50 ` Lai Jiangshan
  2013-03-15 16:50 ` [PATCH 3/9] mmu_notifier: use DEFINE_STATIC_SRCU() to define srcu struct Lai Jiangshan
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Lai Jiangshan @ 2013-03-15 16:50 UTC (permalink / raw)
  To: Paul E. McKenney, Andrew Morton, linux-kernel
  Cc: Lai Jiangshan, Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo

DEFINE_STATIC_SRCU() defines srcu struct and do init at build time.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 kernel/events/core.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index b0cd865..c334f26 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -146,7 +146,7 @@ static atomic_t nr_task_events __read_mostly;
 
 static LIST_HEAD(pmus);
 static DEFINE_MUTEX(pmus_lock);
-static struct srcu_struct pmus_srcu;
+DEFINE_STATIC_SRCU(pmus_srcu);
 
 /*
  * perf event paranoia level:
@@ -7396,7 +7396,6 @@ void __init perf_event_init(void)
 	idr_init(&pmu_idr);
 
 	perf_event_init_all_cpus();
-	init_srcu_struct(&pmus_srcu);
 	perf_pmu_register(&perf_swevent, "software", PERF_TYPE_SOFTWARE);
 	perf_pmu_register(&perf_cpu_clock, NULL, -1);
 	perf_pmu_register(&perf_task_clock, NULL, -1);
-- 
1.7.4.4


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

* [PATCH 3/9] mmu_notifier: use DEFINE_STATIC_SRCU() to define srcu struct
  2013-03-15 16:50 [PATCH 0/9 for-3.10] srcu: use-site fix and cleanups Lai Jiangshan
  2013-03-15 16:50 ` [PATCH 1/9] powerpc,kvm: fix imbalance srcu_read_[un]lock() Lai Jiangshan
  2013-03-15 16:50 ` [PATCH 2/9] events: use DEFINE_STATIC_SRCU() to define pmus_srcu Lai Jiangshan
@ 2013-03-15 16:50 ` Lai Jiangshan
  2013-03-15 16:50 ` [PATCH 4/9] netpoll: use DEFINE_STATIC_SRCU() to define netpoll_srcu Lai Jiangshan
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Lai Jiangshan @ 2013-03-15 16:50 UTC (permalink / raw)
  To: Paul E. McKenney, Andrew Morton, linux-kernel
  Cc: Lai Jiangshan, Robin Holt, Andrea Arcangeli, Gavin Shan,
	Sasha Levin, linux-mm

DEFINE_STATIC_SRCU() defines srcu struct and do init at build time.
also remove unneeded mmu_notifier_init().

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 mm/mmu_notifier.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
index be04122..aa7c785 100644
--- a/mm/mmu_notifier.c
+++ b/mm/mmu_notifier.c
@@ -20,7 +20,7 @@
 #include <linux/slab.h>
 
 /* global SRCU for all MMs */
-static struct srcu_struct srcu;
+DEFINE_STATIC_SRCU(srcu);
 
 /*
  * This function can't run concurrently against mmu_notifier_register
@@ -326,9 +326,3 @@ void mmu_notifier_unregister(struct mmu_notifier *mn, struct mm_struct *mm)
 }
 EXPORT_SYMBOL_GPL(mmu_notifier_unregister);
 
-static int __init mmu_notifier_init(void)
-{
-	return init_srcu_struct(&srcu);
-}
-
-module_init(mmu_notifier_init);
-- 
1.7.4.4


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

* [PATCH 4/9] netpoll: use DEFINE_STATIC_SRCU() to define netpoll_srcu
  2013-03-15 16:50 [PATCH 0/9 for-3.10] srcu: use-site fix and cleanups Lai Jiangshan
                   ` (2 preceding siblings ...)
  2013-03-15 16:50 ` [PATCH 3/9] mmu_notifier: use DEFINE_STATIC_SRCU() to define srcu struct Lai Jiangshan
@ 2013-03-15 16:50 ` Lai Jiangshan
  2013-03-17 16:43   ` David Miller
  2013-03-15 16:50 ` [PATCH 5/9] tomoyo: use DEFINE_SRCU() to define tomoyo_ss Lai Jiangshan
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Lai Jiangshan @ 2013-03-15 16:50 UTC (permalink / raw)
  To: Paul E. McKenney, Andrew Morton, linux-kernel
  Cc: Lai Jiangshan, David S. Miller, Cong Wang, Neil Horman,
	Eric Dumazet, Jiri Pirko, netdev

DEFINE_STATIC_SRCU() defines srcu struct and do init at build time.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 net/core/netpoll.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index fa32899..a3a17ae 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -47,7 +47,7 @@ static struct sk_buff_head skb_pool;
 
 static atomic_t trapped;
 
-static struct srcu_struct netpoll_srcu;
+DEFINE_STATIC_SRCU(netpoll_srcu);
 
 #define USEC_PER_POLL	50
 #define NETPOLL_RX_ENABLED  1
@@ -1212,7 +1212,6 @@ EXPORT_SYMBOL(netpoll_setup);
 static int __init netpoll_init(void)
 {
 	skb_queue_head_init(&skb_pool);
-	init_srcu_struct(&netpoll_srcu);
 	return 0;
 }
 core_initcall(netpoll_init);
-- 
1.7.4.4


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

* [PATCH 5/9] tomoyo: use DEFINE_SRCU() to define tomoyo_ss
  2013-03-15 16:50 [PATCH 0/9 for-3.10] srcu: use-site fix and cleanups Lai Jiangshan
                   ` (3 preceding siblings ...)
  2013-03-15 16:50 ` [PATCH 4/9] netpoll: use DEFINE_STATIC_SRCU() to define netpoll_srcu Lai Jiangshan
@ 2013-03-15 16:50 ` Lai Jiangshan
  2013-03-15 16:50 ` [PATCH 6/9] fsnotify: use DEFINE_SRCU() for srcu_struct Lai Jiangshan
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Lai Jiangshan @ 2013-03-15 16:50 UTC (permalink / raw)
  To: Paul E. McKenney, Andrew Morton, linux-kernel
  Cc: Lai Jiangshan, Kentaro Takeda, Tetsuo Handa, James Morris,
	linux-security-module

DEFINE_STATIC_SRCU() defines srcu struct and do init at build time.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 security/tomoyo/tomoyo.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
index a2ee362..f0b756e 100644
--- a/security/tomoyo/tomoyo.c
+++ b/security/tomoyo/tomoyo.c
@@ -536,7 +536,7 @@ static struct security_operations tomoyo_security_ops = {
 };
 
 /* Lock for GC. */
-struct srcu_struct tomoyo_ss;
+DEFINE_SRCU(tomoyo_ss);
 
 /**
  * tomoyo_init - Register TOMOYO Linux as a LSM module.
@@ -550,8 +550,7 @@ static int __init tomoyo_init(void)
 	if (!security_module_enable(&tomoyo_security_ops))
 		return 0;
 	/* register ourselves with the security framework */
-	if (register_security(&tomoyo_security_ops) ||
-	    init_srcu_struct(&tomoyo_ss))
+	if (register_security(&tomoyo_security_ops))
 		panic("Failure registering TOMOYO Linux");
 	printk(KERN_INFO "TOMOYO Linux initialized\n");
 	cred->security = &tomoyo_kernel_domain;
-- 
1.7.4.4


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

* [PATCH 6/9] fsnotify: use DEFINE_SRCU() for srcu_struct
  2013-03-15 16:50 [PATCH 0/9 for-3.10] srcu: use-site fix and cleanups Lai Jiangshan
                   ` (4 preceding siblings ...)
  2013-03-15 16:50 ` [PATCH 5/9] tomoyo: use DEFINE_SRCU() to define tomoyo_ss Lai Jiangshan
@ 2013-03-15 16:50 ` Lai Jiangshan
  2013-03-15 16:50 ` [PATCH 7/9] fsnotify: use existed call_srcu() Lai Jiangshan
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Lai Jiangshan @ 2013-03-15 16:50 UTC (permalink / raw)
  To: Paul E. McKenney, Andrew Morton, linux-kernel
  Cc: Lai Jiangshan, Eric Paris, Al Viro, Sasha Levin, Dan Carpenter,
	Eric Paris, Lino Sanfilippo

DEFINE_STATIC_SRCU() defines srcu struct and do init at build time.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Eric Paris <eparis@parisplace.org>
---
 fs/notify/fsnotify.c |    6 ------
 fs/notify/mark.c     |    2 +-
 2 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index 4bb21d6..aba962a 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -298,14 +298,8 @@ EXPORT_SYMBOL_GPL(fsnotify);
 
 static __init int fsnotify_init(void)
 {
-	int ret;
-
 	BUG_ON(hweight32(ALL_FSNOTIFY_EVENTS) != 23);
 
-	ret = init_srcu_struct(&fsnotify_mark_srcu);
-	if (ret)
-		panic("initializing fsnotify_mark_srcu");
-
 	return 0;
 }
 core_initcall(fsnotify_init);
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index fc6b49b..aeededc 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -97,7 +97,7 @@
 #include <linux/fsnotify_backend.h>
 #include "fsnotify.h"
 
-struct srcu_struct fsnotify_mark_srcu;
+DEFINE_SRCU(fsnotify_mark_srcu);
 static DEFINE_SPINLOCK(destroy_lock);
 static LIST_HEAD(destroy_list);
 static DECLARE_WAIT_QUEUE_HEAD(destroy_waitq);
-- 
1.7.4.4


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

* [PATCH 7/9] fsnotify: use existed call_srcu()
  2013-03-15 16:50 [PATCH 0/9 for-3.10] srcu: use-site fix and cleanups Lai Jiangshan
                   ` (5 preceding siblings ...)
  2013-03-15 16:50 ` [PATCH 6/9] fsnotify: use DEFINE_SRCU() for srcu_struct Lai Jiangshan
@ 2013-03-15 16:50 ` Lai Jiangshan
  2013-04-05  7:34   ` Lai Jiangshan
  2013-03-15 16:50 ` [PATCH 8/9] fsnotify: use BUILD_BUG_ON() to test the weight of ALL_FSNOTIFY_EVENTS Lai Jiangshan
  2013-03-15 16:50 ` [PATCH 9/9] fsnotify: remove fsnotify_init() Lai Jiangshan
  8 siblings, 1 reply; 14+ messages in thread
From: Lai Jiangshan @ 2013-03-15 16:50 UTC (permalink / raw)
  To: Paul E. McKenney, Andrew Morton, linux-kernel
  Cc: Lai Jiangshan, Eric Paris, Eric Paris, Lino Sanfilippo,
	Naohiro Aota, Al Viro

fsnotify implements its own call_srcu() by:
	dedicated thread + synchronize_srcu()

But srcu provides call_srcu() now, so we should convert them to use
existed call_srcu() and remove the thread.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Eric Paris <eparis@parisplace.org>
---
 fs/notify/mark.c                 |   59 ++++++-------------------------------
 include/linux/fsnotify_backend.h |    2 +-
 2 files changed, 11 insertions(+), 50 deletions(-)

diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index aeededc..af5f0e1 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -98,9 +98,6 @@
 #include "fsnotify.h"
 
 DEFINE_SRCU(fsnotify_mark_srcu);
-static DEFINE_SPINLOCK(destroy_lock);
-static LIST_HEAD(destroy_list);
-static DECLARE_WAIT_QUEUE_HEAD(destroy_waitq);
 
 void fsnotify_get_mark(struct fsnotify_mark *mark)
 {
@@ -116,6 +113,14 @@ void fsnotify_put_mark(struct fsnotify_mark *mark)
 	}
 }
 
+static void fsnotify_destroy_mark_rcu(struct rcu_head *rcu)
+{
+	struct fsnotify_mark *mark;
+
+	mark = container_of(rcu, struct fsnotify_mark, rcu);
+	fsnotify_put_mark(mark);
+}
+
 /*
  * Any time a mark is getting freed we end up here.
  * The caller had better be holding a reference to this mark so we don't actually
@@ -155,10 +160,7 @@ void fsnotify_destroy_mark_locked(struct fsnotify_mark *mark,
 	/* release lock temporarily */
 	mutex_unlock(&group->mark_mutex);
 
-	spin_lock(&destroy_lock);
-	list_add(&mark->destroy_list, &destroy_list);
-	spin_unlock(&destroy_lock);
-	wake_up(&destroy_waitq);
+	call_srcu(&fsnotify_mark_srcu, &mark->rcu, fsnotify_destroy_mark_rcu);
 	/*
 	 * We don't necessarily have a ref on mark from caller so the above destroy
 	 * may have actually freed it, unless this group provides a 'freeing_mark'
@@ -273,11 +275,7 @@ err:
 	atomic_dec(&group->num_marks);
 
 	spin_unlock(&mark->lock);
-
-	spin_lock(&destroy_lock);
-	list_add(&mark->destroy_list, &destroy_list);
-	spin_unlock(&destroy_lock);
-	wake_up(&destroy_waitq);
+	call_srcu(&fsnotify_mark_srcu, &mark->rcu, fsnotify_destroy_mark_rcu);
 
 	return ret;
 }
@@ -342,40 +340,3 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
 	atomic_set(&mark->refcnt, 1);
 	mark->free_mark = free_mark;
 }
-
-static int fsnotify_mark_destroy(void *ignored)
-{
-	struct fsnotify_mark *mark, *next;
-	LIST_HEAD(private_destroy_list);
-
-	for (;;) {
-		spin_lock(&destroy_lock);
-		/* exchange the list head */
-		list_replace_init(&destroy_list, &private_destroy_list);
-		spin_unlock(&destroy_lock);
-
-		synchronize_srcu(&fsnotify_mark_srcu);
-
-		list_for_each_entry_safe(mark, next, &private_destroy_list, destroy_list) {
-			list_del_init(&mark->destroy_list);
-			fsnotify_put_mark(mark);
-		}
-
-		wait_event_interruptible(destroy_waitq, !list_empty(&destroy_list));
-	}
-
-	return 0;
-}
-
-static int __init fsnotify_mark_init(void)
-{
-	struct task_struct *thread;
-
-	thread = kthread_run(fsnotify_mark_destroy, NULL,
-			     "fsnotify_mark");
-	if (IS_ERR(thread))
-		panic("unable to start fsnotify mark destruction thread.");
-
-	return 0;
-}
-device_initcall(fsnotify_mark_init);
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index d5b0910..3d435eb 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -296,7 +296,7 @@ struct fsnotify_mark {
 #define FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY	0x08
 #define FSNOTIFY_MARK_FLAG_ALIVE		0x10
 	unsigned int flags;		/* vfsmount or inode mark? */
-	struct list_head destroy_list;
+	struct rcu_head rcu;
 	void (*free_mark)(struct fsnotify_mark *mark); /* called on final put+free */
 };
 
-- 
1.7.4.4


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

* [PATCH 8/9] fsnotify: use BUILD_BUG_ON() to test the weight of ALL_FSNOTIFY_EVENTS
  2013-03-15 16:50 [PATCH 0/9 for-3.10] srcu: use-site fix and cleanups Lai Jiangshan
                   ` (6 preceding siblings ...)
  2013-03-15 16:50 ` [PATCH 7/9] fsnotify: use existed call_srcu() Lai Jiangshan
@ 2013-03-15 16:50 ` Lai Jiangshan
  2013-03-15 16:50 ` [PATCH 9/9] fsnotify: remove fsnotify_init() Lai Jiangshan
  8 siblings, 0 replies; 14+ messages in thread
From: Lai Jiangshan @ 2013-03-15 16:50 UTC (permalink / raw)
  To: Paul E. McKenney, Andrew Morton, linux-kernel
  Cc: Lai Jiangshan, Eric Paris, Al Viro, Sasha Levin, Dan Carpenter

BUILD_BUG_ON() is build-time-test for constant. avoid runtime test.
also use HWEIGHT32() for build-time.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Eric Paris <eparis@parisplace.org>
---
 fs/notify/fsnotify.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index aba962a..eaa0e9e 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -298,7 +298,7 @@ EXPORT_SYMBOL_GPL(fsnotify);
 
 static __init int fsnotify_init(void)
 {
-	BUG_ON(hweight32(ALL_FSNOTIFY_EVENTS) != 23);
+	BUILD_BUG_ON(HWEIGHT32(ALL_FSNOTIFY_EVENTS) != 23);
 
 	return 0;
 }
-- 
1.7.4.4


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

* [PATCH 9/9] fsnotify: remove fsnotify_init()
  2013-03-15 16:50 [PATCH 0/9 for-3.10] srcu: use-site fix and cleanups Lai Jiangshan
                   ` (7 preceding siblings ...)
  2013-03-15 16:50 ` [PATCH 8/9] fsnotify: use BUILD_BUG_ON() to test the weight of ALL_FSNOTIFY_EVENTS Lai Jiangshan
@ 2013-03-15 16:50 ` Lai Jiangshan
  8 siblings, 0 replies; 14+ messages in thread
From: Lai Jiangshan @ 2013-03-15 16:50 UTC (permalink / raw)
  To: Paul E. McKenney, Andrew Morton, linux-kernel
  Cc: Lai Jiangshan, Eric Paris, Al Viro, Sasha Levin, Dan Carpenter,
	H Hartley Sweeten, Adam Buchbinder, Jiri Kosina, Eric Paris

Since fsnotify_init() is empty in runtime, remove it.
The build time test is moved to notification.c

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Eric Paris <eparis@parisplace.org>
---
 fs/notify/fsnotify.c     |    8 --------
 fs/notify/notification.c |    2 ++
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index eaa0e9e..2ea0c1a 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -295,11 +295,3 @@ out:
 	return ret;
 }
 EXPORT_SYMBOL_GPL(fsnotify);
-
-static __init int fsnotify_init(void)
-{
-	BUILD_BUG_ON(HWEIGHT32(ALL_FSNOTIFY_EVENTS) != 23);
-
-	return 0;
-}
-core_initcall(fsnotify_init);
diff --git a/fs/notify/notification.c b/fs/notify/notification.c
index 7b51b05..80fc0b5 100644
--- a/fs/notify/notification.c
+++ b/fs/notify/notification.c
@@ -453,6 +453,8 @@ static __init int fsnotify_notification_init(void)
 	fsnotify_event_cachep = KMEM_CACHE(fsnotify_event, SLAB_PANIC);
 	fsnotify_event_holder_cachep = KMEM_CACHE(fsnotify_event_holder, SLAB_PANIC);
 
+	BUILD_BUG_ON(HWEIGHT32(ALL_FSNOTIFY_EVENTS) != 23);
+
 	q_overflow_event = fsnotify_create_event(NULL, FS_Q_OVERFLOW, NULL,
 						 FSNOTIFY_EVENT_NONE, NULL, 0,
 						 GFP_KERNEL);
-- 
1.7.4.4


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

* Re: [PATCH 4/9] netpoll: use DEFINE_STATIC_SRCU() to define netpoll_srcu
  2013-03-15 16:50 ` [PATCH 4/9] netpoll: use DEFINE_STATIC_SRCU() to define netpoll_srcu Lai Jiangshan
@ 2013-03-17 16:43   ` David Miller
  0 siblings, 0 replies; 14+ messages in thread
From: David Miller @ 2013-03-17 16:43 UTC (permalink / raw)
  To: laijs
  Cc: paulmck, akpm, linux-kernel, amwang, nhorman, edumazet, jiri, netdev

From: Lai Jiangshan <laijs@cn.fujitsu.com>
Date: Sat, 16 Mar 2013 00:50:52 +0800

> DEFINE_STATIC_SRCU() defines srcu struct and do init at build time.
> 
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>

Applied.

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

* Re: [PATCH 1/9] powerpc,kvm: fix imbalance srcu_read_[un]lock()
  2013-03-15 16:50 ` [PATCH 1/9] powerpc,kvm: fix imbalance srcu_read_[un]lock() Lai Jiangshan
@ 2013-03-17 21:26   ` Paul Mackerras
  2013-04-11 21:51     ` Paul E. McKenney
  0 siblings, 1 reply; 14+ messages in thread
From: Paul Mackerras @ 2013-03-17 21:26 UTC (permalink / raw)
  To: Lai Jiangshan
  Cc: Paul E. McKenney, Andrew Morton, linux-kernel, Marcelo Tosatti,
	Gleb Natapov, Alexander Graf, Benjamin Herrenschmidt, kvm,
	kvm-ppc, linuxppc-dev

On Sat, Mar 16, 2013 at 12:50:49AM +0800, Lai Jiangshan wrote:
> At the point of up_out label in kvmppc_hv_setup_htab_rma(),
> srcu read lock is still held.
> 
> We have to release it before return.
> 
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
> Cc: Gleb Natapov <gleb@redhat.com>
> Cc: Alexander Graf <agraf@suse.de>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: kvm@vger.kernel.org
> Cc: kvm-ppc@vger.kernel.org
> ---
>  arch/powerpc/kvm/book3s_hv.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 80dcc53..c26740e 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -1799,7 +1799,7 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
>  
>   up_out:
>  	up_read(&current->mm->mmap_sem);
> -	goto out;
> +	goto out_srcu;

Acked-by: Paul Mackerras <paulus@samba.org>

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

* Re: [PATCH 7/9] fsnotify: use existed call_srcu()
  2013-03-15 16:50 ` [PATCH 7/9] fsnotify: use existed call_srcu() Lai Jiangshan
@ 2013-04-05  7:34   ` Lai Jiangshan
  0 siblings, 0 replies; 14+ messages in thread
From: Lai Jiangshan @ 2013-04-05  7:34 UTC (permalink / raw)
  To: Lai Jiangshan, Eric Paris
  Cc: Paul E. McKenney, Andrew Morton, linux-kernel, Eric Paris,
	Lino Sanfilippo, Naohiro Aota, Al Viro

[Ping]

Hi, Eric Paris

Could you review this patch?

Thanks,
Lai

On 03/16/2013 12:50 AM, Lai Jiangshan wrote:
> fsnotify implements its own call_srcu() by:
> 	dedicated thread + synchronize_srcu()
> 
> But srcu provides call_srcu() now, so we should convert them to use
> existed call_srcu() and remove the thread.
> 
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> Cc: Eric Paris <eparis@parisplace.org>
> ---
>  fs/notify/mark.c                 |   59 ++++++-------------------------------
>  include/linux/fsnotify_backend.h |    2 +-
>  2 files changed, 11 insertions(+), 50 deletions(-)
> 
> diff --git a/fs/notify/mark.c b/fs/notify/mark.c
> index aeededc..af5f0e1 100644
> --- a/fs/notify/mark.c
> +++ b/fs/notify/mark.c
> @@ -98,9 +98,6 @@
>  #include "fsnotify.h"
>  
>  DEFINE_SRCU(fsnotify_mark_srcu);
> -static DEFINE_SPINLOCK(destroy_lock);
> -static LIST_HEAD(destroy_list);
> -static DECLARE_WAIT_QUEUE_HEAD(destroy_waitq);
>  
>  void fsnotify_get_mark(struct fsnotify_mark *mark)
>  {
> @@ -116,6 +113,14 @@ void fsnotify_put_mark(struct fsnotify_mark *mark)
>  	}
>  }
>  
> +static void fsnotify_destroy_mark_rcu(struct rcu_head *rcu)
> +{
> +	struct fsnotify_mark *mark;
> +
> +	mark = container_of(rcu, struct fsnotify_mark, rcu);
> +	fsnotify_put_mark(mark);
> +}
> +
>  /*
>   * Any time a mark is getting freed we end up here.
>   * The caller had better be holding a reference to this mark so we don't actually
> @@ -155,10 +160,7 @@ void fsnotify_destroy_mark_locked(struct fsnotify_mark *mark,
>  	/* release lock temporarily */
>  	mutex_unlock(&group->mark_mutex);
>  
> -	spin_lock(&destroy_lock);
> -	list_add(&mark->destroy_list, &destroy_list);
> -	spin_unlock(&destroy_lock);
> -	wake_up(&destroy_waitq);
> +	call_srcu(&fsnotify_mark_srcu, &mark->rcu, fsnotify_destroy_mark_rcu);
>  	/*
>  	 * We don't necessarily have a ref on mark from caller so the above destroy
>  	 * may have actually freed it, unless this group provides a 'freeing_mark'
> @@ -273,11 +275,7 @@ err:
>  	atomic_dec(&group->num_marks);
>  
>  	spin_unlock(&mark->lock);
> -
> -	spin_lock(&destroy_lock);
> -	list_add(&mark->destroy_list, &destroy_list);
> -	spin_unlock(&destroy_lock);
> -	wake_up(&destroy_waitq);
> +	call_srcu(&fsnotify_mark_srcu, &mark->rcu, fsnotify_destroy_mark_rcu);
>  
>  	return ret;
>  }
> @@ -342,40 +340,3 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
>  	atomic_set(&mark->refcnt, 1);
>  	mark->free_mark = free_mark;
>  }
> -
> -static int fsnotify_mark_destroy(void *ignored)
> -{
> -	struct fsnotify_mark *mark, *next;
> -	LIST_HEAD(private_destroy_list);
> -
> -	for (;;) {
> -		spin_lock(&destroy_lock);
> -		/* exchange the list head */
> -		list_replace_init(&destroy_list, &private_destroy_list);
> -		spin_unlock(&destroy_lock);
> -
> -		synchronize_srcu(&fsnotify_mark_srcu);
> -
> -		list_for_each_entry_safe(mark, next, &private_destroy_list, destroy_list) {
> -			list_del_init(&mark->destroy_list);
> -			fsnotify_put_mark(mark);
> -		}
> -
> -		wait_event_interruptible(destroy_waitq, !list_empty(&destroy_list));
> -	}
> -
> -	return 0;
> -}
> -
> -static int __init fsnotify_mark_init(void)
> -{
> -	struct task_struct *thread;
> -
> -	thread = kthread_run(fsnotify_mark_destroy, NULL,
> -			     "fsnotify_mark");
> -	if (IS_ERR(thread))
> -		panic("unable to start fsnotify mark destruction thread.");
> -
> -	return 0;
> -}
> -device_initcall(fsnotify_mark_init);
> diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
> index d5b0910..3d435eb 100644
> --- a/include/linux/fsnotify_backend.h
> +++ b/include/linux/fsnotify_backend.h
> @@ -296,7 +296,7 @@ struct fsnotify_mark {
>  #define FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY	0x08
>  #define FSNOTIFY_MARK_FLAG_ALIVE		0x10
>  	unsigned int flags;		/* vfsmount or inode mark? */
> -	struct list_head destroy_list;
> +	struct rcu_head rcu;
>  	void (*free_mark)(struct fsnotify_mark *mark); /* called on final put+free */
>  };
>  


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

* Re: [PATCH 1/9] powerpc,kvm: fix imbalance srcu_read_[un]lock()
  2013-03-17 21:26   ` Paul Mackerras
@ 2013-04-11 21:51     ` Paul E. McKenney
  0 siblings, 0 replies; 14+ messages in thread
From: Paul E. McKenney @ 2013-04-11 21:51 UTC (permalink / raw)
  To: Paul Mackerras
  Cc: Lai Jiangshan, Andrew Morton, linux-kernel, Marcelo Tosatti,
	Gleb Natapov, Alexander Graf, Benjamin Herrenschmidt, kvm,
	kvm-ppc, linuxppc-dev

On Mon, Mar 18, 2013 at 08:26:48AM +1100, Paul Mackerras wrote:
> On Sat, Mar 16, 2013 at 12:50:49AM +0800, Lai Jiangshan wrote:
> > At the point of up_out label in kvmppc_hv_setup_htab_rma(),
> > srcu read lock is still held.
> > 
> > We have to release it before return.
> > 
> > Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> > Cc: Marcelo Tosatti <mtosatti@redhat.com>
> > Cc: Gleb Natapov <gleb@redhat.com>
> > Cc: Alexander Graf <agraf@suse.de>
> > Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > Cc: Paul Mackerras <paulus@samba.org>
> > Cc: kvm@vger.kernel.org
> > Cc: kvm-ppc@vger.kernel.org
> > ---
> >  arch/powerpc/kvm/book3s_hv.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> > index 80dcc53..c26740e 100644
> > --- a/arch/powerpc/kvm/book3s_hv.c
> > +++ b/arch/powerpc/kvm/book3s_hv.c
> > @@ -1799,7 +1799,7 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
> >  
> >   up_out:
> >  	up_read(&current->mm->mmap_sem);
> > -	goto out;
> > +	goto out_srcu;
> 
> Acked-by: Paul Mackerras <paulus@samba.org>

Thank you both, queued for 3.11 (assuming no one has beat me to it).

							Thanx, Paul


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

end of thread, other threads:[~2013-04-11 21:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-15 16:50 [PATCH 0/9 for-3.10] srcu: use-site fix and cleanups Lai Jiangshan
2013-03-15 16:50 ` [PATCH 1/9] powerpc,kvm: fix imbalance srcu_read_[un]lock() Lai Jiangshan
2013-03-17 21:26   ` Paul Mackerras
2013-04-11 21:51     ` Paul E. McKenney
2013-03-15 16:50 ` [PATCH 2/9] events: use DEFINE_STATIC_SRCU() to define pmus_srcu Lai Jiangshan
2013-03-15 16:50 ` [PATCH 3/9] mmu_notifier: use DEFINE_STATIC_SRCU() to define srcu struct Lai Jiangshan
2013-03-15 16:50 ` [PATCH 4/9] netpoll: use DEFINE_STATIC_SRCU() to define netpoll_srcu Lai Jiangshan
2013-03-17 16:43   ` David Miller
2013-03-15 16:50 ` [PATCH 5/9] tomoyo: use DEFINE_SRCU() to define tomoyo_ss Lai Jiangshan
2013-03-15 16:50 ` [PATCH 6/9] fsnotify: use DEFINE_SRCU() for srcu_struct Lai Jiangshan
2013-03-15 16:50 ` [PATCH 7/9] fsnotify: use existed call_srcu() Lai Jiangshan
2013-04-05  7:34   ` Lai Jiangshan
2013-03-15 16:50 ` [PATCH 8/9] fsnotify: use BUILD_BUG_ON() to test the weight of ALL_FSNOTIFY_EVENTS Lai Jiangshan
2013-03-15 16:50 ` [PATCH 9/9] fsnotify: remove fsnotify_init() Lai Jiangshan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).