WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [PATCH 3/7 TAKE 2] xenoprof for xen/ia64: import oprofi

To: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [PATCH 3/7 TAKE 2] xenoprof for xen/ia64: import oprofile/perfmon.c to xen
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Tue, 14 Nov 2006 16:13:18 +0900
Cc: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Delivery-date: Mon, 13 Nov 2006 23:13:26 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20061114071214.9377.78928.sendpatchset@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20061114071214.9377.78928.sendpatchset@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User yamahata@xxxxxxxxxxxxx
# Date 1161346894 -32400
# Node ID acacfc83fff962a48605cc88908c4d012563742d
# Parent  802891fcacbab5bf3cbe564b5d70bd31f0903b46
import linux/arch/ia64/oprofile/perfmon.c to
xen/arch/ia64/xen/oprofile/perfmon.c
PATCHNAME: import_linux_arch_ia64_oprofile_perfmon_c_to_ia64_xen

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>

diff -r 802891fcacba -r acacfc83fff9 xen/arch/ia64/xen/oprofile/perfmon.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/ia64/xen/oprofile/perfmon.c      Fri Oct 20 21:21:34 2006 +0900
@@ -0,0 +1,100 @@
+/**
+ * @file perfmon.c
+ *
+ * @remark Copyright 2003 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon <levon@xxxxxxxxxxxxxxxxx>
+ */
+
+#include <linux/kernel.h>
+#include <linux/config.h>
+#include <linux/oprofile.h>
+#include <linux/sched.h>
+#include <asm/perfmon.h>
+#include <asm/ptrace.h>
+#include <asm/errno.h>
+
+static int allow_ints;
+
+static int
+perfmon_handler(struct task_struct *task, void *buf, pfm_ovfl_arg_t *arg,
+                struct pt_regs *regs, unsigned long stamp)
+{
+       int event = arg->pmd_eventid;
+ 
+       arg->ovfl_ctrl.bits.reset_ovfl_pmds = 1;
+
+       /* the owner of the oprofile event buffer may have exited
+        * without perfmon being shutdown (e.g. SIGSEGV)
+        */
+       if (allow_ints)
+               oprofile_add_sample(regs, event);
+       return 0;
+}
+
+
+static int perfmon_start(void)
+{
+       allow_ints = 1;
+       return 0;
+}
+
+
+static void perfmon_stop(void)
+{
+       allow_ints = 0;
+}
+
+
+#define OPROFILE_FMT_UUID { \
+       0x77, 0x7a, 0x6e, 0x61, 0x20, 0x65, 0x73, 0x69, 0x74, 0x6e, 0x72, 0x20, 
0x61, 0x65, 0x0a, 0x6c }
+
+static pfm_buffer_fmt_t oprofile_fmt = {
+       .fmt_name           = "oprofile_format",
+       .fmt_uuid           = OPROFILE_FMT_UUID,
+       .fmt_handler        = perfmon_handler,
+};
+
+
+static char * get_cpu_type(void)
+{
+       __u8 family = local_cpu_data->family;
+
+       switch (family) {
+               case 0x07:
+                       return "ia64/itanium";
+               case 0x1f:
+                       return "ia64/itanium2";
+               default:
+                       return "ia64/ia64";
+       }
+}
+
+
+/* all the ops are handled via userspace for IA64 perfmon */
+
+static int using_perfmon;
+
+int perfmon_init(struct oprofile_operations * ops)
+{
+       int ret = pfm_register_buffer_fmt(&oprofile_fmt);
+       if (ret)
+               return -ENODEV;
+
+       ops->cpu_type = get_cpu_type();
+       ops->start = perfmon_start;
+       ops->stop = perfmon_stop;
+       using_perfmon = 1;
+       printk(KERN_INFO "oprofile: using perfmon.\n");
+       return 0;
+}
+
+
+void perfmon_exit(void)
+{
+       if (!using_perfmon)
+               return;
+
+       pfm_unregister_buffer_fmt(oprofile_fmt.fmt_uuid);
+}
yamahata

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel