Re: [PATCH] Per cpu irq stat

2005-03-15 Thread Christoph Lameter
On Tue, 15 Mar 2005, Christoph Hellwig wrote:

> On Mon, Mar 14, 2005 at 10:32:34PM -0800, Christoph Lameter wrote:
> > The definition of the irq_stat as an array means that the individual
> > elements of the irq_stat array are located on one NUMA node requiring
> > internode traffic to access irq_stat from other nodes. This patch makes
> > irq_stat a per_cpu variable which allows most accesses to be local.
>
> There's architectures accessing it from assemly.

The patch is i386 specific!

> But furthermore there's absolutely not point for the irq_stat structure
> at all anymore now that we have the per_cpu infrastructure.  so kill it
> completely and let every architecture just provide a local_softirq_pending
> macro.

That would require reworking a lot of architectures.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Per cpu irq stat

2005-03-15 Thread Christoph Hellwig
On Mon, Mar 14, 2005 at 10:32:34PM -0800, Christoph Lameter wrote:
> The definition of the irq_stat as an array means that the individual
> elements of the irq_stat array are located on one NUMA node requiring
> internode traffic to access irq_stat from other nodes. This patch makes
> irq_stat a per_cpu variable which allows most accesses to be local.

There's architectures accessing it from assemly.

But furthermore there's absolutely not point for the irq_stat structure
at all anymore now that we have the per_cpu infrastructure.  so kill it
completely and let every architecture just provide a local_softirq_pending
macro.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Per cpu irq stat

2005-03-14 Thread Christoph Lameter
On Mon, 14 Mar 2005, Andrew Morton wrote:

> >  +DEFINE_PER_CPU(irq_cpustat_t, irq_stat)
> >  cacheline_maxaligned_in_smp;
>
> Why is this marked cacheline_maxaligned_in_smp?

In order to avoid potential false aliasing I guess. irq_cpustat_t is
already marked ___cacheline_aligned though which should be sufficient.
Shai?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Per cpu irq stat

2005-03-14 Thread Andrew Morton
Christoph Lameter <[EMAIL PROTECTED]> wrote:
>
> The definition of the irq_stat as an array means that the individual
>  elements of the irq_stat array are located on one NUMA node requiring
>  internode traffic to access irq_stat from other nodes. This patch makes
>  irq_stat a per_cpu variable which allows most accesses to be local.

OK...

The wordwrapping monster got at your patch, but I fixed it up.

>  +DEFINE_PER_CPU(irq_cpustat_t, irq_stat)
>  cacheline_maxaligned_in_smp;

Why is this marked cacheline_maxaligned_in_smp?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Per cpu irq stat

2005-03-14 Thread Christoph Lameter
The definition of the irq_stat as an array means that the individual
elements of the irq_stat array are located on one NUMA node requiring
internode traffic to access irq_stat from other nodes. This patch makes
irq_stat a per_cpu variable which allows most accesses to be local.

Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]>
Signed-off-by: Shai Fultheim <[EMAIL PROTECTED]>

