Commit b993be7e authored by Rusty Russell's avatar Rusty Russell Committed by Steve French

[PATCH] Make kstat_this_cpu in terms of __get_cpu_var and use it

kstat_this_cpu() is defined in terms of per_cpu instead of __get_cpu_var.

This patch changes that, and uses it everywhere appropriate.  The sched.c
change puts it in a local variable, which helps gcc generate better code.
parent 163feb58
...@@ -416,7 +416,6 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs) ...@@ -416,7 +416,6 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs)
* handled by some other CPU. (or is disabled) * handled by some other CPU. (or is disabled)
*/ */
int irq = regs.orig_eax & 0xff; /* high bits used in ret_from_ code */ int irq = regs.orig_eax & 0xff; /* high bits used in ret_from_ code */
int cpu = smp_processor_id();
irq_desc_t *desc = irq_desc + irq; irq_desc_t *desc = irq_desc + irq;
struct irqaction * action; struct irqaction * action;
unsigned int status; unsigned int status;
...@@ -437,7 +436,7 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs) ...@@ -437,7 +436,7 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs)
} }
} }
#endif #endif
kstat_cpu(cpu).irqs[irq]++; kstat_this_cpu.irqs[irq]++;
spin_lock(&desc->lock); spin_lock(&desc->lock);
desc->handler->ack(irq); desc->handler->ack(irq);
/* /*
......
...@@ -31,7 +31,8 @@ struct kernel_stat { ...@@ -31,7 +31,8 @@ struct kernel_stat {
DECLARE_PER_CPU(struct kernel_stat, kstat); DECLARE_PER_CPU(struct kernel_stat, kstat);
#define kstat_cpu(cpu) per_cpu(kstat, cpu) #define kstat_cpu(cpu) per_cpu(kstat, cpu)
#define kstat_this_cpu kstat_cpu(smp_processor_id()) /* Must have preemption disabled for this to be meaningful. */
#define kstat_this_cpu __get_cpu_var(kstat)
extern unsigned long nr_context_switches(void); extern unsigned long nr_context_switches(void);
......
...@@ -1175,6 +1175,7 @@ DEFINE_PER_CPU(struct kernel_stat, kstat) = { { 0 } }; ...@@ -1175,6 +1175,7 @@ DEFINE_PER_CPU(struct kernel_stat, kstat) = { { 0 } };
void scheduler_tick(int user_ticks, int sys_ticks) void scheduler_tick(int user_ticks, int sys_ticks)
{ {
int cpu = smp_processor_id(); int cpu = smp_processor_id();
struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
runqueue_t *rq = this_rq(); runqueue_t *rq = this_rq();
task_t *p = current; task_t *p = current;
...@@ -1184,19 +1185,19 @@ void scheduler_tick(int user_ticks, int sys_ticks) ...@@ -1184,19 +1185,19 @@ void scheduler_tick(int user_ticks, int sys_ticks)
if (p == rq->idle) { if (p == rq->idle) {
/* note: this timer irq context must be accounted for as well */ /* note: this timer irq context must be accounted for as well */
if (irq_count() - HARDIRQ_OFFSET >= SOFTIRQ_OFFSET) if (irq_count() - HARDIRQ_OFFSET >= SOFTIRQ_OFFSET)
kstat_cpu(cpu).cpustat.system += sys_ticks; cpustat->system += sys_ticks;
else if (atomic_read(&rq->nr_iowait) > 0) else if (atomic_read(&rq->nr_iowait) > 0)
kstat_cpu(cpu).cpustat.iowait += sys_ticks; cpustat->iowait += sys_ticks;
else else
kstat_cpu(cpu).cpustat.idle += sys_ticks; cpustat->idle += sys_ticks;
rebalance_tick(rq, 1); rebalance_tick(rq, 1);
return; return;
} }
if (TASK_NICE(p) > 0) if (TASK_NICE(p) > 0)
kstat_cpu(cpu).cpustat.nice += user_ticks; cpustat->nice += user_ticks;
else else
kstat_cpu(cpu).cpustat.user += user_ticks; cpustat->user += user_ticks;
kstat_cpu(cpu).cpustat.system += sys_ticks; cpustat->system += sys_ticks;
/* Task might have expired already, but not scheduled off yet */ /* Task might have expired already, but not scheduled off yet */
if (p->array != rq->active) { if (p->array != rq->active) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment