[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] New Xen trace buffer implementation that avoids blocking



ChangeSet 1.1278.1.1, 2005/04/07 05:08:36+01:00, bren@xxxxxxxxxxxxxxxxxxxxxxx

        New Xen trace buffer implementation that avoids blocking
        interrupts. Add support for trace buffer CPU mask and
        event mask. Add support for trace classes. New DOM0 trace
        buffer hypercall. Fix 'xentrace' signal handler bug.
        
        Signed-off-by: bin.ren@xxxxxxxxxxxx



 tools/xentrace/formats        |   49 +++++++++-------------------
 tools/xentrace/xentrace.c     |   48 ++++++++++++++-------------
 xen/common/dom0_ops.c         |    7 +---
 xen/common/schedule.c         |   18 ----------
 xen/common/trace.c            |   73 ++++++++++++++++++++++++------------------
 xen/include/asm-x86/vmx.h     |    4 --
 xen/include/public/dom0_ops.h |   16 ++++++---
 xen/include/public/trace.h    |   54 +++++++++++++++++++++++--------
 xen/include/xen/trace.h       |   59 ++++++++++++++++++---------------
 9 files changed, 172 insertions(+), 156 deletions(-)


diff -Nru a/tools/xentrace/formats b/tools/xentrace/formats
--- a/tools/xentrace/formats    2005-04-07 05:03:20 -04:00
+++ b/tools/xentrace/formats    2005-04-07 05:03:20 -04:00
@@ -1,34 +1,17 @@
-0x00010000     CPU%(cpu)d      %(tsc)d         sched_add_domain        [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x ]
-0x00010001     CPU%(cpu)d      %(tsc)d         sched_rem_domain        [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x ]
-0x00010002     CPU%(cpu)d      %(tsc)d         domain_sleep            [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x ]
-0x00010003     CPU%(cpu)d      %(tsc)d         domain_wake             [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x ]
-0x00010004     CPU%(cpu)d      %(tsc)d         do_yield                [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x ]
-0x00010005     CPU%(cpu)d      %(tsc)d         do_block                [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x ]
-0x00010006     CPU%(cpu)d      %(tsc)d         domain_shutdown         [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x, reason = 0x%(3)08x ]
-0x00010007     CPU%(cpu)d      %(tsc)d         sched_ctl
-0x00010008     CPU%(cpu)d      %(tsc)d         sched_adjdom            [ domid 
= 0x%(1)08x ]
-0x00010009     CPU%(cpu)d      %(tsc)d         __enter_scheduler       [ 
prev<domid:edomid> = 0x%(1)08x : 0x%(2)08x, next<domid:edomid> = 0x%(3)08x : 
0x%(4)08x ]
-0x0001000A     CPU%(cpu)d      %(tsc)d         s_timer_fn
-0x0001000B     CPU%(cpu)d      %(tsc)d         t_timer_fn
-0x0001000C     CPU%(cpu)d      %(tsc)d         dom_timer_fn
+0x00020001     CPU%(cpu)d      %(tsc)d         sched_add_domain        [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x ]
+0x00020002     CPU%(cpu)d      %(tsc)d         sched_rem_domain        [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x ]
+0x00020003     CPU%(cpu)d      %(tsc)d         domain_sleep            [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x ]
+0x00020004     CPU%(cpu)d      %(tsc)d         domain_wake             [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x ]
+0x00020005     CPU%(cpu)d      %(tsc)d         do_yield                [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x ]
+0x00020006     CPU%(cpu)d      %(tsc)d         do_block                [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x ]
+0x00020007     CPU%(cpu)d      %(tsc)d         domain_shutdown         [ domid 
= 0x%(1)08x, edomid = 0x%(2)08x, reason = 0x%(3)08x ]
+0x00020008     CPU%(cpu)d      %(tsc)d         sched_ctl
+0x00020009     CPU%(cpu)d      %(tsc)d         sched_adjdom            [ domid 
= 0x%(1)08x ]
+0x0002000a     CPU%(cpu)d      %(tsc)d         __enter_scheduler       [ 
prev<domid:edomid> = 0x%(1)08x : 0x%(2)08x, next<domid:edomid> = 0x%(3)08x : 
0x%(4)08x ]
+0x0002000B     CPU%(cpu)d      %(tsc)d         s_timer_fn
+0x0002000c     CPU%(cpu)d      %(tsc)d         t_timer_fn
+0x0002000d     CPU%(cpu)d      %(tsc)d         dom_timer_fn
 
