diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-04-28 01:23:45 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2011-05-06 02:16:59 -0400 |
commit | b554d7de8d112fca4188da3bf0d7f8b56f42fb95 (patch) | |
tree | 3641a25b7356da1bdcb52f6ff160f605ed778cd4 /kernel/rcutiny.c | |
parent | 2655d57ef35aa327a2e58a1c5dc7b65c65003f4e (diff) |
rcu: optimize rcutiny
rcu_sched_qs() currently calls local_irq_save()/local_irq_restore() up
to three times.
Remove irq masking from rcu_qsctr_help() / invoke_rcu_kthread()
and do it once in rcu_sched_qs() / rcu_bh_qs()
This generates smaller code as well.
text data bss dec hex filename
2314 156 24 2494 9be kernel/rcutiny.old.o
2250 156 24 2430 97e kernel/rcutiny.new.o
Fix an outdated comment for rcu_qsctr_help()
Move invoke_rcu_kthread() definition before its use.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'kernel/rcutiny.c')
-rw-r--r-- | kernel/rcutiny.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c index 4d60fbc9c64c..421abfd3641d 100644 --- a/kernel/rcutiny.c +++ b/kernel/rcutiny.c | |||
@@ -40,10 +40,10 @@ | |||
40 | static struct task_struct *rcu_kthread_task; | 40 | static struct task_struct *rcu_kthread_task; |
41 | static DECLARE_WAIT_QUEUE_HEAD(rcu_kthread_wq); | 41 | static DECLARE_WAIT_QUEUE_HEAD(rcu_kthread_wq); |
42 | static unsigned long have_rcu_kthread_work; | 42 | static unsigned long have_rcu_kthread_work; |
43 | static void invoke_rcu_kthread(void); | ||
44 | 43 | ||
45 | /* Forward declarations for rcutiny_plugin.h. */ | 44 | /* Forward declarations for rcutiny_plugin.h. */ |
46 | struct rcu_ctrlblk; | 45 | struct rcu_ctrlblk; |
46 | static void invoke_rcu_kthread(void); | ||
47 | static void rcu_process_callbacks(struct rcu_ctrlblk *rcp); | 47 | static void rcu_process_callbacks(struct rcu_ctrlblk *rcp); |
48 | static int rcu_kthread(void *arg); | 48 | static int rcu_kthread(void *arg); |
49 | static void __call_rcu(struct rcu_head *head, | 49 | static void __call_rcu(struct rcu_head *head, |
@@ -79,36 +79,45 @@ void rcu_exit_nohz(void) | |||
79 | #endif /* #ifdef CONFIG_NO_HZ */ | 79 | #endif /* #ifdef CONFIG_NO_HZ */ |
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Helper function for rcu_qsctr_inc() and rcu_bh_qsctr_inc(). | 82 | * Helper function for rcu_sched_qs() and rcu_bh_qs(). |
83 | * Also disable irqs to avoid confusion due to interrupt handlers | 83 | * Also irqs are disabled to avoid confusion due to interrupt handlers |
84 | * invoking call_rcu(). | 84 | * invoking call_rcu(). |
85 | */ | 85 | */ |
86 | static int rcu_qsctr_help(struct rcu_ctrlblk *rcp) | 86 | static int rcu_qsctr_help(struct rcu_ctrlblk *rcp) |
87 | { | 87 | { |
88 | unsigned long flags; | ||
89 | |||
90 | local_irq_save(flags); | ||
91 | if (rcp->rcucblist != NULL && | 88 | if (rcp->rcucblist != NULL && |
92 | rcp->donetail != rcp->curtail) { | 89 | rcp->donetail != rcp->curtail) { |
93 | rcp->donetail = rcp->curtail; | 90 | rcp->donetail = rcp->curtail; |
94 | local_irq_restore(flags); | ||
95 | return 1; | 91 | return 1; |
96 | } | 92 | } |
97 | local_irq_restore(flags); | ||
98 | 93 | ||
99 | return 0; | 94 | return 0; |
100 | } | 95 | } |
101 | 96 | ||
102 | /* | 97 | /* |
98 | * Wake up rcu_kthread() to process callbacks now eligible for invocation | ||
99 | * or to boost readers. | ||
100 | */ | ||
101 | static void invoke_rcu_kthread(void) | ||
102 | { | ||
103 | have_rcu_kthread_work = 1; | ||
104 | wake_up(&rcu_kthread_wq); | ||
105 | } | ||
106 | |||
107 | /* | ||
103 | * Record an rcu quiescent state. And an rcu_bh quiescent state while we | 108 | * Record an rcu quiescent state. And an rcu_bh quiescent state while we |
104 | * are at it, given that any rcu quiescent state is also an rcu_bh | 109 | * are at it, given that any rcu quiescent state is also an rcu_bh |
105 | * quiescent state. Use "+" instead of "||" to defeat short circuiting. | 110 | * quiescent state. Use "+" instead of "||" to defeat short circuiting. |
106 | */ | 111 | */ |
107 | void rcu_sched_qs(int cpu) | 112 | void rcu_sched_qs(int cpu) |
108 | { | 113 | { |
114 | unsigned long flags; | ||
115 | |||
116 | local_irq_save(flags); | ||
109 | if (rcu_qsctr_help(&rcu_sched_ctrlblk) + | 117 | if (rcu_qsctr_help(&rcu_sched_ctrlblk) + |
110 | rcu_qsctr_help(&rcu_bh_ctrlblk)) | 118 | rcu_qsctr_help(&rcu_bh_ctrlblk)) |
111 | invoke_rcu_kthread(); | 119 | invoke_rcu_kthread(); |
120 | local_irq_restore(flags); | ||
112 | } | 121 | } |
113 | 122 | ||
114 | /* | 123 | /* |
@@ -116,8 +125,12 @@ void rcu_sched_qs(int cpu) | |||
116 | */ | 125 | */ |
117 | void rcu_bh_qs(int cpu) | 126 | void rcu_bh_qs(int cpu) |
118 | { | 127 | { |
128 | unsigned long flags; | ||
129 | |||
130 | local_irq_save(flags); | ||
119 | if (rcu_qsctr_help(&rcu_bh_ctrlblk)) | 131 | if (rcu_qsctr_help(&rcu_bh_ctrlblk)) |
120 | invoke_rcu_kthread(); | 132 | invoke_rcu_kthread(); |
133 | local_irq_restore(flags); | ||
121 | } | 134 | } |
122 | 135 | ||
123 | /* | 136 | /* |
@@ -208,20 +221,6 @@ static int rcu_kthread(void *arg) | |||
208 | } | 221 | } |
209 | 222 | ||
210 | /* | 223 | /* |
211 | * Wake up rcu_kthread() to process callbacks now eligible for invocation | ||
212 | * or to boost readers. | ||
213 | */ | ||
214 | static void invoke_rcu_kthread(void) | ||
215 | { | ||
216 | unsigned long flags; | ||
217 | |||
218 | local_irq_save(flags); | ||
219 | have_rcu_kthread_work = 1; | ||
220 | wake_up(&rcu_kthread_wq); | ||
221 | local_irq_restore(flags); | ||
222 | } | ||
223 | |||
224 | /* | ||
225 | * Wait for a grace period to elapse. But it is illegal to invoke | 224 | * Wait for a grace period to elapse. But it is illegal to invoke |
226 | * synchronize_sched() from within an RCU read-side critical section. | 225 | * synchronize_sched() from within an RCU read-side critical section. |
227 | * Therefore, any legal call to synchronize_sched() is a quiescent | 226 | * Therefore, any legal call to synchronize_sched() is a quiescent |