Skip to content

Commit

Permalink
[PATCH] x86_64: Node local pda take 2 -- cpu_pda preparation
Browse files Browse the repository at this point in the history
Helper patch to change cpu_pda users to use macros to access cpu_pda
instead of the cpu_pda[] array.

Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Signed-off-by: Shai Fultheim <shai@scalex86.org>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Ravikiran G Thirumalai authored and Linus Torvalds committed Jan 12, 2006
1 parent 05b3cbd commit df79efd
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions arch/x86_64/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ int show_interrupts(struct seq_file *p, void *v)
seq_printf(p, "NMI: ");
for (j = 0; j < NR_CPUS; j++)
if (cpu_online(j))
seq_printf(p, "%10u ", cpu_pda[j].__nmi_count);
seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
seq_putc(p, '\n');
#ifdef CONFIG_X86_LOCAL_APIC
seq_printf(p, "LOC: ");
for (j = 0; j < NR_CPUS; j++)
if (cpu_online(j))
seq_printf(p, "%10u ", cpu_pda[j].apic_timer_irqs);
seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
seq_putc(p, '\n');
#endif
seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
Expand Down
6 changes: 3 additions & 3 deletions arch/x86_64/kernel/nmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,19 @@ int __init check_nmi_watchdog (void)
smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0);

for (cpu = 0; cpu < NR_CPUS; cpu++)
counts[cpu] = cpu_pda[cpu].__nmi_count;
counts[cpu] = cpu_pda(cpu)->__nmi_count;
local_irq_enable();
mdelay((10*1000)/nmi_hz); // wait 10 ticks

for (cpu = 0; cpu < NR_CPUS; cpu++) {
if (!cpu_online(cpu))
continue;
if (cpu_pda[cpu].__nmi_count - counts[cpu] <= 5) {
if (cpu_pda(cpu)->__nmi_count - counts[cpu] <= 5) {
endflag = 1;
printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n",
cpu,
counts[cpu],
cpu_pda[cpu].__nmi_count);
cpu_pda(cpu)->__nmi_count);
nmi_active = 0;
lapic_nmi_owner &= ~LAPIC_NMI_WATCHDOG;
nmi_perfctr_msr = 0;
Expand Down
8 changes: 4 additions & 4 deletions arch/x86_64/kernel/setup64.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ char x86_boot_params[BOOT_PARAM_SIZE] __initdata = {0,};

cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;

struct x8664_pda cpu_pda[NR_CPUS] __cacheline_aligned;
struct x8664_pda _cpu_pda[NR_CPUS] __cacheline_aligned;

struct desc_ptr idt_descr = { 256 * 16, (unsigned long) idt_table };

Expand Down Expand Up @@ -110,18 +110,18 @@ void __init setup_per_cpu_areas(void)
}
if (!ptr)
panic("Cannot allocate cpu data for CPU %d\n", i);
cpu_pda[i].data_offset = ptr - __per_cpu_start;
cpu_pda(i)->data_offset = ptr - __per_cpu_start;
memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
}
}

void pda_init(int cpu)
{
struct x8664_pda *pda = &cpu_pda[cpu];
struct x8664_pda *pda = cpu_pda(cpu);

/* Setup up data that may be needed in __get_free_pages early */
asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0));
wrmsrl(MSR_GS_BASE, cpu_pda + cpu);
wrmsrl(MSR_GS_BASE, pda);

pda->cpunumber = cpu;
pda->irqcount = -1;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/kernel/smpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)

do_rest:

cpu_pda[cpu].pcurrent = c_idle.idle;
cpu_pda(cpu)->pcurrent = c_idle.idle;

start_rip = setup_trampoline();

Expand Down
11 changes: 5 additions & 6 deletions arch/x86_64/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ asmlinkage void reserved(void);
asmlinkage void alignment_check(void);
asmlinkage void machine_check(void);
asmlinkage void spurious_interrupt_bug(void);
asmlinkage void call_debug(void);

struct notifier_block *die_chain;
static DEFINE_SPINLOCK(die_notifier_lock);
Expand Down Expand Up @@ -139,7 +138,7 @@ static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
switch (k + 1) {
#if DEBUG_STKSZ > EXCEPTION_STKSZ
case DEBUG_STACK:
end = cpu_pda[cpu].debugstack + DEBUG_STKSZ;
end = cpu_pda(cpu)->debugstack + DEBUG_STKSZ;
break;
#endif
default:
Expand Down Expand Up @@ -186,7 +185,7 @@ void show_trace(unsigned long *stack)
{
unsigned long addr;
const unsigned cpu = safe_smp_processor_id();
unsigned long *irqstack_end = (unsigned long *)cpu_pda[cpu].irqstackptr;
unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr;
int i;
unsigned used = 0;

Expand Down Expand Up @@ -254,8 +253,8 @@ void show_stack(struct task_struct *tsk, unsigned long * rsp)
unsigned long *stack;
int i;
const int cpu = safe_smp_processor_id();
unsigned long *irqstack_end = (unsigned long *) (cpu_pda[cpu].irqstackptr);
unsigned long *irqstack = (unsigned long *) (cpu_pda[cpu].irqstackptr - IRQSTACKSIZE);
unsigned long *irqstack_end = (unsigned long *) (cpu_pda(cpu)->irqstackptr);
unsigned long *irqstack = (unsigned long *) (cpu_pda(cpu)->irqstackptr - IRQSTACKSIZE);

// debugging aid: "show_stack(NULL, NULL);" prints the
// back trace for this cpu.
Expand Down Expand Up @@ -303,7 +302,7 @@ void show_registers(struct pt_regs *regs)
int in_kernel = !user_mode(regs);
unsigned long rsp;
const int cpu = safe_smp_processor_id();
struct task_struct *cur = cpu_pda[cpu].pcurrent;
struct task_struct *cur = cpu_pda(cpu)->pcurrent;

rsp = regs->rsp;

Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/kernel/x8664_ksyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ EXPORT_SYMBOL(pci_mem_start);
EXPORT_SYMBOL(copy_page);
EXPORT_SYMBOL(clear_page);

EXPORT_SYMBOL(cpu_pda);
EXPORT_SYMBOL(_cpu_pda);
#ifdef CONFIG_SMP
EXPORT_SYMBOL(cpu_data);
EXPORT_SYMBOL(__write_lock_failed);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/mm/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ __cpuinit void numa_add_cpu(int cpu)

void __cpuinit numa_set_node(int cpu, int node)
{
cpu_pda[cpu].nodenumber = node;
cpu_pda(cpu)->nodenumber = node;
cpu_to_node[cpu] = node;
}

Expand Down
4 changes: 3 additions & 1 deletion include/asm-x86_64/pda.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ struct x8664_pda {
unsigned apic_timer_irqs;
} ____cacheline_aligned_in_smp;

extern struct x8664_pda cpu_pda[];
extern struct x8664_pda _cpu_pda[];

#define cpu_pda(i) (&_cpu_pda[i])

/*
* There is no fast way to get the base address of the PDA, all the accesses
Expand Down
2 changes: 1 addition & 1 deletion include/asm-x86_64/percpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <asm/pda.h>

#define __per_cpu_offset(cpu) (cpu_pda[cpu].data_offset)
#define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset)
#define __my_cpu_offset() read_pda(data_offset)

/* Separate out the type, so (int[3], foo) works. */
Expand Down

0 comments on commit df79efd

Please sign in to comment.