cpumask: use work_on_cpu in acpi/cstate.c

Impact: use new cpumask API to reduce stack usage

Replace the saving of current->cpus_allowed and set_cpus_allowed_ptr() with
a work_on_cpu function for the acpi_processor_ffh_cstate_probe() function.

Basically splits acpi_processor_ffh_cstate_probe() into two functions, the
other being acpi_processor_ffh_cstate_probe_cpu which is the work function
run on the designated cpu.

Signed-off-by: Mike Travis <travis@sgi.com>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

Mike Travis and committed by
Ingo Molnar
c74f31c0 835481d9

+37 -33
+37 -33
arch/x86/kernel/acpi/cstate.c
··· 66 67 #define NATIVE_CSTATE_BEYOND_HALT (2) 68 69 - int acpi_processor_ffh_cstate_probe(unsigned int cpu, 70 - struct acpi_processor_cx *cx, struct acpi_power_register *reg) 71 { 72 - struct cstate_entry *percpu_entry; 73 - struct cpuinfo_x86 *c = &cpu_data(cpu); 74 - 75 - cpumask_t saved_mask; 76 - int retval; 77 unsigned int eax, ebx, ecx, edx; 78 unsigned int edx_part; 79 unsigned int cstate_type; /* C-state type and not ACPI C-state type */ 80 unsigned int num_cstate_subtype; 81 - 82 - if (!cpu_cstate_entry || c->cpuid_level < CPUID_MWAIT_LEAF ) 83 - return -1; 84 - 85 - if (reg->bit_offset != NATIVE_CSTATE_BEYOND_HALT) 86 - return -1; 87 - 88 - percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu); 89 - percpu_entry->states[cx->index].eax = 0; 90 - percpu_entry->states[cx->index].ecx = 0; 91 - 92 - /* Make sure we are running on right CPU */ 93 - saved_mask = current->cpus_allowed; 94 - retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 95 - if (retval) 96 - return -1; 97 98 cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); 99 ··· 94 retval = -1; 95 goto out; 96 } 97 - percpu_entry->states[cx->index].ecx = MWAIT_ECX_INTERRUPT_BREAK; 98 - 99 - /* Use the hint in CST */ 100 - percpu_entry->states[cx->index].eax = cx->address; 101 102 if (!mwait_supported[cstate_type]) { 103 mwait_supported[cstate_type] = 1; 104 - printk(KERN_DEBUG "Monitor-Mwait will be used to enter C-%d " 105 - "state\n", cx->type); 106 } 107 - snprintf(cx->desc, ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x", 108 - cx->address); 109 - 110 out: 111 - set_cpus_allowed_ptr(current, &saved_mask); 112 return retval; 113 } 114 EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe);
··· 66 67 #define NATIVE_CSTATE_BEYOND_HALT (2) 68 69 + static long acpi_processor_ffh_cstate_probe_cpu(void *_cx) 70 { 71 + struct acpi_processor_cx *cx = _cx; 72 + long retval; 73 unsigned int eax, ebx, ecx, edx; 74 unsigned int edx_part; 75 unsigned int cstate_type; /* C-state type and not ACPI C-state type */ 76 unsigned int num_cstate_subtype; 77 78 cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); 79 ··· 114 retval = -1; 115 goto out; 116 } 117 118 if (!mwait_supported[cstate_type]) { 119 mwait_supported[cstate_type] = 1; 120 + printk(KERN_DEBUG 121 + "Monitor-Mwait will be used to enter C-%d " 122 + "state\n", cx->type); 123 } 124 + snprintf(cx->desc, 125 + ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x", 126 + cx->address); 127 out: 128 + return retval; 129 + } 130 + 131 + int acpi_processor_ffh_cstate_probe(unsigned int cpu, 132 + struct acpi_processor_cx *cx, struct acpi_power_register *reg) 133 + { 134 + struct cstate_entry *percpu_entry; 135 + struct cpuinfo_x86 *c = &cpu_data(cpu); 136 + long retval; 137 + 138 + if (!cpu_cstate_entry || c->cpuid_level < CPUID_MWAIT_LEAF) 139 + return -1; 140 + 141 + if (reg->bit_offset != NATIVE_CSTATE_BEYOND_HALT) 142 + return -1; 143 + 144 + percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu); 145 + percpu_entry->states[cx->index].eax = 0; 146 + percpu_entry->states[cx->index].ecx = 0; 147 + 148 + /* Make sure we are running on right CPU */ 149 + 150 + retval = work_on_cpu(cpu, acpi_processor_ffh_cstate_probe_cpu, cx); 151 + if (retval == 0) { 152 + /* Use the hint in CST */ 153 + percpu_entry->states[cx->index].eax = cx->address; 154 + percpu_entry->states[cx->index].ecx = MWAIT_ECX_INTERRUPT_BREAK; 155 + } 156 return retval; 157 } 158 EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe);