[PATCH 4/4] tickless idle cpus: decrementer statistics - NOT MEANT FOR INCLUSION

Srivatsa Vaddagiri vatsa at in.ibm.com
Fri Apr 7 16:32:56 EST 2006


This patch (a hack) provides some statistics of decrementer exception on
each CPU. I used this purely to verify that tickless feature is working.

Anton, would this be useful statistics to be exposed (maybe in
/proc/interrupts)? If so, I could work out a more cleaner way of
providing this statistics to user.

Signed-off-by: Srivatsa Vaddagiri <vatsa at in.ibm.com>

---

 linux-2.6.17-rc1-root/arch/powerpc/kernel/time.c |    4 ++++
 linux-2.6.17-rc1-root/fs/proc/proc_misc.c        |   17 +++++++++++++++++
 2 files changed, 21 insertions(+)

diff -puN arch/powerpc/kernel/time.c~stat arch/powerpc/kernel/time.c
--- linux-2.6.17-rc1/arch/powerpc/kernel/time.c~stat	2006-04-07 11:29:20.000000000 +0530
+++ linux-2.6.17-rc1-root/arch/powerpc/kernel/time.c	2006-04-07 11:29:20.000000000 +0530
@@ -757,6 +757,8 @@ void start_hz_timer(struct pt_regs *regs
 static inline int clear_hzless_mask(void) { return 0;}
 #endif
 
+DEFINE_PER_CPU(int, dec_ticks);
+
 /*
  * For iSeries shared processors, we have to let the hypervisor
  * set the hardware decrementer.  We set a virtual decrementer
@@ -780,6 +782,8 @@ void timer_interrupt(struct pt_regs * re
 
 	irq_enter();
 
+	__get_cpu_var(dec_ticks) += 1;
+
 	clear_hzless_mask();
 
 	profile_tick(CPU_PROFILING, regs);
diff -puN fs/proc/proc_misc.c~stat fs/proc/proc_misc.c
--- linux-2.6.17-rc1/fs/proc/proc_misc.c~stat	2006-04-07 11:29:20.000000000 +0530
+++ linux-2.6.17-rc1-root/fs/proc/proc_misc.c	2006-04-07 11:29:20.000000000 +0530
@@ -243,6 +243,22 @@ static int version_read_proc(char *page,
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
+DECLARE_PER_CPU(int, dec_ticks);
+
+static int decrementer_read_proc(char *page, char **start, off_t off,
+				 int count, int *eof, void *data)
+{
+	int len, cpu;
+	char *cp = page;
+
+	for_each_cpu(cpu)
+		cp += sprintf (cp, "%d ", per_cpu(dec_ticks, cpu));
+
+	len = cp - page;
+
+	return proc_calc_metrics(page, start, off, count, eof, len);
+}
+
 extern struct seq_operations cpuinfo_op;
 static int cpuinfo_open(struct inode *inode, struct file *file)
 {
@@ -740,6 +756,7 @@ void __init proc_misc_init(void)
 		{"uptime",	uptime_read_proc},
 		{"meminfo",	meminfo_read_proc},
 		{"version",	version_read_proc},
+		{"decrementer",	decrementer_read_proc},
 #ifdef CONFIG_PROC_HARDWARE
 		{"hardware",	hardware_read_proc},
 #endif

_

-- 
Regards,
vatsa



More information about the Linuxppc-dev mailing list