Skip to content

Commit

Permalink
Merge branch 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/kernel/git/tip/linux-2.6-tip

* 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  x86: Limit number of per cpu TSC sync messages
  x86: dumpstack, 64-bit: Disable preemption when walking the IRQ/exception stacks
  x86: dumpstack: Clean up the x86_stack_ids[][] initalization and other details
  x86, cpu: mv display_cacheinfo -> cpu_detect_cache_sizes
  x86: Suppress stack overrun message for init_task
  x86: Fix cpu_devs[] initialization in early_cpu_init()
  x86: Remove CPU cache size output for non-Intel too
  x86: Minimise printk spew from per-vendor init code
  x86: Remove the CPU cache size printk's
  cpumask: Avoid cpumask_t in arch/x86/kernel/apic/nmi.c
  x86: Make sure we also print a Code: line for show_regs()
  • Loading branch information
torvalds committed Dec 5, 2009
2 parents 83be7d7 + 9b3660a commit 6ec22f9
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 75 deletions.
11 changes: 6 additions & 5 deletions arch/x86/kernel/apic/nmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
int unknown_nmi_panic;
int nmi_watchdog_enabled;

static cpumask_t backtrace_mask __read_mostly;
/* For reliability, we're prepared to waste bits here. */
static DECLARE_BITMAP(backtrace_mask, NR_CPUS) __read_mostly;

/* nmi_active:
* >0: the lapic NMI watchdog is active, but can be disabled
Expand Down Expand Up @@ -414,15 +415,15 @@ nmi_watchdog_tick(struct pt_regs *regs, unsigned reason)
}

/* We can be called before check_nmi_watchdog, hence NULL check. */
if (cpumask_test_cpu(cpu, &backtrace_mask)) {
if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) {
static DEFINE_SPINLOCK(lock); /* Serialise the printks */

spin_lock(&lock);
printk(KERN_WARNING "NMI backtrace for cpu %d\n", cpu);
show_regs(regs);
dump_stack();
spin_unlock(&lock);
cpumask_clear_cpu(cpu, &backtrace_mask);
cpumask_clear_cpu(cpu, to_cpumask(backtrace_mask));

rc = 1;
}
Expand Down Expand Up @@ -558,14 +559,14 @@ void arch_trigger_all_cpu_backtrace(void)
{
int i;

cpumask_copy(&backtrace_mask, cpu_online_mask);
cpumask_copy(to_cpumask(backtrace_mask), cpu_online_mask);

printk(KERN_INFO "sending NMI to all CPUs:\n");
apic->send_IPI_all(NMI_VECTOR);

/* Wait for up to 10 seconds for all CPUs to do the backtrace */
for (i = 0; i < 10 * 1000; i++) {
if (cpumask_empty(&backtrace_mask))
if (cpumask_empty(to_cpumask(backtrace_mask)))
break;
mdelay(1);
}
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/cpu/amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
}
}

display_cacheinfo(c);
cpu_detect_cache_sizes(c);

/* Multi core CPU? */
if (c->extended_cpuid_level >= 0x80000008) {
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/cpu/centaur.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ static void __cpuinit init_c3(struct cpuinfo_x86 *c)
set_cpu_cap(c, X86_FEATURE_REP_GOOD);
}

display_cacheinfo(c);
cpu_detect_cache_sizes(c);
}

enum {
Expand Down
30 changes: 16 additions & 14 deletions arch/x86/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void __init setup_cpu_local_masks(void)
static void __cpuinit default_init(struct cpuinfo_x86 *c)
{
#ifdef CONFIG_X86_64
display_cacheinfo(c);
cpu_detect_cache_sizes(c);
#else
/* Not much we can do here... */
/* Check if at least it has cpuid */
Expand Down Expand Up @@ -383,16 +383,14 @@ static void __cpuinit get_model_name(struct cpuinfo_x86 *c)
}
}

