aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2009-08-22 16:56:52 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-23 04:32:40 -0400
commitf41d911f8c49a5d65c86504c19e8204bb605c4fd (patch)
tree59bcd3048652ef290b3e19d2904409afd5c90eb3 /include/linux/sched.h
parenta157229cabd6dd8cfa82525fc9bf730c94cc9ac2 (diff)
rcu: Merge preemptable-RCU functionality into hierarchical RCU
Create a kernel/rcutree_plugin.h file that contains definitions for preemptable RCU (or, under the #else branch of the #ifdef, empty definitions for the classic non-preemptable semantics). These definitions fit into plugins defined in kernel/rcutree.c for this purpose. This variant of preemptable RCU uses a new algorithm whose read-side expense is roughly that of classic hierarchical RCU under CONFIG_PREEMPT. This new algorithm's update-side expense is similar to that of classic hierarchical RCU, and, in absence of read-side preemption or blocking, is exactly that of classic hierarchical RCU. Perhaps more important, this new algorithm has a much simpler implementation, saving well over 1,000 lines of code compared to mainline's implementation of preemptable RCU, which will hopefully be retired in favor of this new algorithm. The simplifications are obtained by maintaining per-task nesting state for running tasks, and using a simple lock-protected algorithm to handle accounting when tasks block within RCU read-side critical sections, making use of lessons learned while creating numerous user-level RCU implementations over the past 18 months. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: laijs@cn.fujitsu.com Cc: dipankar@in.ibm.com Cc: akpm@linux-foundation.org Cc: mathieu.desnoyers@polymtl.ca Cc: josht@linux.vnet.ibm.com Cc: dvhltc@us.ibm.com Cc: niv@us.ibm.com Cc: peterz@infradead.org Cc: rostedt@goodmis.org LKML-Reference: <12509746134003-git-send-email-> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 3ab08e4bb6b8..d7f98f637a2a 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1210,6 +1210,13 @@ struct task_struct {
1210 int rcu_flipctr_idx; 1210 int rcu_flipctr_idx;
1211#endif /* #ifdef CONFIG_PREEMPT_RCU */ 1211#endif /* #ifdef CONFIG_PREEMPT_RCU */
1212 1212
1213#ifdef CONFIG_TREE_PREEMPT_RCU
1214 int rcu_read_lock_nesting;
1215 char rcu_read_unlock_special;
1216 int rcu_blocked_cpu;
1217 struct list_head rcu_node_entry;
1218#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
1219
1213#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) 1220#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
1214 struct sched_info sched_info; 1221 struct sched_info sched_info;
1215#endif 1222#endif
@@ -1723,6 +1730,36 @@ extern cputime_t task_gtime(struct task_struct *p);
1723#define tsk_used_math(p) ((p)->flags & PF_USED_MATH) 1730#define tsk_used_math(p) ((p)->flags & PF_USED_MATH)
1724#define used_math() tsk_used_math(current) 1731#define used_math() tsk_used_math(current)
1725 1732
1733#ifdef CONFIG_TREE_PREEMPT_RCU
1734
1735#define RCU_READ_UNLOCK_BLOCKED (1 << 0) /* blocked while in RCU read-side. */
1736#define RCU_READ_UNLOCK_NEED_QS (1 << 1) /* RCU core needs CPU response. */
1737#define RCU_READ_UNLOCK_GOT_QS (1 << 2) /* CPU has responded to RCU core. */
1738
1739static inline void rcu_copy_process(struct task_struct *p)
1740{
1741 p->rcu_read_lock_nesting = 0;
1742 p->rcu_read_unlock_special = 0;
1743 p->rcu_blocked_cpu = -1;
1744 INIT_LIST_HEAD(&p->rcu_node_entry);
1745}
1746
1747#elif defined(CONFIG_PREEMPT_RCU)
1748
1749static inline void rcu_copy_process(struct task_struct *p)
1750{
1751 p->rcu_read_lock_nesting = 0;
1752 p->rcu_flipctr_idx = 0;
1753}
1754
1755#else
1756
1757static inline void rcu_copy_process(struct task_struct *p)
1758{
1759}
1760
1761#endif
1762
1726#ifdef CONFIG_SMP 1763#ifdef CONFIG_SMP
1727extern int set_cpus_allowed_ptr(struct task_struct *p, 1764extern int set_cpus_allowed_ptr(struct task_struct *p,
1728 const struct cpumask *new_mask); 1765 const struct cpumask *new_mask);