aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2013-10-15 15:49:59 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2013-10-15 15:49:59 -0400
commit252997330908cb8ee3d5714539ed967b977c2eae (patch)
tree627395514c622dc6eb51ae3a2a5bbebddc788299 /kernel
parent25e03a74e4a14e0d52a66fb56c728f049a6a26d3 (diff)
parent5c173eb8bcb9c1aa888bd6d14a4cb746f3dd2420 (diff)
Merge branch 'idle.2013.09.25a' into HEAD
idle.2013.09.25a: Topic branch for idle entry-/exit-related changes.
Diffstat (limited to 'kernel')
-rw-r--r--kernel/lockdep.c4
-rw-r--r--kernel/rcupdate.c2
-rw-r--r--kernel/rcutiny.c10
-rw-r--r--kernel/rcutree.c23
-rw-r--r--kernel/rcutree.h2
-rw-r--r--kernel/rcutree_plugin.h24
6 files changed, 41 insertions, 24 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index e16c45b9ee77..4e8e14c34e42 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -4224,7 +4224,7 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)
4224 printk("\n%srcu_scheduler_active = %d, debug_locks = %d\n", 4224 printk("\n%srcu_scheduler_active = %d, debug_locks = %d\n",
4225 !rcu_lockdep_current_cpu_online() 4225 !rcu_lockdep_current_cpu_online()
4226 ? "RCU used illegally from offline CPU!\n" 4226 ? "RCU used illegally from offline CPU!\n"
4227 : rcu_is_cpu_idle() 4227 : !rcu_is_watching()
4228 ? "RCU used illegally from idle CPU!\n" 4228 ? "RCU used illegally from idle CPU!\n"
4229 : "", 4229 : "",
4230 rcu_scheduler_active, debug_locks); 4230 rcu_scheduler_active, debug_locks);
@@ -4247,7 +4247,7 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)
4247 * So complain bitterly if someone does call rcu_read_lock(), 4247 * So complain bitterly if someone does call rcu_read_lock(),
4248 * rcu_read_lock_bh() and so on from extended quiescent states. 4248 * rcu_read_lock_bh() and so on from extended quiescent states.
4249 */ 4249 */
4250 if (rcu_is_cpu_idle()) 4250 if (!rcu_is_watching())
4251 printk("RCU used illegally from extended quiescent state!\n"); 4251 printk("RCU used illegally from extended quiescent state!\n");
4252 4252
4253 lockdep_print_held_locks(curr); 4253 lockdep_print_held_locks(curr);
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index 3260a1074b48..c07af1c4e1bb 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -148,7 +148,7 @@ int rcu_read_lock_bh_held(void)
148{ 148{
149 if (!debug_lockdep_rcu_enabled()) 149 if (!debug_lockdep_rcu_enabled())
150 return 1; 150 return 1;
151 if (rcu_is_cpu_idle()) 151 if (!rcu_is_watching())
152 return 0; 152 return 0;
153 if (!rcu_lockdep_current_cpu_online()) 153 if (!rcu_lockdep_current_cpu_online())
154 return 0; 154 return 0;
diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
index 7e3b0d6fc6e2..312e9709713f 100644
--- a/kernel/rcutiny.c
+++ b/kernel/rcutiny.c
@@ -176,18 +176,18 @@ void rcu_irq_enter(void)
176} 176}
177EXPORT_SYMBOL_GPL(rcu_irq_enter); 177EXPORT_SYMBOL_GPL(rcu_irq_enter);
178 178
179#ifdef CONFIG_DEBUG_LOCK_ALLOC 179#if defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE)
180 180
181/* 181/*
182 * Test whether RCU thinks that the current CPU is idle. 182 * Test whether RCU thinks that the current CPU is idle.
183 */ 183 */
184int rcu_is_cpu_idle(void) 184bool __rcu_is_watching(void)
185{ 185{
186 return !rcu_dynticks_nesting; 186 return rcu_dynticks_nesting;
187} 187}
188EXPORT_SYMBOL(rcu_is_cpu_idle); 188EXPORT_SYMBOL(__rcu_is_watching);
189 189
190#endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */ 190#endif /* defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) */
191 191
192/* 192/*
193 * Test whether the current CPU was interrupted from idle. Nested 193 * Test whether the current CPU was interrupted from idle. Nested
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index a06d172c75e0..240604aa3f70 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -650,21 +650,34 @@ void rcu_nmi_exit(void)
650} 650}
651 651
652/** 652/**
653 * rcu_is_cpu_idle - see if RCU thinks that the current CPU is idle 653 * __rcu_is_watching - are RCU read-side critical sections safe?
654 *
655 * Return true if RCU is watching the running CPU, which means that
656 * this CPU can safely enter RCU read-side critical sections. Unlike
657 * rcu_is_watching(), the caller of __rcu_is_watching() must have at
658 * least disabled preemption.
659 */
660bool __rcu_is_watching(void)
661{
662 return atomic_read(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1;
663}
664
665/**
666 * rcu_is_watching - see if RCU thinks that the current CPU is idle
654 * 667 *
655 * If the current CPU is in its idle loop and is neither in an interrupt 668 * If the current CPU is in its idle loop and is neither in an interrupt
656 * or NMI handler, return true. 669 * or NMI handler, return true.
657 */ 670 */
658int rcu_is_cpu_idle(void) 671bool rcu_is_watching(void)
659{ 672{
660 int ret; 673 int ret;
661 674
662 preempt_disable(); 675 preempt_disable();
663 ret = (atomic_read(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1) == 0; 676 ret = __rcu_is_watching();
664 preempt_enable(); 677 preempt_enable();
665 return ret; 678 return ret;
666} 679}
667EXPORT_SYMBOL(rcu_is_cpu_idle); 680EXPORT_SYMBOL_GPL(rcu_is_watching);
668 681
669#if defined(CONFIG_PROVE_RCU) && defined(CONFIG_HOTPLUG_CPU) 682#if defined(CONFIG_PROVE_RCU) && defined(CONFIG_HOTPLUG_CPU)
670 683
@@ -2321,7 +2334,7 @@ static void __call_rcu_core(struct rcu_state *rsp, struct rcu_data *rdp,
2321 * If called from an extended quiescent state, invoke the RCU 2334 * If called from an extended quiescent state, invoke the RCU
2322 * core in order to force a re-evaluation of RCU's idleness. 2335 * core in order to force a re-evaluation of RCU's idleness.
2323 */ 2336 */
2324 if (rcu_is_cpu_idle() && cpu_online(smp_processor_id())) 2337 if (!rcu_is_watching() && cpu_online(smp_processor_id()))
2325 invoke_rcu_core(); 2338 invoke_rcu_core();
2326 2339
2327 /* If interrupts were disabled or CPU offline, don't invoke RCU core. */ 2340 /* If interrupts were disabled or CPU offline, don't invoke RCU core. */
diff --git a/kernel/rcutree.h b/kernel/rcutree.h
index 5f97eab602cd..52be957c9fe2 100644
--- a/kernel/rcutree.h
+++ b/kernel/rcutree.h
@@ -104,6 +104,8 @@ struct rcu_dynticks {
104 /* idle-period nonlazy_posted snapshot. */ 104 /* idle-period nonlazy_posted snapshot. */
105 unsigned long last_accelerate; 105 unsigned long last_accelerate;
106 /* Last jiffy CBs were accelerated. */ 106 /* Last jiffy CBs were accelerated. */
107 unsigned long last_advance_all;
108 /* Last jiffy CBs were all advanced. */
107 int tick_nohz_enabled_snap; /* Previously seen value from sysfs. */ 109 int tick_nohz_enabled_snap; /* Previously seen value from sysfs. */
108#endif /* #ifdef CONFIG_RCU_FAST_NO_HZ */ 110#endif /* #ifdef CONFIG_RCU_FAST_NO_HZ */
109}; 111};
diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
index cd95efa1da48..8d85a5ce093a 100644
--- a/kernel/rcutree_plugin.h
+++ b/kernel/rcutree_plugin.h
@@ -1635,17 +1635,23 @@ module_param(rcu_idle_lazy_gp_delay, int, 0644);
1635extern int tick_nohz_enabled; 1635extern int tick_nohz_enabled;
1636 1636
1637/* 1637/*
1638 * Try to advance callbacks for all flavors of RCU on the current CPU. 1638 * Try to advance callbacks for all flavors of RCU on the current CPU, but
1639 * Afterwards, if there are any callbacks ready for immediate invocation, 1639 * only if it has been awhile since the last time we did so. Afterwards,
1640 * return true. 1640 * if there are any callbacks ready for immediate invocation, return true.
1641 */ 1641 */
1642static bool rcu_try_advance_all_cbs(void) 1642static bool rcu_try_advance_all_cbs(void)
1643{ 1643{
1644 bool cbs_ready = false; 1644 bool cbs_ready = false;
1645 struct rcu_data *rdp; 1645 struct rcu_data *rdp;
1646 struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks);
1646 struct rcu_node *rnp; 1647 struct rcu_node *rnp;
1647 struct rcu_state *rsp; 1648 struct rcu_state *rsp;
1648 1649
1650 /* Exit early if we advanced recently. */
1651 if (jiffies == rdtp->last_advance_all)
1652 return 0;
1653 rdtp->last_advance_all = jiffies;
1654
1649 for_each_rcu_flavor(rsp) { 1655 for_each_rcu_flavor(rsp) {
1650 rdp = this_cpu_ptr(rsp->rda); 1656 rdp = this_cpu_ptr(rsp->rda);
1651 rnp = rdp->mynode; 1657 rnp = rdp->mynode;
@@ -1744,6 +1750,8 @@ static void rcu_prepare_for_idle(int cpu)
1744 */ 1750 */
1745 if (rdtp->all_lazy && 1751 if (rdtp->all_lazy &&
1746 rdtp->nonlazy_posted != rdtp->nonlazy_posted_snap) { 1752 rdtp->nonlazy_posted != rdtp->nonlazy_posted_snap) {
1753 rdtp->all_lazy = false;
1754 rdtp->nonlazy_posted_snap = rdtp->nonlazy_posted;
1747 invoke_rcu_core(); 1755 invoke_rcu_core();
1748 return; 1756 return;
1749 } 1757 }
@@ -1773,17 +1781,11 @@ static void rcu_prepare_for_idle(int cpu)
1773 */ 1781 */
1774static void rcu_cleanup_after_idle(int cpu) 1782static void rcu_cleanup_after_idle(int cpu)
1775{ 1783{
1776 struct rcu_data *rdp;
1777 struct rcu_state *rsp;
1778 1784
1779 if (rcu_is_nocb_cpu(cpu)) 1785 if (rcu_is_nocb_cpu(cpu))
1780 return; 1786 return;
1781 rcu_try_advance_all_cbs(); 1787 if (rcu_try_advance_all_cbs())
1782 for_each_rcu_flavor(rsp) { 1788 invoke_rcu_core();
1783 rdp = per_cpu_ptr(rsp->rda, cpu);
1784 if (cpu_has_callbacks_ready_to_invoke(rdp))
1785 invoke_rcu_core();
1786 }
1787} 1789}
1788 1790
1789/* 1791/*