x86_64: Avoid too many remote cpu references due to /proc/stat

2007-07-21 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c3508f8f341f19f6b1c3f854f144540427668151
Commit: c3508f8f341f19f6b1c3f854f144540427668151
Parent: 2618f86e0010fc6703e77af3613bac7ade46efc6
Author: Ravikiran G Thirumalai [EMAIL PROTECTED]
AuthorDate: Sat Jul 21 17:10:19 2007 +0200
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Sat Jul 21 18:37:09 2007 -0700

x86_64: Avoid too many remote cpu references due to /proc/stat

Too many remote cpu references due to /proc/stat.

On x86_64, with newer kernel versions, kstat_irqs is a bit of a problem.
On every call to kstat_irqs, the process brings in per-cpu data from all
online cpus.  Doing this for NR_IRQS, which is now 256 + 32 * NR_CPUS
results in (256+32*63) * 63 remote cpu references on a 64 cpu config.
/proc/stat is parsed by common commands like top, who etc, causing lots
of cacheline transfers

This statistic seems useless.  Other 'big iron' arches disable this.

AK: changed to remove for all SMP setups
AK: add comment

Signed-off-by: Ravikiran Thirumalai [EMAIL PROTECTED]
Signed-off-by: Andi Kleen [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 fs/proc/proc_misc.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index f133afe..bee251c 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -507,7 +507,8 @@ static int show_stat(struct seq_file *p, void *v)
}
seq_printf(p, intr %llu, (unsigned long long)sum);
 
-#if !defined(CONFIG_PPC64)  !defined(CONFIG_ALPHA)  !defined(CONFIG_IA64)
+#ifndef CONFIG_SMP
+   /* Touches too many cache lines on SMP setups */
for (i = 0; i  NR_IRQS; i++)
seq_printf(p,  %u, per_irq_sum[i]);
 #endif
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Avoid too many remote cpu references due to /proc/stat

2007-07-19 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4004c69ad68dd03733179277280ea2946990ba36
Commit: 4004c69ad68dd03733179277280ea2946990ba36
Parent: a0a9983509f45b2225ca87fdcf7b40ea916834ed
Author: Ravikiran G Thirumalai [EMAIL PROTECTED]
AuthorDate: Thu Jul 19 01:47:53 2007 -0700
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Thu Jul 19 10:04:43 2007 -0700

Avoid too many remote cpu references due to /proc/stat

Optimize show_stat to collect per-irq information just once.

On x86_64, with newer kernel versions, kstat_irqs is a bit of a problem.
On every call to kstat_irqs, the process brings in per-cpu data from all
online cpus.  Doing this for NR_IRQS, which is now 256 + 32 * NR_CPUS
results in (256+32*63) * 63 remote cpu references on a 64 cpu config.
Considering the fact that we already compute this value per-cpu, we can
save on the remote references as below.

Signed-off-by: Alok N Kataria [EMAIL PROTECTED]
Signed-off-by: Ravikiran Thirumalai [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 fs/proc/proc_misc.c |   15 ---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index d24b8d4..f133afe 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -445,6 +445,11 @@ static int show_stat(struct seq_file *p, void *v)
cputime64_t user, nice, system, idle, iowait, irq, softirq, steal;
u64 sum = 0;
struct timespec boottime;
+   unsigned int *per_irq_sum;
+
+   per_irq_sum = kzalloc(sizeof(unsigned int)*NR_IRQS, GFP_KERNEL);
+   if (!per_irq_sum)
+   return -ENOMEM;
 
user = nice = system = idle = iowait =
irq = softirq = steal = cputime64_zero;
@@ -462,8 +467,11 @@ static int show_stat(struct seq_file *p, void *v)
irq = cputime64_add(irq, kstat_cpu(i).cpustat.irq);
softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq);
steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal);
-   for (j = 0 ; j  NR_IRQS ; j++)
-   sum += kstat_cpu(i).irqs[j];
+   for (j = 0; j  NR_IRQS; j++) {
+   unsigned int temp = kstat_cpu(i).irqs[j];
+   sum += temp;
+   per_irq_sum[j] += temp;
+   }
}
 
seq_printf(p, cpu  %llu %llu %llu %llu %llu %llu %llu %llu\n,
@@ -501,7 +509,7 @@ static int show_stat(struct seq_file *p, void *v)
 
 #if !defined(CONFIG_PPC64)  !defined(CONFIG_ALPHA)  !defined(CONFIG_IA64)
for (i = 0; i  NR_IRQS; i++)
-   seq_printf(p,  %u, kstat_irqs(i));
+   seq_printf(p,  %u, per_irq_sum[i]);
 #endif
 
seq_printf(p,
@@ -516,6 +524,7 @@ static int show_stat(struct seq_file *p, void *v)
nr_running(),
nr_iowait());
 
+   kfree(per_irq_sum);
return 0;
 }
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html