From: Rob Gardner <rob.gardner@hp.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH] Non-polling trace record access
Date: Thu, 06 Apr 2006 14:44:53 -0600 [thread overview]
Message-ID: <44357DC5.2010809@hp.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 3371 bytes --]
This is the kernel side code to implement a virtual irq that gets sent
when the xen trace buffers become half-full. This allows userland tools
such as xentrace and xenmon to avoid polling for new trace records. A
future patch will include support for this in XenMon, along with various
other enhancements and bug fixes.
This patch has been tested on x86, x86-64, and x86 SMP machines.
Keir: The code has been re-synced with current tip, and your suggested
changes made.
Rob Gardner
# HG changeset patch
# User rob.gardner@hp.com
# Node ID a2f24cf7585929ade7d846049bfc0544298bf8d0
# Parent 67de34c062b5897d1e82995b171be081f976558e
Added trace buffer virtual irq to implement non-polling trace record access
Signed-off-by: Rob Gardner <rob.gardner@hp.com>
diff -r 67de34c062b5 -r a2f24cf75859 xen/common/trace.c
--- a/xen/common/trace.c Thu Apr 6 11:03:53 2006
+++ b/xen/common/trace.c Thu Apr 6 20:38:58 2006
@@ -27,6 +27,8 @@
#include <xen/smp.h>
#include <xen/trace.h>
#include <xen/errno.h>
+#include <xen/event.h>
+#include <xen/softirq.h>
#include <xen/init.h>
#include <asm/atomic.h>
#include <public/dom0_ops.h>
@@ -40,6 +42,11 @@
static struct t_rec *t_recs[NR_CPUS];
static int nr_recs;
+/* High water mark for trace buffers; */
+/* Send virtual interrupt when buffer level reaches this point */
+static int t_buf_highwater;
+
+
/* a flag recording whether initialization has been done */
/* or more properly, if the tbuf subsystem is enabled right now */
int tb_init_done;
@@ -49,6 +56,12 @@
/* which tracing events are enabled */
static u32 tb_event_mask = TRC_ALL;
+
+static void trace_notify_guest(void)
+{
+ send_guest_global_virq(dom0, VIRQ_TBUF);
+}
+
/**
* alloc_trace_bufs - performs initialization of the per-cpu trace buffers.
@@ -92,6 +105,9 @@
buf->cons = buf->prod = 0;
t_recs[i] = (struct t_rec *)(buf + 1);
}
+
+ t_buf_highwater = nr_recs >> 1; /* 50% high water */
+ open_softirq(TRACE_SOFTIRQ, trace_notify_guest);
return 0;
}
@@ -272,6 +288,13 @@
buf->prod++;
local_irq_restore(flags);
+
+ /*
+ * Notify trace buffer consumer that we've reached the high water mark.
+ *
+ */
+ if ( (buf->prod - buf->cons) == t_buf_highwater )
+ raise_softirq(TRACE_SOFTIRQ);
}
/*
diff -r 67de34c062b5 -r a2f24cf75859 xen/include/public/xen.h
--- a/xen/include/public/xen.h Thu Apr 6 11:03:53 2006
+++ b/xen/include/public/xen.h Thu Apr 6 20:38:58 2006
@@ -77,6 +77,7 @@
#define VIRQ_CONSOLE 2 /* G. (DOM0) Bytes received on emergency
console. */
#define VIRQ_DOM_EXC 3 /* G. (DOM0) Exceptional event for some
domain. */
#define VIRQ_DEBUGGER 6 /* G. (DOM0) A domain has paused for
debugging. */
+#define VIRQ_TBUF 7 /* G. (DOM0) Trace buffer has records
available */
#define NR_VIRQS 8
/*
diff -r 67de34c062b5 -r a2f24cf75859 xen/include/xen/softirq.h
--- a/xen/include/xen/softirq.h Thu Apr 6 11:03:53 2006
+++ b/xen/include/xen/softirq.h Thu Apr 6 20:38:58 2006
@@ -9,7 +9,8 @@
#define NMI_SOFTIRQ 4
#define PAGE_SCRUB_SOFTIRQ 5
#define DOMAIN_SHUTDOWN_FINALISE_SOFTIRQ 6
-#define NR_SOFTIRQS 7
+#define TRACE_SOFTIRQ 7
+#define NR_SOFTIRQS 8
#ifndef __ASSEMBLY__
[-- Attachment #2: non-polling-tbuf.patch --]
[-- Type: text/plain, Size: 2856 bytes --]
# HG changeset patch
# User rob.gardner@hp.com
# Node ID a2f24cf7585929ade7d846049bfc0544298bf8d0
# Parent 67de34c062b5897d1e82995b171be081f976558e
Added trace buffer virtual irq to implement non-polling trace record access
Signed-off-by: Rob Gardner <rob.gardner@hp.com>
diff -r 67de34c062b5 -r a2f24cf75859 xen/common/trace.c
--- a/xen/common/trace.c Thu Apr 6 11:03:53 2006
+++ b/xen/common/trace.c Thu Apr 6 20:38:58 2006
@@ -27,6 +27,8 @@
#include <xen/smp.h>
#include <xen/trace.h>
#include <xen/errno.h>
+#include <xen/event.h>
+#include <xen/softirq.h>
#include <xen/init.h>
#include <asm/atomic.h>
#include <public/dom0_ops.h>
@@ -40,6 +42,11 @@
static struct t_rec *t_recs[NR_CPUS];
static int nr_recs;
+/* High water mark for trace buffers; */
+/* Send virtual interrupt when buffer level reaches this point */
+static int t_buf_highwater;
+
+
/* a flag recording whether initialization has been done */
/* or more properly, if the tbuf subsystem is enabled right now */
int tb_init_done;
@@ -49,6 +56,12 @@
/* which tracing events are enabled */
static u32 tb_event_mask = TRC_ALL;
+
+static void trace_notify_guest(void)
+{
+ send_guest_global_virq(dom0, VIRQ_TBUF);
+}
+
/**
* alloc_trace_bufs - performs initialization of the per-cpu trace buffers.
@@ -92,6 +105,9 @@
buf->cons = buf->prod = 0;
t_recs[i] = (struct t_rec *)(buf + 1);
}
+
+ t_buf_highwater = nr_recs >> 1; /* 50% high water */
+ open_softirq(TRACE_SOFTIRQ, trace_notify_guest);
return 0;
}
@@ -272,6 +288,13 @@
buf->prod++;
local_irq_restore(flags);
+
+ /*
+ * Notify trace buffer consumer that we've reached the high water mark.
+ *
+ */
+ if ( (buf->prod - buf->cons) == t_buf_highwater )
+ raise_softirq(TRACE_SOFTIRQ);
}
/*
diff -r 67de34c062b5 -r a2f24cf75859 xen/include/public/xen.h
--- a/xen/include/public/xen.h Thu Apr 6 11:03:53 2006
+++ b/xen/include/public/xen.h Thu Apr 6 20:38:58 2006
@@ -77,6 +77,7 @@
#define VIRQ_CONSOLE 2 /* G. (DOM0) Bytes received on emergency console. */
#define VIRQ_DOM_EXC 3 /* G. (DOM0) Exceptional event for some domain. */
#define VIRQ_DEBUGGER 6 /* G. (DOM0) A domain has paused for debugging. */
+#define VIRQ_TBUF 7 /* G. (DOM0) Trace buffer has records available */
#define NR_VIRQS 8
/*
diff -r 67de34c062b5 -r a2f24cf75859 xen/include/xen/softirq.h
--- a/xen/include/xen/softirq.h Thu Apr 6 11:03:53 2006
+++ b/xen/include/xen/softirq.h Thu Apr 6 20:38:58 2006
@@ -9,7 +9,8 @@
#define NMI_SOFTIRQ 4
#define PAGE_SCRUB_SOFTIRQ 5
#define DOMAIN_SHUTDOWN_FINALISE_SOFTIRQ 6
-#define NR_SOFTIRQS 7
+#define TRACE_SOFTIRQ 7
+#define NR_SOFTIRQS 8
#ifndef __ASSEMBLY__
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2006-04-06 20:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-06 20:44 Rob Gardner [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-03-31 17:54 [PATCH] Non-polling trace record access Rob Gardner
2006-04-06 9:27 ` Keir Fraser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44357DC5.2010809@hp.com \
--to=rob.gardner@hp.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.