-
-0x00020008     CPU%(cpu)d      %(tsc)d         enter: dom0_create_dom
-0x00030008     CPU%(cpu)d      %(tsc)d         leave: dom0_create_dom
-0x00020009     CPU%(cpu)d      %(tsc)d         enter: dom0_destroy_dom
-0x00030009     CPU%(cpu)d      %(tsc)d         leave: dom0_destroy_dom
-0x0002000A     CPU%(cpu)d      %(tsc)d         enter: dom0_start_dom
-0x0003000A     CPU%(cpu)d      %(tsc)d         leave: dom0_start_dom
-0x0002000B     CPU%(cpu)d      %(tsc)d         enter: dom0_stop_dom
-0x0003000B     CPU%(cpu)d      %(tsc)d         leave: dom0_stop_dom
-0x0002000C     CPU%(cpu)d      %(tsc)d         enter: dom0_getinfo
-0x0003000C     CPU%(cpu)d      %(tsc)d         leave: dom0_getinfo
-0x0002000D     CPU%(cpu)d      %(tsc)d         enter: dom0_build
-0x0003000D     CPU%(cpu)d      %(tsc)d         leave: dom0_build
-0x00020019     CPU%(cpu)d      %(tsc)d         enter: dom0_shadow_op
-0x00030019     CPU%(cpu)d      %(tsc)d         leave: dom0_shadow_op
-
-
-0x00040001     CPU%(cpu)d      %(tsc)d         VMX_VMEXIT              [ domid 
= 0x%(1)08x, eip = 0x%(2)08x, reason = 0x%(3)08x ]
-0x00040002     CPU%(cpu)d      %(tsc)d         VMX_VECTOR              [ domid 
= 0x%(1)08x, eip = 0x%(2)08x, vector = 0x%(3)08x ]
-0x00040003     CPU%(cpu)d      %(tsc)d         VMX_INT                 [ domid 
= 0x%(1)08x, trap = 0x%(2)08x, va = 0x%(3)08x ]
\ No newline at end of file
+0x00080001     CPU%(cpu)d      %(tsc)d         VMX_VMEXIT              [ domid 
= 0x%(1)08x, eip = 0x%(2)08x, reason = 0x%(3)08x ]
+0x00080002     CPU%(cpu)d      %(tsc)d         VMX_VECTOR              [ domid 
= 0x%(1)08x, eip = 0x%(2)08x, vector = 0x%(3)08x ]
+0x00080003     CPU%(cpu)d      %(tsc)d         VMX_INT                 [ domid 
= 0x%(1)08x, trap = 0x%(2)08x, va = 0x%(3)08x ]
diff -Nru a/tools/xentrace/xentrace.c b/tools/xentrace/xentrace.c
--- a/tools/xentrace/xentrace.c 2005-04-07 05:03:20 -04:00
+++ b/tools/xentrace/xentrace.c 2005-04-07 05:03:20 -04:00
@@ -11,10 +11,10 @@
 
 #include <time.h>
 #include <stdlib.h>
-#include <sys/mman.h>
 #include <stdio.h>
-#include <sys/types.h>
+#include <sys/mman.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
@@ -101,8 +101,9 @@
     dom0_op_t op;                        /* dom0 op we'll build             */
     int xc_handle = xc_interface_open(); /* for accessing control interface */
 
-    op.cmd = DOM0_GETTBUFS;
+    op.cmd = DOM0_TBUFCONTROL;
     op.interface_version = DOM0_INTERFACE_VERSION;
+    op.u.tbufcontrol.op  = DOM0_TBUF_GET_INFO;
 
     ret = do_dom0_op(xc_handle, &op);
 
@@ -114,8 +115,8 @@
         exit(EXIT_FAILURE);
     }
 
-    *mach_addr = op.u.gettbufs.mach_addr;
-    *size      = op.u.gettbufs.size;
+    *mach_addr = op.u.tbufcontrol.mach_addr;
+    *size      = op.u.tbufcontrol.size;
 }
 
 /**
@@ -141,8 +142,8 @@
     }
 
     tbufs_mapped = xc_map_foreign_range(xc_handle, 0 /* Dom 0 ID */,
-                                       size * num, PROT_READ,
-                                       tbufs_mach >> PAGE_SHIFT);
+                                        size * num, PROT_READ,
+                                        tbufs_mach >> PAGE_SHIFT);
 
     xc_interface_close(xc_handle);
 
@@ -152,7 +153,7 @@
         exit(EXIT_FAILURE);
     }
 
-    return (struct t_buf *)tbufs_mapped;
+    return tbufs_mapped;
 }
 
 
@@ -181,8 +182,7 @@
     /* initialise pointers to the trace buffers - given the size of a trace
      * buffer and the value of bufs_maped, we can easily calculate these */
     for ( i = 0; i<num; i++ )
-        user_ptrs[i] = (struct t_buf *)(
-            (unsigned long)bufs_mapped + size * i);
+        user_ptrs[i] = (struct t_buf *)((unsigned long)bufs_mapped + size * i);
 
     return user_ptrs;
 }
@@ -214,9 +214,9 @@
         exit(EXIT_FAILURE);
     }
 
-    for ( i = 0; i<num; i++ )
-        data[i] = (struct t_rec *)(meta[i]->data - tbufs_mach
-                                  + (unsigned long)tbufs_mapped);
+    for ( i = 0; i < num; i++ )
+        data[i] = (struct t_rec *)(meta[i]->rec_addr - tbufs_mach
+                                   + (unsigned long)tbufs_mapped);
 
     return data;
 }
@@ -242,7 +242,7 @@
     }
     
     for ( i = 0; i<num; i++ )