Index: linux-2.6.11/arch/i386/kernel/apic.c
===
--- linux-2.6.11.orig/arch/i386/kernel/apic.c   2005-03-01
23:38:33.0 -0800
+++ linux-2.6.11/arch/i386/kernel/apic.c2005-03-08
15:01:43.0 -0800
@@ -1165,7 +1165,7 @@ fastcall void smp_apic_timer_interrupt(s
/*
 * the NMI deadlock-detector uses this.
 */
-   irq_stat[cpu].apic_timer_irqs++;
+   per_cpu(irq_stat, cpu).apic_timer_irqs++;

/*
 * NOTE! We'd better ACK the irq immediately,
Index: linux-2.6.11/arch/i386/kernel/io_apic.c
===
--- linux-2.6.11.orig/arch/i386/kernel/io_apic.c2005-03-01
23:37:54.0 -0800
+++ linux-2.6.11/arch/i386/kernel/io_apic.c 2005-03-08
16:56:24.923078776 -0800
@@ -275,7 +275,7 @@ struct irq_cpu_info {
 #define IRQ_DELTA(cpu,irq) (irq_cpu_data[cpu].irq_delta[irq])

 #define IDLE_ENOUGH(cpu,now) \
-   (idle_cpu(cpu) && ((now) -
irq_stat[(cpu)].idle_timestamp > 1))
+   (idle_cpu(cpu) && ((now) - per_cpu(irq_stat,
(cpu)).idle_timestamp > 1))

 #define IRQ_ALLOWED(cpu, allowed_mask) cpu_isset(cpu, allowed_mask)

Index: linux-2.6.11/arch/i386/kernel/irq.c
===
--- linux-2.6.11.orig/arch/i386/kernel/irq.c2005-03-01
23:37:48.0 -0800
+++ linux-2.6.11/arch/i386/kernel/irq.c 2005-03-08 17:57:13.623392016
-0800
@@ -16,6 +16,9 @@
 #include 
 #include 

+DEFINE_PER_CPU(irq_cpustat_t, irq_stat)
cacheline_maxaligned_in_smp;
+EXPORT_PER_CPU_SYMBOL(irq_stat);
+
 #ifndef CONFIG_X86_LOCAL_APIC
 /*
  * 'what should we do if we get a hw irq event on an illegal vector'.
@@ -246,7 +249,7 @@ skip:
for (j = 0; j < NR_CPUS; j++)
if (cpu_online(j))
seq_printf(p, "%10u ",
-   irq_stat[j].apic_timer_irqs);
+
per_cpu(irq_stat,j).apic_timer_irqs);
seq_putc(p, '\n');
 #endif
seq_printf(p, "ERR: %10u\n",
atomic_read(&irq_err_count));
Index: linux-2.6.11/arch/i386/kernel/nmi.c
===
--- linux-2.6.11.orig/arch/i386/kernel/nmi.c2005-03-01
23:38:10.0 -0800
+++ linux-2.6.11/arch/i386/kernel/nmi.c 2005-03-08 15:01:43.0
-0800
@@ -110,7 +110,7 @@ int __init check_nmi_watchdog (void)
printk(KERN_INFO "testing NMI watchdog ... ");

for (cpu = 0; cpu < NR_CPUS; cpu++)
-   prev_nmi_count[cpu] = irq_stat[cpu].__nmi_count;
+   prev_nmi_count[cpu] = per_cpu(irq_stat,
cpu).__nmi_count;
local_irq_enable();
mdelay((10*1000)/nmi_hz); // wait 10 ticks

@@ -483,7 +483,7 @@ void nmi_watchdog_tick (struct pt_regs *
 */
int sum, cpu = smp_processor_id();

-   sum = irq_stat[cpu].apic_timer_irqs;
+   sum = per_cpu(irq_stat, cpu).apic_timer_irqs;

if (last_irq_sums[cpu] == sum) {
/*
Index: linux-2.6.11/arch/i386/kernel/process.c
===
--- linux-2.6.11.orig/arch/i386/kernel/process.c2005-03-08
15:01:42.0 -0800
+++ linux-2.6.11/arch/i386/kernel/process.c 2005-03-08
18:06:03.695808760 -0800
@@ -161,7 +161,7 @@ void cpu_idle (void)
if (!idle)
idle = default_idle;

-   irq_stat[cpu].idle_timestamp = jiffies;
+   __get_cpu_var(irq_stat).idle_timestamp =
jiffies;
idle();
}
schedule();
Index: linux-2.6.11/include/asm-i386/hardirq.h
===
--- linux-2.6.11.orig/include/asm-i386/hardirq.h2005-03-01
23:38:17.0 -0800
+++ linux-2.6.11/include/asm-i386/hardirq.h 2005-03-08
18:10:52.545896872 -0800
@@ -12,8 +12,13 @@ typedef struct {
unsigned int apic_timer_irqs;   /* arch dependent */
 } cacheline_aligned irq_cpustat_t;

-#include  /* Standard mappings for irq_cpustat_t
above */
+DECLARE_PER_CPU(irq_cpustat_t, irq_stat);
+extern irq_cpustat_t irq_stat[];
+
+#define __ARCH_IRQ_STAT
+#define __IRQ_STAT(cpu, member) (per_cpu(irq_stat, cpu).member)

 void ack_bad_irq(unsigned int irq);
+#include 

 #endif /* __ASM_HARDIRQ_H */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http