Commit 151f8cc1169f9052095b2be36183ab132d75c6c2
Committed by
Andi Kleen
1 parent
34464a5b89
Exists in
master
and in
4 other branches
[PATCH] Remove safe_smp_processor_id()
And replace all users with ordinary smp_processor_id. The function was originally added to get some basic oops information out even if the GS register was corrupted. However that didn't work for some anymore because printk is needed to print the oops and it uses smp_processor_id() already. Also GS register corruptions are not particularly common anymore. This also helps the Xen port which would otherwise need to do this in a special way because it can't access the local APIC. Cc: Chris Wright <chrisw@sous-sol.org> Signed-off-by: Andi Kleen <ak@suse.de>
Showing 4 changed files with 6 additions and 31 deletions Side-by-side Diff
arch/x86_64/kernel/mce.c
arch/x86_64/kernel/smp.c
| ... | ... | @@ -521,28 +521,4 @@ |
| 521 | 521 | atomic_inc(&call_data->finished); |
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | - | |
| 525 | -int safe_smp_processor_id(void) | |
| 526 | -{ | |
| 527 | - unsigned apicid, i; | |
| 528 | - | |
| 529 | - if (disable_apic || !apic_mapped) | |
| 530 | - return 0; | |
| 531 | - | |
| 532 | - apicid = hard_smp_processor_id(); | |
| 533 | - if (apicid < NR_CPUS && x86_cpu_to_apicid[apicid] == apicid) | |
| 534 | - return apicid; | |
| 535 | - | |
| 536 | - for (i = 0; i < NR_CPUS; ++i) { | |
| 537 | - if (x86_cpu_to_apicid[i] == apicid) | |
| 538 | - return i; | |
| 539 | - } | |
| 540 | - | |
| 541 | - /* No entries in x86_cpu_to_apicid? Either no MPS|ACPI, | |
| 542 | - * or called too early. Either way, we must be CPU 0. */ | |
| 543 | - if (x86_cpu_to_apicid[0] == BAD_APICID) | |
| 544 | - return 0; | |
| 545 | - | |
| 546 | - return 0; /* Should not happen */ | |
| 547 | -} |
arch/x86_64/kernel/traps.c
| ... | ... | @@ -264,7 +264,7 @@ |
| 264 | 264 | void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * stack, |
| 265 | 265 | struct stacktrace_ops *ops, void *data) |
| 266 | 266 | { |
| 267 | - const unsigned cpu = safe_smp_processor_id(); | |
| 267 | + const unsigned cpu = smp_processor_id(); | |
| 268 | 268 | unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr; |
| 269 | 269 | unsigned used = 0; |
| 270 | 270 | |
| ... | ... | @@ -429,7 +429,7 @@ |
| 429 | 429 | { |
| 430 | 430 | unsigned long *stack; |
| 431 | 431 | int i; |
| 432 | - const int cpu = safe_smp_processor_id(); | |
| 432 | + const int cpu = smp_processor_id(); | |
| 433 | 433 | unsigned long *irqstack_end = (unsigned long *) (cpu_pda(cpu)->irqstackptr); |
| 434 | 434 | unsigned long *irqstack = (unsigned long *) (cpu_pda(cpu)->irqstackptr - IRQSTACKSIZE); |
| 435 | 435 | |
| ... | ... | @@ -483,7 +483,7 @@ |
| 483 | 483 | int i; |
| 484 | 484 | int in_kernel = !user_mode(regs); |
| 485 | 485 | unsigned long rsp; |
| 486 | - const int cpu = safe_smp_processor_id(); | |
| 486 | + const int cpu = smp_processor_id(); | |
| 487 | 487 | struct task_struct *cur = cpu_pda(cpu)->pcurrent; |
| 488 | 488 | |
| 489 | 489 | rsp = regs->rsp; |
| ... | ... | @@ -558,7 +558,7 @@ |
| 558 | 558 | |
| 559 | 559 | unsigned __kprobes long oops_begin(void) |
| 560 | 560 | { |
| 561 | - int cpu = safe_smp_processor_id(); | |
| 561 | + int cpu = smp_processor_id(); | |
| 562 | 562 | unsigned long flags; |
| 563 | 563 | |
| 564 | 564 | oops_enter(); |
| ... | ... | @@ -636,7 +636,7 @@ |
| 636 | 636 | * We are in trouble anyway, lets at least try |
| 637 | 637 | * to get a message out. |
| 638 | 638 | */ |
| 639 | - printk(str, safe_smp_processor_id()); | |
| 639 | + printk(str, smp_processor_id()); | |
| 640 | 640 | show_registers(regs); |
| 641 | 641 | if (kexec_should_crash(current)) |
| 642 | 642 | crash_kexec(regs); |
include/asm-x86_64/smp.h
| ... | ... | @@ -66,7 +66,6 @@ |
| 66 | 66 | return GET_APIC_ID(*(unsigned int *)(APIC_BASE+APIC_ID)); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | -extern int safe_smp_processor_id(void); | |
| 70 | 69 | extern int __cpu_disable(void); |
| 71 | 70 | extern void __cpu_die(unsigned int cpu); |
| 72 | 71 | extern void prefill_possible_map(void); |
| ... | ... | @@ -100,7 +99,6 @@ |
| 100 | 99 | |
| 101 | 100 | #ifndef CONFIG_SMP |
| 102 | 101 | #define stack_smp_processor_id() 0 |
| 103 | -#define safe_smp_processor_id() 0 | |
| 104 | 102 | #define cpu_logical_map(x) (x) |
| 105 | 103 | #else |
| 106 | 104 | #include <asm/thread_info.h> |