|
40 | 40 | #include <arch/abi.h>
|
41 | 41 | #include <arch/sim_def.h>
|
42 | 42 |
|
43 |
| - |
44 | 43 | /*
|
45 | 44 | * Use the (x86) "idle=poll" option to prefer low latency when leaving the
|
46 | 45 | * idle loop over low power while in the idle loop, e.g. if we have
|
47 | 46 | * one thread per core and we want to get threads out of futex waits fast.
|
48 | 47 | */
|
49 |
| -static int no_idle_nap; |
50 | 48 | static int __init idle_setup(char *str)
|
51 | 49 | {
|
52 | 50 | if (!str)
|
53 | 51 | return -EINVAL;
|
54 | 52 |
|
55 | 53 | if (!strcmp(str, "poll")) {
|
56 | 54 | pr_info("using polling idle threads.\n");
|
57 |
| - no_idle_nap = 1; |
58 |
| - } else if (!strcmp(str, "halt")) |
59 |
| - no_idle_nap = 0; |
60 |
| - else |
61 |
| - return -1; |
62 |
| - |
63 |
| - return 0; |
| 55 | + cpu_idle_poll_ctrl(true); |
| 56 | + return 0; |
| 57 | + } else if (!strcmp(str, "halt")) { |
| 58 | + return 0; |
| 59 | + } |
| 60 | + return -1; |
64 | 61 | }
|
65 | 62 | early_param("idle", idle_setup);
|
66 | 63 |
|
67 |
| -/* |
68 |
| - * The idle thread. There's no useful work to be |
69 |
| - * done, so just try to conserve power and have a |
70 |
| - * low exit latency (ie sit in a loop waiting for |
71 |
| - * somebody to say that they'd like to reschedule) |
72 |
| - */ |
73 |
| -void cpu_idle(void) |
| 64 | +void arch_cpu_idle(void) |
74 | 65 | {
|
75 |
| - int cpu = smp_processor_id(); |
76 |
| - |
77 |
| - |
78 |
| - current_thread_info()->status |= TS_POLLING; |
79 |
| - |
80 |
| - if (no_idle_nap) { |
81 |
| - while (1) { |
82 |
| - while (!need_resched()) |
83 |
| - cpu_relax(); |
84 |
| - schedule(); |
85 |
| - } |
86 |
| - } |
87 |
| - |
88 |
| - /* endless idle loop with no priority at all */ |
89 |
| - while (1) { |
90 |
| - tick_nohz_idle_enter(); |
91 |
| - rcu_idle_enter(); |
92 |
| - while (!need_resched()) { |
93 |
| - if (cpu_is_offline(cpu)) |
94 |
| - BUG(); /* no HOTPLUG_CPU */ |
95 |
| - |
96 |
| - local_irq_disable(); |
97 |
| - __get_cpu_var(irq_stat).idle_timestamp = jiffies; |
98 |
| - current_thread_info()->status &= ~TS_POLLING; |
99 |
| - /* |
100 |
| - * TS_POLLING-cleared state must be visible before we |
101 |
| - * test NEED_RESCHED: |
102 |
| - */ |
103 |
| - smp_mb(); |
104 |
| - |
105 |
| - if (!need_resched()) |
106 |
| - _cpu_idle(); |
107 |
| - else |
108 |
| - local_irq_enable(); |
109 |
| - current_thread_info()->status |= TS_POLLING; |
110 |
| - } |
111 |
| - rcu_idle_exit(); |
112 |
| - tick_nohz_idle_exit(); |
113 |
| - schedule_preempt_disabled(); |
114 |
| - } |
| 66 | + __get_cpu_var(irq_stat).idle_timestamp = jiffies; |
| 67 | + _cpu_idle(); |
115 | 68 | }
|
116 | 69 |
|
117 | 70 | /*
|
|
0 commit comments