Skip to content

Commit 8747f20

Browse files
Peter Zijlstrarafaeljw
authored andcommitted
cpuidle: Allow cpuidle drivers to take over RCU-idle
Some drivers have to do significant work, some of which relies on RCU still being active. Instead of using RCU_NONIDLE in the drivers and flipping RCU back on, allow drivers to take over RCU-idle duty. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Tested-by: Borislav Petkov <bp@suse.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent a889a23 commit 8747f20

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎drivers/cpuidle/cpuidle.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ static void enter_s2idle_proper(struct cpuidle_driver *drv,
138138
struct cpuidle_device *dev, int index)
139139
{
140140
ktime_t time_start, time_end;
141+
struct cpuidle_state *target_state = &drv->states[index];
141142

142143
time_start = ns_to_ktime(local_clock());
143144

@@ -153,16 +154,18 @@ static void enter_s2idle_proper(struct cpuidle_driver *drv,
153154
* suspended is generally unsafe.
154155
*/
155156
stop_critical_timings();
156-
rcu_idle_enter();
157-
drv->states[index].enter_s2idle(dev, drv, index);
157+
if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE))
158+
rcu_idle_enter();
159+
target_state->enter_s2idle(dev, drv, index);
158160
if (WARN_ON_ONCE(!irqs_disabled()))
159161
local_irq_disable();
160162
/*
161163
* timekeeping_resume() that will be called by tick_unfreeze() for the
162164
* first CPU executing it calls functions containing RCU read-side
163165
* critical sections, so tell RCU about that.
164166
*/
165-
rcu_idle_exit();
167+
if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE))
168+
rcu_idle_exit();
166169
tick_unfreeze();
167170
start_critical_timings();
168171

@@ -239,9 +242,11 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
239242
time_start = ns_to_ktime(local_clock());
240243

241244
stop_critical_timings();
242-
rcu_idle_enter();
245+
if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE))
246+
rcu_idle_enter();
243247
entered_state = target_state->enter(dev, drv, index);
244-
rcu_idle_exit();
248+
if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE))
249+
rcu_idle_exit();
245250
start_critical_timings();
246251

247252
sched_clock_idle_wakeup_event();

‎include/linux/cpuidle.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ struct cpuidle_state {
8282
#define CPUIDLE_FLAG_UNUSABLE BIT(3) /* avoid using this state */
8383
#define CPUIDLE_FLAG_OFF BIT(4) /* disable this state by default */
8484
#define CPUIDLE_FLAG_TLB_FLUSHED BIT(5) /* idle-state flushes TLBs */
85+
#define CPUIDLE_FLAG_RCU_IDLE BIT(6) /* idle-state takes care of RCU */
8586

8687
struct cpuidle_device_kobj;
8788
struct cpuidle_state_kobj;

0 commit comments

Comments
 (0)