-        tails[i] = bufs[i]->head;
+        tails[i] = atomic_read(&bufs[i]->rec_idx);
 
     return tails;
 }
@@ -299,7 +299,7 @@
     get_tbufs(&tbufs_mach, &size);
     tbufs_mapped = map_tbufs(tbufs_mach, num, size);
 
-    size_in_recs = (size / sizeof(struct t_rec) )-1;
+    size_in_recs = (size - sizeof(struct t_buf)) / sizeof(struct t_rec);
 
     /* build arrays of convenience ptrs */
     meta  = init_bufs_ptrs (tbufs_mapped, num, size);
@@ -310,11 +310,11 @@
     while ( !interrupted )
     {
         for ( i = 0; ( i < num ) && !interrupted; i++ )
-           while( cons[i] != meta[i]->head )
-           {
-               write_rec(i, data[i] + (cons[i] % size_in_recs), logfile);
-               cons[i]++;
-           }
+            while( cons[i] != atomic_read(&meta[i]->rec_idx) )
+            {
+                write_rec(i, data[i] + cons[i], logfile);
+                cons[i] = (cons[i] + 1) % size_in_recs;
+            }
 
         nanosleep(&opts.poll_sleep, NULL);
     }
@@ -445,9 +445,11 @@
     
     /* ensure that if we get a signal, we'll do cleanup, then exit */
     act.sa_handler = close_handler;
-    sigaction(SIGHUP,  &act, 0);
-    sigaction(SIGTERM, &act, 0);
-    sigaction(SIGINT,  &act, 0);
+    act.sa_flags = 0;
+    sigemptyset(&act.sa_mask);
+    sigaction(SIGHUP,  &act, NULL);
+    sigaction(SIGTERM, &act, NULL);
+    sigaction(SIGINT,  &act, NULL);
 
     ret = monitor_tbufs(logfile);
 
diff -Nru a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c
--- a/xen/common/dom0_ops.c     2005-04-07 05:03:20 -04:00
+++ b/xen/common/dom0_ops.c     2005-04-07 05:03:20 -04:00
@@ -19,9 +19,6 @@
 #include <xen/physdev.h>
 #include <public/sched_ctl.h>
 
-#define TRC_DOM0OP_ENTER_BASE  0x00020000
-#define TRC_DOM0OP_LEAVE_BASE  0x00030000
-
 extern unsigned int alloc_new_dom_mem(struct domain *, unsigned int);
 extern long arch_do_dom0_op(dom0_op_t *op, dom0_op_t *u_dom0_op);
 extern void arch_getdomaininfo_ctxt(
@@ -385,9 +382,9 @@
     break;
 
 #ifdef TRACE_BUFFER
-    case DOM0_GETTBUFS:
+    case DOM0_TBUFCONTROL:
     {
-        ret = get_tb_info(&op->u.gettbufs);
+        ret = tb_control(&op->u.tbufcontrol);
         copy_to_user(u_dom0_op, op, sizeof(*op));
     }
     break;
diff -Nru a/xen/common/schedule.c b/xen/common/schedule.c
--- a/xen/common/schedule.c     2005-04-07 05:03:20 -04:00
+++ b/xen/common/schedule.c     2005-04-07 05:03:20 -04:00
@@ -42,24 +42,6 @@
 
 #define TIME_SLOP      (s32)MICROSECS(50)     /* allow time to slip a bit */
 
-/*
- * TODO MAW pull trace-related #defines out of here and into an auto-generated
- * header file later on!
- */
-#define TRC_SCHED_DOM_ADD             0x00010000
-#define TRC_SCHED_DOM_REM             0x00010001
-#define TRC_SCHED_SLEEP               0x00010002
-#define TRC_SCHED_WAKE                0x00010003
-#define TRC_SCHED_YIELD               0x00010004
-#define TRC_SCHED_BLOCK               0x00010005
-#define TRC_SCHED_SHUTDOWN            0x00010006
-#define TRC_SCHED_CTL                 0x00010007
-#define TRC_SCHED_ADJDOM              0x00010008
-#define TRC_SCHED_SWITCH              0x00010009
-#define TRC_SCHED_S_TIMER_FN          0x0001000A
-#define TRC_SCHED_T_TIMER_FN          0x0001000B
-#define TRC_SCHED_DOM_TIMER_FN        0x0001000C
-
 /* Various timer handlers. */
 static void s_timer_fn(unsigned long unused);
 static void t_timer_fn(unsigned long unused);
diff -Nru a/xen/common/trace.c b/xen/common/trace.c
--- a/xen/common/trace.c        2005-04-07 05:03:20 -04:00
+++ b/xen/common/trace.c        2005-04-07 05:03:20 -04:00
@@ -8,6 +8,8 @@
  * Author: Mark Williamson, mark.a.williamson@xxxxxxxxx
  * Date:   January 2004
  *
+ * Copyright (C) 2005 Bin Ren
+ *
  * The trace buffer code is designed to allow debugging traces of Xen to be
  * generated on UP / SMP machines.  Each trace entry is timestamped so that

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.