Patch: cpu utilization monitor.

ahuja at austin.ibm.com ahuja at austin.ibm.com
Wed Mar 17 10:38:06 EST 2004



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.1507 
#	arch/ppc64/kernel/smp.c	1.68    -> 1.69   
#	arch/ppc64/kernel/Makefile	1.40    -> 1.41   
#	               (new)	        -> 1.1     arch/ppc64/kernel/profile.h
#	               (new)	        -> 1.1     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
# --------------------------------------------
#
diff -Nru a/arch/ppc64/kernel/Makefile b/arch/ppc64/kernel/Makefile
--- a/arch/ppc64/kernel/Makefile	Tue Mar 16 16:46:34 2004
+++ b/arch/ppc64/kernel/Makefile	Tue Mar 16 16:46:34 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	Tue Mar 16 16:46:34 2004
@@ -0,0 +1,81 @@
+/*
+ * 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->my_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->my_timer;
+
+	if (tl->function == NULL) {
+		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);
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	Tue Mar 16 16:46:34 2004
@@ -0,0 +1,27 @@
+/*
+ *    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 my_timer;
+        unsigned long long start_purr;
+        unsigned long long current_purr;
+        unsigned long long tb;
+};
+
diff -Nru a/arch/ppc64/kernel/smp.c b/arch/ppc64/kernel/smp.c
--- a/arch/ppc64/kernel/smp.c	Tue Mar 16 16:46:34 2004
+++ b/arch/ppc64/kernel/smp.c	Tue Mar 16 16:46:34 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>
@@ -967,6 +968,7 @@
 int __devinit __cpu_up(unsigned int cpu)
 {
 	int c;
+	struct cpu_util_store * cus = &per_cpu(cpu_util_sampler, cpu);
 
 	/* At boot, don't bother with non-present cpus -JSCHOPP */
 	if (!system_running && !cpu_present_at_boot(cpu))
@@ -1001,6 +1003,12 @@
 
 	/* wake up cpus */
 	smp_ops->kick_cpu(cpu);
+
+	/* Collect starting purr */
+	if (PVR_VER(systemcfg->processor) == PV_POWER5) {
+		cus->start_purr = mfspr(PURR);
+		cus->tb = mftb();
+	}
 
 	/*
 	 * wait to see if the cpu made a callin (is actually up).


More information about the Linuxppc64-dev mailing list