void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
void __cpuinit cpu_detect_cache_sizes(struct cpuinfo_x86 *c)
{
unsigned int n, dummy, ebx, ecx, edx, l2size;

n = c->extended_cpuid_level;

if (n >= 0x80000005) {
cpuid(0x80000005, &dummy, &ebx, &ecx, &edx);
printk(KERN_INFO "CPU: L1 I Cache: %dK (%d bytes/line), D cache %dK (%d bytes/line)\n",
edx>>24, edx&0xFF, ecx>>24, ecx&0xFF);
c->x86_cache_size = (ecx>>24) + (edx>>24);
#ifdef CONFIG_X86_64
/* On K8 L1 TLB is inclusive, so don't count it */
Expand Down Expand Up @@ -422,9 +420,6 @@ void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
#endif

c->x86_cache_size = l2size;

printk(KERN_INFO "CPU: L2 Cache: %dK (%d bytes/line)\n",
l2size, ecx & 0xFF);
}

void __cpuinit detect_ht(struct cpuinfo_x86 *c)
Expand Down Expand Up @@ -659,24 +654,31 @@ void __init early_cpu_init(void)
const struct cpu_dev *const *cdev;
int count = 0;

#ifdef PROCESSOR_SELECT
printk(KERN_INFO "KERNEL supported cpus:\n");
#endif

for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) {
const struct cpu_dev *cpudev = *cdev;
unsigned int j;

if (count >= X86_VENDOR_NUM)
break;
cpu_devs[count] = cpudev;
count++;

for (j = 0; j < 2; j++) {
if (!cpudev->c_ident[j])
continue;
printk(KERN_INFO " %s %s\n", cpudev->c_vendor,
cpudev->c_ident[j]);
#ifdef PROCESSOR_SELECT
{
unsigned int j;

for (j = 0; j < 2; j++) {
if (!cpudev->c_ident[j])
continue;
printk(KERN_INFO " %s %s\n", cpudev->c_vendor,
cpudev->c_ident[j]);
}
}
#endif
}

early_identify_cpu(&boot_cpu_data);
}

Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/cpu/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ struct cpu_dev {
extern const struct cpu_dev *const __x86_cpu_dev_start[],
*const __x86_cpu_dev_end[];

extern void display_cacheinfo(struct cpuinfo_x86 *c);
extern void cpu_detect_cache_sizes(struct cpuinfo_x86 *c);

#endif
2 changes: 1 addition & 1 deletion arch/x86/kernel/cpu/cyrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ static void __cpuinit init_nsc(struct cpuinfo_x86 *c)
/* Handle the GX (Formally known as the GX2) */

if (c->x86 == 5 && c->x86_model == 5)
display_cacheinfo(c);
cpu_detect_cache_sizes(c);
else
init_cyrix(c);
}
Expand Down
16 changes: 0 additions & 16 deletions arch/x86/kernel/cpu/intel_cacheinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,22 +488,6 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
#endif
}

if (trace)
printk(KERN_INFO "CPU: Trace cache: %dK uops", trace);
else if (l1i)
printk(KERN_INFO "CPU: L1 I cache: %dK", l1i);

if (l1d)
printk(KERN_CONT ", L1 D cache: %dK\n", l1d);
else
printk(KERN_CONT "\n");

if (l2)
printk(KERN_INFO "CPU: L2 cache: %dK\n", l2);

if (l3)
printk(KERN_INFO "CPU: L3 cache: %dK\n", l3);

c->x86_cache_size = l3 ? l3 : (l2 ? l2 : (l1i+l1d));

return l2;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/cpu/transmeta.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void __cpuinit init_transmeta(struct cpuinfo_x86 *c)

early_init_transmeta(c);

display_cacheinfo(c);
cpu_detect_cache_sizes(c);

/* Print CMS and CPU revision */
max = cpuid_eax(0x80860000);
Expand Down
9 changes: 4 additions & 5 deletions arch/x86/kernel/dumpstack_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include <linux/module.h>
#include <linux/ptrace.h>
#include <linux/kexec.h>
#include <linux/sysfs.h>
#include <linux/bug.h>
#include <linux/nmi.h>
#include <linux/sysfs.h>

#include <asm/stacktrace.h>

Expand All @@ -35,6 +35,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,

if (!stack) {
unsigned long dummy;

stack = &dummy;
if (task && task != current)
stack = (unsigned long *)task->thread.sp;
Expand All @@ -57,8 +58,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,

context = (struct thread_info *)
((unsigned long)stack & (~(THREAD_SIZE - 1)));
bp = print_context_stack(context, stack, bp, ops,
data, NULL, &graph);
bp = print_context_stack(context, stack, bp, ops, data, NULL, &graph);

stack = (unsigned long *)context->previous_esp;
if (!stack)
Expand All @@ -72,7 +72,7 @@ EXPORT_SYMBOL(dump_trace);

void
show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
unsigned long *sp, unsigned long bp, char *log_lvl)
unsigned long *sp, unsigned long bp, char *log_lvl)
{
unsigned long *stack;
int i;
Expand Down Expand Up @@ -156,4 +156,3 @@ int is_valid_bugaddr(unsigned long ip)

return ud2 == 0x0b0f;
}

46 changes: 26 additions & 20 deletions arch/x86/kernel/dumpstack_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,36 @@
#include <linux/module.h>
#include <linux/ptrace.h>
#include <linux/kexec.h>
#include <linux/sysfs.h>
#include <linux/bug.h>
#include <linux/nmi.h>
#include <linux/sysfs.h>

#include <asm/stacktrace.h>

#include "dumpstack.h"

#define N_EXCEPTION_STACKS_END \
(N_EXCEPTION_STACKS + DEBUG_STKSZ/EXCEPTION_STKSZ - 2)

