cpu utilization monitor.

ahuja at austin.ibm.com ahuja at austin.ibm.com
Thu Mar 18 11:01:22 EST 2004


I made some of the changes requested...

Will try and incorporate other requests in future versions of this file.

Cheers,
Manish


On Tue, 16 Mar 2004 ahuja at forte.austin.ibm.com wrote:

>
>
> This patch adds the framework required by performace team and on demand
> computing. At this point only the important bits/framework are covered.
>
> All the kobjects/calculations are yet to be written.
>
> We are still contiunuing to disscuss methods for performace monitoring.
>
> Purr is a vcpu performance counter. This collects purr/tb
> periodically to be used later in computations from any given
> cpu without needing to acquire a cpu exclusively.
>
> Thanks,
> Manish
>
> p.s My first patch, so go easy guys...
>
-------------- next part --------------
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.1506  -> 1.1508 
#	arch/ppc64/kernel/smp.c	1.68    -> 1.70   
#	arch/ppc64/kernel/Makefile	1.40    -> 1.41   
#	               (new)	        -> 1.2     arch/ppc64/kernel/profile.h
#	               (new)	        -> 1.2     arch/ppc64/kernel/profile.c
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/03/16	ahuja at threadlp13.austin.ibm.com	1.1507
# Added new functionality for performance monitoring mahuja at us.ibm.com
# --------------------------------------------
# 04/03/17	ahuja at threadlp13.austin.ibm.com	1.1508
# smp.c:
#   Made it a function and invoking that only...
# profile.h:
#   Changed my timer & made unbsigned long long to u64
# profile.c:
#   Removed all refs to my_timer
# --------------------------------------------
#
diff -Nru a/arch/ppc64/kernel/Makefile b/arch/ppc64/kernel/Makefile
--- a/arch/ppc64/kernel/Makefile	Wed Mar 17 17:49:43 2004
+++ b/arch/ppc64/kernel/Makefile	Wed Mar 17 17:49:43 2004
@@ -43,7 +43,7 @@
 obj-$(CONFIG_PPC_RTAS)		+= rtas-proc.o
 obj-$(CONFIG_SCANLOG)		+= scanlog.o
 obj-$(CONFIG_VIOPATH)		+= viopath.o
-obj-$(CONFIG_LPARCFG)		+= lparcfg.o
+obj-$(CONFIG_LPARCFG)		+= lparcfg.o profile.o
 obj-$(CONFIG_HVC_CONSOLE)	+= hvconsole.o
 obj-$(CONFIG_BOOTX_TEXT)	+= btext.o
 
diff -Nru a/arch/ppc64/kernel/profile.c b/arch/ppc64/kernel/profile.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/arch/ppc64/kernel/profile.c	Wed Mar 17 17:49:43 2004
@@ -0,0 +1,95 @@
+/*
+ * PPC64 Cpu util performace monitoring.
+ *
+ * Manish Ahuja mahuja at us.ibm.com
+ *    Copyright (c) 2004 Manish Ahuja IBM CORP.
+ *
+ *      This program is free software; you can redistribute it and/or
+ *      modify it under the terms of the GNU General Public License
+ *      as published by the Free Software Foundation; either version
+ *      2 of the License, or (at your option) any later version.
+ *
+ *	This file will also report many of the perf values for 2.6 
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <asm/hvcall.h>
+#include <asm/cputable.h>
+#include "profile.h"
+
+#define SAMPLE_TICK HZ
+
+DEFINE_PER_CPU(struct cpu_util_store, cpu_util_sampler);
+
+/*
+ * This is a timer handler.  There is on per CPU. It gets scheduled
+ * every SAMPLE_TICK ticks.
+ */
+
+static void util_timer_func(unsigned long data)
+{
+	struct cpu_util_store * cus = &__get_cpu_var(cpu_util_sampler);
+	struct timer_list *tl = &cus->cpu_util_timer;
+
+	if (PVR_VER(systemcfg->processor) == PV_POWER5) {
+		cus->current_purr = mfspr(PURR);
+		cus->tb = mftb();
+        }
+	/*printk(KERN_INFO "PURR VAL %ld %lld %lld\n", data, cus->current_purr, cus->tb);*/
+
+	mod_timer(tl, jiffies + SAMPLE_TICK);
+}
+
+/*
+ * One time function that gets called when all the cpu's are online 
+ * to start collection. It adds the timer to each cpu on the system.
+ * start_purr is collected during smp_init time in __cpu_up code
+ */
+
+static void start_util_timer(int cpu)
+{
+	struct cpu_util_store * cus = &per_cpu(cpu_util_sampler, cpu);
+	struct timer_list *tl = &cus->cpu_util_timer;
+
+	if (tl->function != NULL)
+		return;
+
+	init_timer(tl);
+	tl->expires = jiffies + SAMPLE_TICK;
+	tl->data = cpu;
+	tl->function = util_timer_func;
+	add_timer_on(tl, cpu);
+}
+
+int __init cpu_util_init(void)
+{
+	int cpu;
+
+	for (cpu = 0; cpu < NR_CPUS; cpu++) {
+		if (cpu_online(cpu))
+			start_util_timer(cpu);
+	}
+
+	return 0;
+}
+
+__initcall(cpu_util_init);
+
+/* Collect starting purr */
+
+void collect_startpurr(int cpu)
+{
+	struct cpu_util_store * cus = &per_cpu(cpu_util_sampler, cpu);	
+
+	if (PVR_VER(systemcfg->processor) == PV_POWER5) {
+		cus->start_purr = mfspr(PURR);
+		cus->tb = mftb();
+	}
+}
+
diff -Nru a/arch/ppc64/kernel/profile.h b/arch/ppc64/kernel/profile.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/arch/ppc64/kernel/profile.h	Wed Mar 17 17:49:43 2004
@@ -0,0 +1,28 @@
+/*
+ *    Copyright (c) 2004 Manish Ahuja <mahuja at us.ibm.com>
+ *
+ *    Module name: profile.h
+ *
+ *    Description:
+ *      Architecture- / platform-specific boot-time initialization code for
+ *      tracking purr utilization and other performace features in coming 
+ * 	releases for splpar/smt machines.
+ *
+ *      This program is free software; you can redistribute it and/or
+ *      modify it under the terms of the GNU General Public License
+ *      as published by the Free Software Foundation; either version
+ *      2 of the License, or (at your option) any later version.
+ */
+
+#define PURR 309
+
+DECLARE_PER_CPU(struct cpu_util_store, cpu_util_sampler);
+
+struct cpu_util_store {
+        struct timer_list cpu_util_timer;
+        u64 start_purr;
+        u64 current_purr;
+        u64 tb;
+};
+
+void collect_startpurr(int cpu);
diff -Nru a/arch/ppc64/kernel/smp.c b/arch/ppc64/kernel/smp.c
--- a/arch/ppc64/kernel/smp.c	Wed Mar 17 17:49:43 2004
+++ b/arch/ppc64/kernel/smp.c	Wed Mar 17 17:49:43 2004
@@ -52,6 +52,7 @@
 #include <asm/xics.h>
 #include <asm/cputable.h>
 #include <asm/system.h>
+#include "profile.h"
 
 #ifdef CONFIG_KDB
 #include <linux/kdb.h>
@@ -1001,6 +1002,9 @@
 
 	/* wake up cpus */
 	smp_ops->kick_cpu(cpu);
+
+	/* Collect starting purr */
+	collect_startpurr(cpu);
 
 	/*
 	 * wait to see if the cpu made a callin (is actually up).


More information about the Linuxppc64-dev mailing list