Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1211279
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 4/8] rcusync: Introduce rcu_sync_dtor() |
| Date | 2015-08-21 19:50 +0200 |
| Message-ID | <pZYBZ-2dA-37@gated-at.bofh.it> (permalink) |
| References | <pZYBY-2dA-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Add the new rcu_sync_ops->wait() method and the new helper,
rcu_sync_dtor().
It is needed if you are going to, say, kfree(rcu_sync_object).
It simply calls ops->wait() to "flush" the potentially pending
rcu callback.
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/rcusync.h | 1 +
kernel/rcu/sync.c | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/include/linux/rcusync.h b/include/linux/rcusync.h
index 631a842..50229c0 100644
--- a/include/linux/rcusync.h
+++ b/include/linux/rcusync.h
@@ -31,6 +31,7 @@ static inline bool rcu_sync_is_idle(struct rcu_sync_struct *rss)
extern void rcu_sync_init(struct rcu_sync_struct *, enum rcu_sync_type);
extern void rcu_sync_enter(struct rcu_sync_struct *);
extern void rcu_sync_exit(struct rcu_sync_struct *);
+extern void rcu_sync_dtor(struct rcu_sync_struct *);
#define __RCU_SYNC_INITIALIZER(name, type) { \
.gp_state = 0, \
diff --git a/kernel/rcu/sync.c b/kernel/rcu/sync.c
index 0ab7cbd..7e2a9aa 100644
--- a/kernel/rcu/sync.c
+++ b/kernel/rcu/sync.c
@@ -10,6 +10,7 @@
static const struct {
void (*sync)(void);
void (*call)(struct rcu_head *, void (*)(struct rcu_head *));
+ void (*wait)(void);
#ifdef CONFIG_PROVE_RCU
int (*held)(void);
#endif
@@ -17,16 +18,19 @@ static const struct {
[RCU_SYNC] = {
.sync = synchronize_rcu,
.call = call_rcu,
+ .wait = rcu_barrier,
__INIT_HELD(rcu_read_lock_held)
},
[RCU_SCHED_SYNC] = {
.sync = synchronize_sched,
.call = call_rcu_sched,
+ .wait = rcu_barrier_sched,
__INIT_HELD(rcu_read_lock_sched_held)
},
[RCU_BH_SYNC] = {
.sync = synchronize_rcu_bh,
.call = call_rcu_bh,
+ .wait = rcu_barrier_bh,
__INIT_HELD(rcu_read_lock_bh_held)
},
};
@@ -127,3 +131,21 @@ void rcu_sync_exit(struct rcu_sync_struct *rss)
}
spin_unlock_irq(&rss->rss_lock);
}
+
+void rcu_sync_dtor(struct rcu_sync_struct *rss)
+{
+ int cb_state;
+
+ BUG_ON(rss->gp_count);
+
+ spin_lock_irq(&rss->rss_lock);
+ if (rss->cb_state == CB_REPLAY)
+ rss->cb_state = CB_PENDING;
+ cb_state = rss->cb_state;
+ spin_unlock_irq(&rss->rss_lock);
+
+ if (cb_state != CB_IDLE) {
+ gp_ops[rss->gp_type].wait();
+ BUG_ON(rss->cb_state != CB_IDLE);
+ }
+}
--
1.5.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/8] Add rcu_sync infrastructure to avoid _expedited() in percpu-rwsem Oleg Nesterov <oleg@redhat.com> - 2015-08-21 19:50 +0200
[PATCH v2 3/8] rcusync: Add the CONFIG_PROVE_RCU checks Oleg Nesterov <oleg@redhat.com> - 2015-08-21 19:50 +0200
[PATCH v2 6/8] percpu-rwsem: change it to rely on rss_sync infrastructure Oleg Nesterov <oleg@redhat.com> - 2015-08-21 19:50 +0200
[PATCH v2 5/8] percpu-rwsem: make percpu_free_rwsem() after kzalloc() safe Oleg Nesterov <oleg@redhat.com> - 2015-08-21 19:50 +0200
[PATCH v2 8/8] percpu-rwsem: cleanup the lockdep annotations in percpu_down_read() Oleg Nesterov <oleg@redhat.com> - 2015-08-21 19:50 +0200
[PATCH v2 4/8] rcusync: Introduce rcu_sync_dtor() Oleg Nesterov <oleg@redhat.com> - 2015-08-21 19:50 +0200
[PATCH v2 7/8] percpu-rwsem: fix the comments outdated by rcu_sync Oleg Nesterov <oleg@redhat.com> - 2015-08-21 19:50 +0200
[PATCH v2 2/8] rcusync: Introduce struct rcu_sync_ops Oleg Nesterov <oleg@redhat.com> - 2015-08-21 19:50 +0200
[PATCH v2 1/8] rcu: Create rcu_sync infrastructure Oleg Nesterov <oleg@redhat.com> - 2015-08-21 19:50 +0200
Re: [PATCH v2 0/8] Add rcu_sync infrastructure to avoid _expedited() in percpu-rwsem "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-08-22 18:40 +0200
Re: [PATCH v2 0/8] Add rcu_sync infrastructure to avoid _expedited() in percpu-rwsem Oleg Nesterov <oleg@redhat.com> - 2015-08-24 17:40 +0200
parse_args() is too unforgivable? Oleg Nesterov <oleg@redhat.com> - 2015-08-24 20:40 +0200
Re: parse_args() is too unforgivable? Rusty Russell <rusty@rustcorp.com.au> - 2015-08-25 03:40 +0200
[PATCH 0/1] params: don't ignore the rest of cmdline if parse_one() fails Oleg Nesterov <oleg@redhat.com> - 2015-08-25 17:30 +0200
[PATCH 1/1] params: don't ignore the rest of cmdline if parse_one() fails Oleg Nesterov <oleg@redhat.com> - 2015-08-25 17:30 +0200
Re: [PATCH 1/1] params: don't ignore the rest of cmdline if parse_one() fails Rusty Russell <rusty@rustcorp.com.au> - 2015-08-26 03:20 +0200
Re: [PATCH v2 0/8] Add rcu_sync infrastructure to avoid _expedited() in percpu-rwsem "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-08-26 02:30 +0200
Re: [PATCH v2 0/8] Add rcu_sync infrastructure to avoid _expedited() in percpu-rwsem Oleg Nesterov <oleg@redhat.com> - 2015-08-26 14:20 +0200
Re: [PATCH v2 0/8] Add rcu_sync infrastructure to avoid _expedited() in percpu-rwsem Oleg Nesterov <oleg@redhat.com> - 2015-08-26 15:00 +0200
Re: [PATCH v2 0/8] Add rcu_sync infrastructure to avoid _expedited() in percpu-rwsem "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-08-26 16:40 +0200
csiph-web