static char x86_stack_ids[][8] = {
[DEBUG_STACK - 1] = "#DB",
[NMI_STACK - 1] = "NMI",
[DOUBLEFAULT_STACK - 1] = "#DF",
[STACKFAULT_STACK - 1] = "#SS",
[MCE_STACK - 1] = "#MC",
[ DEBUG_STACK-1 ] = "#DB",
[ NMI_STACK-1 ] = "NMI",
[ DOUBLEFAULT_STACK-1 ] = "#DF",
[ STACKFAULT_STACK-1 ] = "#SS",
[ MCE_STACK-1 ] = "#MC",
#if DEBUG_STKSZ > EXCEPTION_STKSZ
[N_EXCEPTION_STACKS ...
N_EXCEPTION_STACKS + DEBUG_STKSZ / EXCEPTION_STKSZ - 2] = "#DB[?]"
[ N_EXCEPTION_STACKS ...
N_EXCEPTION_STACKS_END ] = "#DB[?]"
#endif
};
};

int x86_is_stack_id(int id, char *name)
{
return x86_stack_ids[id - 1] == name;
}

static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
unsigned *usedp, char **idp)
unsigned *usedp, char **idp)
{
unsigned k;

Expand Down Expand Up @@ -202,21 +204,24 @@ EXPORT_SYMBOL(dump_trace);

void
show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
unsigned long *sp, unsigned long bp, char *log_lvl)
unsigned long *sp, unsigned long bp, char *log_lvl)
{
unsigned long *irq_stack_end;
unsigned long *irq_stack;
unsigned long *stack;
int cpu;
int i;
const int cpu = smp_processor_id();
unsigned long *irq_stack_end =
(unsigned long *)(per_cpu(irq_stack_ptr, cpu));
unsigned long *irq_stack =
(unsigned long *)(per_cpu(irq_stack_ptr, cpu) - IRQ_STACK_SIZE);

preempt_disable();
cpu = smp_processor_id();

irq_stack_end = (unsigned long *)(per_cpu(irq_stack_ptr, cpu));
irq_stack = (unsigned long *)(per_cpu(irq_stack_ptr, cpu) - IRQ_STACK_SIZE);

/*
* debugging aid: "show_stack(NULL, NULL);" prints the
* back trace for this cpu.
* Debugging aid: "show_stack(NULL, NULL);" prints the
* back trace for this cpu:
*/

if (sp == NULL) {
if (task)
sp = (unsigned long *)task->thread.sp;
Expand All @@ -240,6 +245,8 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
printk(" %016lx", *stack++);
touch_nmi_watchdog();
}
preempt_enable();

printk("\n");
show_trace_log_lvl(task, regs, sp, bp, log_lvl);
}
Expand Down Expand Up @@ -303,4 +310,3 @@ int is_valid_bugaddr(unsigned long ip)

return ud2 == 0x0b0f;
}

2 changes: 1 addition & 1 deletion arch/x86/kernel/process_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void __show_regs(struct pt_regs *regs, int all)

void show_regs(struct pt_regs *regs)
{
__show_regs(regs, 1);
show_registers(regs);
show_trace(NULL, regs, &regs->sp, regs->bp);
}

Expand Down
3 changes: 1 addition & 2 deletions arch/x86/kernel/process_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ void __show_regs(struct pt_regs *regs, int all)

void show_regs(struct pt_regs *regs)
{
printk(KERN_INFO "CPU %d:", smp_processor_id());
__show_regs(regs, 1);
show_registers(regs);
show_trace(NULL, regs, (void *)(regs + 1), regs->bp);
}

Expand Down
13 changes: 7 additions & 6 deletions arch/x86/kernel/tsc_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,12 @@ void __cpuinit check_tsc_sync_source(int cpu)
return;

if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE)) {
printk_once(KERN_INFO "Skipping synchronization checks as TSC is reliable.\n");
if (cpu == (nr_cpu_ids-1) || system_state != SYSTEM_BOOTING)
pr_info(
"Skipped synchronization checks as TSC is reliable.\n");
return;
}

pr_info("checking TSC synchronization [CPU#%d -> CPU#%d]:",
smp_processor_id(), cpu);

/*
* Reset it - in case this is a second bootup:
*/
Expand All @@ -142,12 +141,14 @@ void __cpuinit check_tsc_sync_source(int cpu)
cpu_relax();

if (nr_warps) {
printk("\n");
pr_warning("TSC synchronization [CPU#%d -> CPU#%d]:\n",
smp_processor_id(), cpu);
pr_warning("Measured %Ld cycles TSC warp between CPUs, "
"turning off TSC clock.\n", max_warp);
mark_tsc_unstable("check_tsc_sync_source failed");
} else {
printk(" passed.\n");
pr_debug("TSC synchronization [CPU#%d -> CPU#%d]: passed\n",
smp_processor_id(), cpu);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ no_context(struct pt_regs *regs, unsigned long error_code,
show_fault_oops(regs, error_code, address);

stackend = end_of_stack(tsk);
if (*stackend != STACK_END_MAGIC)
if (tsk != &init_task && *stackend != STACK_END_MAGIC)
printk(KERN_ALERT "Thread overran stack, or stack corrupted\n");

tsk->thread.cr2 = address;
Expand Down

0 comments on commit 6ec22f9

Please sign in to comment.