idle.c (dd84cfff3cc3b79c9d616f85bd1178df135cbd1a) idle.c (e67198cc05b8ecbb7b8e2d8ef9fb5c8d26821873)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Generic entry points for the idle threads and
4 * implementation of the idle task scheduling class.
5 *
6 * (NOTE: these are not related to SCHED_IDLE batch scheduled
7 * tasks which are handled in sched/fair.c )
8 */

--- 39 unchanged lines hidden (view full) ---

48}
49__setup("hlt", cpu_idle_nopoll_setup);
50#endif
51
52static noinline int __cpuidle cpu_idle_poll(void)
53{
54 trace_cpu_idle(0, smp_processor_id());
55 stop_critical_timings();
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Generic entry points for the idle threads and
4 * implementation of the idle task scheduling class.
5 *
6 * (NOTE: these are not related to SCHED_IDLE batch scheduled
7 * tasks which are handled in sched/fair.c )
8 */

--- 39 unchanged lines hidden (view full) ---

48}
49__setup("hlt", cpu_idle_nopoll_setup);
50#endif
51
52static noinline int __cpuidle cpu_idle_poll(void)
53{
54 trace_cpu_idle(0, smp_processor_id());
55 stop_critical_timings();
56 rcu_idle_enter();
56 ct_idle_enter();
57 local_irq_enable();
58
59 while (!tif_need_resched() &&
60 (cpu_idle_force_poll || tick_check_broadcast_expired()))
61 cpu_relax();
62
57 local_irq_enable();
58
59 while (!tif_need_resched() &&
60 (cpu_idle_force_poll || tick_check_broadcast_expired()))
61 cpu_relax();
62
63 rcu_idle_exit();
63 ct_idle_exit();
64 start_critical_timings();
65 trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
66
67 return 1;
68}
69
70/* Weak implementations for optional arch specific functions */
71void __weak arch_cpu_idle_prepare(void) { }

--- 21 unchanged lines hidden (view full) ---

93 stop_critical_timings();
94
95 /*
96 * arch_cpu_idle() is supposed to enable IRQs, however
97 * we can't do that because of RCU and tracing.
98 *
99 * Trace IRQs enable here, then switch off RCU, and have
100 * arch_cpu_idle() use raw_local_irq_enable(). Note that
64 start_critical_timings();
65 trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
66
67 return 1;
68}
69
70/* Weak implementations for optional arch specific functions */
71void __weak arch_cpu_idle_prepare(void) { }

--- 21 unchanged lines hidden (view full) ---

93 stop_critical_timings();
94
95 /*
96 * arch_cpu_idle() is supposed to enable IRQs, however
97 * we can't do that because of RCU and tracing.
98 *
99 * Trace IRQs enable here, then switch off RCU, and have
100 * arch_cpu_idle() use raw_local_irq_enable(). Note that
101 * rcu_idle_enter() relies on lockdep IRQ state, so switch that
101 * ct_idle_enter() relies on lockdep IRQ state, so switch that
102 * last -- this is very similar to the entry code.
103 */
104 trace_hardirqs_on_prepare();
105 lockdep_hardirqs_on_prepare();
102 * last -- this is very similar to the entry code.
103 */
104 trace_hardirqs_on_prepare();
105 lockdep_hardirqs_on_prepare();
106 rcu_idle_enter();
106 ct_idle_enter();
107 lockdep_hardirqs_on(_THIS_IP_);
108
109 arch_cpu_idle();
110
111 /*
112 * OK, so IRQs are enabled here, but RCU needs them disabled to
113 * turn itself back on.. funny thing is that disabling IRQs
114 * will cause tracing, which needs RCU. Jump through hoops to
115 * make it 'work'.
116 */
117 raw_local_irq_disable();
118 lockdep_hardirqs_off(_THIS_IP_);
107 lockdep_hardirqs_on(_THIS_IP_);
108
109 arch_cpu_idle();
110
111 /*
112 * OK, so IRQs are enabled here, but RCU needs them disabled to
113 * turn itself back on.. funny thing is that disabling IRQs
114 * will cause tracing, which needs RCU. Jump through hoops to
115 * make it 'work'.
116 */
117 raw_local_irq_disable();
118 lockdep_hardirqs_off(_THIS_IP_);
119 rcu_idle_exit();
119 ct_idle_exit();
120 lockdep_hardirqs_on(_THIS_IP_);
121 raw_local_irq_enable();
122
123 start_critical_timings();
124 trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
125 }
126}
127

--- 396 unchanged lines hidden ---
120 lockdep_hardirqs_on(_THIS_IP_);
121 raw_local_irq_enable();
122
123 start_critical_timings();
124 trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
125 }
126}
127

--- 396 unchanged lines hidden ---