ia64/xen-unstable

changeset 1370:6cf25fb7eebd

bitkeeper revision 1.901 (40a2378bJgHRjIarVmrsJejFqiYh3g)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into labyrinth.cl.cam.ac.uk:/auto/groups/xeno/users/iap10/xeno-clone/xeno.bk
author iap10@labyrinth.cl.cam.ac.uk
date Wed May 12 14:41:15 2004 +0000 (2004-05-12)
parents 76c4a76ab5d1 a7062958deee
children a3dd7bf2fcd6
files .rootkeys tools/xentrace/Makefile tools/xentrace/formats tools/xentrace/xentrace.8 tools/xentrace/xentrace.c tools/xentrace/xentrace_cpusplit tools/xentrace/xentrace_cpusplit.1 tools/xentrace/xentrace_format tools/xentrace/xentrace_format.1 xen/arch/i386/entry.S
line diff
     1.1 --- a/.rootkeys	Wed May 12 09:12:53 2004 +0000
     1.2 +++ b/.rootkeys	Wed May 12 14:41:15 2004 +0000
     1.3 @@ -115,8 +115,6 @@ 403a3edbrr8RE34gkbR40zep98SXbg tools/xen
     1.4  40a107afN60pFdURgBv9KwEzgRl5mQ tools/xentrace/formats
     1.5  4050c413PhhLNAYk3TEwP37i_iLw9Q tools/xentrace/xentrace.8
     1.6  403a3edbVpV2E_wq1zeEkJ_n4Uu2eg tools/xentrace/xentrace.c
     1.7 -403a3edb0lzD0Fojc-NYNoXr3SYrnA tools/xentrace/xentrace_cpusplit
     1.8 -4050c413BnzzZZlZRI1ai6oFXOsHLQ tools/xentrace/xentrace_cpusplit.1
     1.9  403a3edblCUrzSj0mmKhO5HOPrOrSQ tools/xentrace/xentrace_format
    1.10  4050c413NtuyIq5lsYJV4P7KIjujXw tools/xentrace/xentrace_format.1
    1.11  3f72f1bdJPsV3JCnBqs9ddL9tr6D2g xen/COPYING
     2.1 --- a/tools/xentrace/Makefile	Wed May 12 09:12:53 2004 +0000
     2.2 +++ b/tools/xentrace/Makefile	Wed May 12 14:41:15 2004 +0000
     2.3 @@ -9,7 +9,7 @@ HDRS     = $(wildcard *.h)
     2.4  OBJS     = $(patsubst %.c,%.o,$(wildcard *.c))
     2.5  
     2.6  BIN      = xentrace
     2.7 -SCRIPTS  = xentrace_cpusplit xentrace_format
     2.8 +SCRIPTS  = xentrace_format
     2.9  MAN1     = $(wildcard *.1)
    2.10  MAN8     = $(wildcard *.8)
    2.11  
     3.1 --- a/tools/xentrace/formats	Wed May 12 09:12:53 2004 +0000
     3.2 +++ b/tools/xentrace/formats	Wed May 12 14:41:15 2004 +0000
     3.3 @@ -1,13 +1,13 @@
     3.4 -0x00010000	CPU%(cpu)d 0x%(tsc)x sched_add_domain(0x%(3)08x)            [ dom id = 0x%(1)08x%(2)08x   ]
     3.5 -0x00010001	CPU%(cpu)d 0x%(tsc)x sched_rem_domain(0x%08(3)x)            [ dom id = 0x%(1)08x%(2)08x   ]
     3.6 -0x00010002	CPU%(cpu)d 0x%(tsc)x __wake_up(0x%(3)08x)                   [ dom id = 0x%(1)08x%(2)08x   ]
     3.7 +0x00010000	CPU%(cpu)d 0x%(tsc)x sched_add_domain(0x%(3)08x)            [ dom id = 0x%(1)x%(2)08x   ]
     3.8 +0x00010001	CPU%(cpu)d 0x%(tsc)x sched_rem_domain(0x%08(3)x)            [ dom id = 0x%(1)x%(2)08x   ]
     3.9 +0x00010002	CPU%(cpu)d 0x%(tsc)x __wake_up(0x%(3)08x)                   [ dom id = 0x%(1)x%(2)08x   ]
    3.10  0x00010003	CPU%(cpu)d 0x%(tsc)x do_block()                             [ current = 0x%(2)08x         ]
    3.11  0x00010004	CPU%(cpu)d 0x%(tsc)x do_yield()		                    [ current = %(2)08x         ]
    3.12  0x00010005	CPU%(cpu)d 0x%(tsc)x do_set_timer_op(0x%(4)08x, 0x%(5)08x)  [ current = 0x%(3)08x ]
    3.13  0x00010006	CPU%(cpu)d 0x%(tsc)x sched_ctl(0x%(1)08x)
    3.14 -0x00010007	CPU%(cpu)d 0x%(tsc)x sched_adjdom(params)                   [ dom id = 0x%(1)08x%(2)08x   ]
    3.15 -0x00010008	CPU%(cpu)d 0x%(tsc)x __reschedule(0x%(3)08x)                [ dom id = 0x%(1)08x%(2)08x   ]
    3.16 -0x00010009	CPU%(cpu)d 0x%(tsc)x switching to task_struct 0x%(1)08x     [ dom id = 0x%(1)08x     ]
    3.17 +0x00010007	CPU%(cpu)d 0x%(tsc)x sched_adjdom(params)                   [ dom id = 0x%(1)x%(2)08x   ]
    3.18 +0x00010008	CPU%(cpu)d 0x%(tsc)x __reschedule(0x%(3)08x)                [ dom id = 0x%(1)x%(2)08x   ]
    3.19 +0x00010009	CPU%(cpu)d 0x%(tsc)x switching to task_struct 0x%(1)08x     [ dom id = 0x%(1)x     ]
    3.20  0x0001000A	CPU%(cpu)d 0x%(tsc)x s_timer_fn(unused)
    3.21  0x0001000B	CPU%(cpu)d 0x%(tsc)x t_timer_fn(unused)
    3.22  0x0001000C	CPU%(cpu)d 0x%(tsc)x dom_timer_fn(data)
     4.1 --- a/tools/xentrace/xentrace.8	Wed May 12 09:12:53 2004 +0000
     4.2 +++ b/tools/xentrace/xentrace.8	Wed May 12 14:41:15 2004 +0000
     4.3 @@ -10,17 +10,22 @@ xentrace \- capture Xen trace buffer dat
     4.4  ]
     4.5  .SH DESCRIPTION
     4.6  .B xentrace
     4.7 -is used to dump data from Xen's per-cpu trace buffers.  Records
     4.8 -are dumped in ASCII format, onto the standard output or a \fIFILE\fP
     4.9 -specified on the command line.
    4.10 -Trace records are formatted as follows:
    4.11 +is used to capture trace buffer data from Xen.  The data is
    4.12 +output in the following binary format (host endian):
    4.13  .PP
    4.14 -                    CPU TSC EVENT D1 D2 D3 D4 D5
    4.15 +    CPU(uint) TSC(u64) EVENT(u32) D1 D2 D3 D4 D5 (all u32)
    4.16  .PP
    4.17  Where CPU is the processor number, TSC is the record's timestamp
    4.18  (the value of the CPU cycle counter), EVENT is the event ID and
    4.19  D1...D5 are the trace data.
    4.20  
    4.21 +Data is dumped onto the standard output (which must not be a TTY) or a
    4.22 +\fIFILE\fP specified on the command line.
    4.23 +
    4.24 +The output should be parsed using the tool xentrace_format, which can
    4.25 +produce human-readable output in ASCII format.
    4.26 +
    4.27 +
    4.28  .SS Options
    4.29  .TP
    4.30  .B -t, --log-thresh=l
     5.1 --- a/tools/xentrace/xentrace.c	Wed May 12 09:12:53 2004 +0000
     5.2 +++ b/tools/xentrace/xentrace.c	Wed May 12 14:41:15 2004 +0000
     5.3 @@ -26,8 +26,7 @@
     5.4  /* from xen/include/hypervisor-ifs */
     5.5  #include <trace.h>
     5.6  
     5.7 -extern FILE *stdout;
     5.8 -
     5.9 +extern FILE *stderr;
    5.10  
    5.11  /***** Compile time configuration of defaults ********************************/
    5.12  
    5.13 @@ -53,7 +52,6 @@ int interrupted = 0; /* gets set if we g
    5.14  void close_handler(int signal)
    5.15  {
    5.16      interrupted = 1;
    5.17 -    fprintf(stderr,"Received signal %d, now exiting\n", signal);
    5.18  }
    5.19  
    5.20  /**
    5.21 @@ -70,23 +68,21 @@ struct timespec millis_to_timespec(unsig
    5.22      return spec;
    5.23  }
    5.24  
    5.25 -
    5.26  /**
    5.27 - * print_rec - plain print an event given a pointer to its start
    5.28 - * @cpu:       CPU the data came from
    5.29 - * @data:      pointer to the start of the event data
    5.30 - * @out:       file stream to print out to
    5.31 + * write_rec - output a trace record in binary format
    5.32 + * @cpu      - source buffer CPU ID
    5.33 + * @rec      - trace record to output
    5.34 + * @out      - output stream
    5.35   *
    5.36 - * Takes a pointer to a record and prints out the data.
    5.37 + * Outputs the trace record to a filestream, prepending the CPU ID of the
    5.38 + * source trace buffer.
    5.39   */
    5.40 -void print_rec(unsigned int cpu, struct t_rec *rec, FILE *out)
    5.41 -{    
    5.42 -    fprintf(out, "%u %llu %lu %lu %lu %lu %lu %lu\n",
    5.43 -	    cpu, rec->cycles, rec->event, rec->d1, rec->d2,
    5.44 -	    rec->d3, rec->d4, rec->d5);
    5.45 +void write_rec(unsigned int cpu, struct t_rec *rec, FILE *out)
    5.46 +{
    5.47 +    fwrite(&cpu, sizeof(cpu), 1, out);
    5.48 +    fwrite(rec, sizeof(*rec), 1, out);
    5.49  }
    5.50  
    5.51 -
    5.52  /**
    5.53   * get_tbufs - get pointer to and size of the trace buffers
    5.54   * @phys_addr: location to store physical address if the trace buffers to
    5.55 @@ -321,11 +317,11 @@ int monitor_tbufs(FILE *logfile)
    5.56              {
    5.57                  /* output pre-wrap data */
    5.58                  for(j = 0; j < prewrap; j++)
    5.59 -                    print_rec(i, data[i] + tails[i] + j, logfile);
    5.60 +                    write_rec(i, data[i] + tails[i] + j, logfile);
    5.61                  
    5.62                  /* output post-wrap data, if any */                    
    5.63                  for(j = 0; j < (newdata - prewrap); j++)
    5.64 -                    print_rec(i, data[i] + j, logfile);  
    5.65 +                    write_rec(i, data[i] + j, logfile);  
    5.66                  
    5.67                  tails[i] += newdata;
    5.68                  if(tails[i] >= meta[i]->size) tails[i] = 0;
    5.69 @@ -418,9 +414,10 @@ const struct argp parser_def =
    5.70      "Tool to capure Xen trace buffer data"
    5.71      "\v"
    5.72      "This tool is used to capture trace buffer data from Xen.  The data is "
    5.73 -    "output as space-separated decimal numbers, represented in ASCII, in "
    5.74 -    "the following order:\n\n"
    5.75 -    "  CPU TSC EVENT DATA1 DATA2 DATA3 DATA4 DATA5\n"
    5.76 +    "output in a binary format, in the following order:\n\n"
    5.77 +    "  CPU(uint) TSC(u64) EVENT(u32) D1 D2 D3 D4 D5 (all u32)\n\n"
    5.78 +    "The output should be parsed using the tool xentrace_format, which can "
    5.79 +    "produce human-readable output in ASCII format."
    5.80  };
    5.81  
    5.82  
    5.83 @@ -430,8 +427,8 @@ const char *argp_program_bug_address = "
    5.84      
    5.85  int main(int argc, char **argv)
    5.86  {
    5.87 -    int ret;
    5.88 -    FILE *logfile = stdout;
    5.89 +    int outfd = 1, ret;
    5.90 +    FILE *logfile;
    5.91      struct sigaction act;
    5.92  
    5.93      opts.outfile = 0;
    5.94 @@ -441,7 +438,21 @@ int main(int argc, char **argv)
    5.95      argp_parse(&parser_def, argc, argv, 0, 0, &opts);
    5.96  
    5.97      if ( opts.outfile )
    5.98 -        logfile = fopen(opts.outfile, "w");
    5.99 +        outfd = open(opts.outfile, O_WRONLY | O_CREAT);
   5.100 +
   5.101 +    if(outfd < 0)
   5.102 +    {
   5.103 +        perror("Could not open output file");
   5.104 +        exit(EXIT_FAILURE);
   5.105 +    }        
   5.106 +
   5.107 +    if(isatty(outfd))
   5.108 +    {
   5.109 +        fprintf(stderr, "Cannot output to a TTY, specify a log file.\n");
   5.110 +        exit(EXIT_FAILURE);
   5.111 +    }
   5.112 +
   5.113 +    logfile = fdopen(outfd, "w");
   5.114      
   5.115      /* ensure that if we get a signal, we'll do cleanup, then exit */
   5.116      act.sa_handler = close_handler;
     6.1 --- a/tools/xentrace/xentrace_cpusplit	Wed May 12 09:12:53 2004 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,59 +0,0 @@
     6.4 -#!/usr/bin/env python
     6.5 -
     6.6 -# by Mark Williamson, (C) 2004 Intel Research Cambridge
     6.7 -
     6.8 -# Program for separating trace buffer data into per-cpu log files.
     6.9 -
    6.10 -import re, sys, signal
    6.11 -
    6.12 -def usage():
    6.13 -    print >> sys.stderr, \
    6.14 -          "Usage: " + sys.argv[0] + """ base-name
    6.15 -          Separates ASCII trace buffer data on stdin into per-CPU trace
    6.16 -          files.  The trace files are named by appending the CPU number
    6.17 -          to the base name supplied on the command line.
    6.18 -
    6.19 -          Depending on your system and the volume of trace buffer data,
    6.20 -          this script may not be able to keep up with the output of xentrace
    6.21 -          if it is piped directly.  In these circumstances you should have
    6.22 -          xentrace output to a file for processing off-line.
    6.23 -          """
    6.24 -    sys.exit(1)
    6.25 -    
    6.26 -def sighand(x,y):
    6.27 -    global interrupted
    6.28 -    interrupted = 1
    6.29 -
    6.30 -signal.signal(signal.SIGTERM, sighand)
    6.31 -signal.signal(signal.SIGHUP,  sighand)
    6.32 -signal.signal(signal.SIGINT,  sighand)
    6.33 -
    6.34 -r = re.compile("(\d) .*")
    6.35 -
    6.36 -if len(sys.argv) < 2:
    6.37 -    usage()
    6.38 -else:
    6.39 -    base_name = sys.argv[1]
    6.40 -
    6.41 -files = {}
    6.42 -interrupted = 0
    6.43 -
    6.44 -while not interrupted:
    6.45 -    try:
    6.46 -        line = sys.stdin.readline()
    6.47 -        if not line: break
    6.48 -        
    6.49 -        m = r.match(line)
    6.50 -
    6.51 -        if not m: print >> sys.stderr, "Invalid input line."
    6.52 -        
    6.53 -        cpu = m.group(1)
    6.54 -        
    6.55 -        if not files.has_key(base_name + str(cpu)):
    6.56 -            files[base_name + str(cpu)] = open(base_name + str(cpu), "w")
    6.57 -            
    6.58 -        print >> files[base_name + str(cpu)], line,
    6.59 -
    6.60 -    except IOError: sys.exit()
    6.61 -
    6.62 -# files closed automatically
     7.1 --- a/tools/xentrace/xentrace_cpusplit.1	Wed May 12 09:12:53 2004 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,27 +0,0 @@
     7.4 -.TH XENTRACE_CPUSPLIT 1 "11 March 2004" "Xen domain 0 utils"
     7.5 -.SH NAME
     7.6 -xentrace_cpusplit \- separate Xen trace data into per-CPU log files
     7.7 -.SH SYNOPSIS
     7.8 -.B xentrace_cpusplit
     7.9 -[
    7.10 -.I BASE-NAME
    7.11 -]
    7.12 -.SH DESCRIPTION
    7.13 -.B xentrace_cpusplit
    7.14 -Separates ASCII trace buffer data from stdin into per-CPU trace
    7.15 -files.  The trace files are named by appending the CPU number
    7.16 -to the \fIBASE-NAME\fP supplied on the command line.
    7.17 -
    7.18 -The trace records in the per-CPU files are in identical format to the
    7.19 -original output of \fBxentrace\fP and are in chronological order.
    7.20 -
    7.21 -Depending on your system and the rate at which trace data is produced,
    7.22 -this script may not be able to keep up with the output of
    7.23 -\fBxentrace\fP if it is piped directly.  In these circumstances you
    7.24 -should have \fBxentrace\fP output to a file for processing off-line.
    7.25 -
    7.26 -.SH AUTHOR
    7.27 -Mark A. Williamson <mark.a.williamson@intel.com>
    7.28 -
    7.29 -.SH "SEE ALSO"
    7.30 -xentrace(8), xentrace_format(1)
     8.1 --- a/tools/xentrace/xentrace_format	Wed May 12 09:12:53 2004 +0000
     8.2 +++ b/tools/xentrace/xentrace_format	Wed May 12 14:41:15 2004 +0000
     8.3 @@ -4,14 +4,15 @@
     8.4  
     8.5  # Program for reformatting trace buffer output according to user-supplied rules
     8.6  
     8.7 -import re, sys, string, signal
     8.8 +import re, sys, string, signal, struct
     8.9  
    8.10  def usage():
    8.11      print >> sys.stderr, \
    8.12            "Usage: " + sys.argv[0] + """ defs-file
    8.13 -          Parses trace data in ASCII format and reformats it according to the
    8.14 -          rules in a file of definitions.  The rules in this file should have
    8.15 -          the format ({ and } show grouping and are not part of the syntax):
    8.16 +          Parses trace data in binary format, as output by Xentrace and
    8.17 +          reformats it according to the rules in a file of definitions.  The
    8.18 +          rules in this file should have the format ({ and } show grouping
    8.19 +          and are not part of the syntax):
    8.20  
    8.21            {event_id}{whitespace}{text format string}
    8.22  
    8.23 @@ -68,31 +69,29 @@ interrupted = 0
    8.24  
    8.25  defs = read_defs(sys.argv[1])
    8.26  
    8.27 -reg = re.compile('(\d+) (\d+) (\d+) (.*)')
    8.28 +# structure of trace record + prepended CPU id (as output by xentrace):
    8.29 +# CPU(I) TSC(Q) EVENT(L) D1(L) D2(L) D3(L) D4(L) D5(L)
    8.30 +TRCREC = "IQLLLLLL"
    8.31  
    8.32  while not interrupted:
    8.33      try:
    8.34 -        line = sys.stdin.readline()
    8.35 +        line = sys.stdin.read(struct.calcsize(TRCREC))
    8.36          if not line:
    8.37              break
    8.38 -        
    8.39 -        m = reg.match(line)
    8.40  
    8.41 -        if not m: print >> sys.stderr, "Invalid input line."
    8.42 -
    8.43 -        s = string.split(m.group(4))
    8.44 +        (cpu, tsc, event, d1, d2, d3, d4, d5) = struct.unpack(TRCREC, line)
    8.45  
    8.46 -        args = {'cpu'   : eval(m.group(1)),
    8.47 -                'tsc'   : eval(m.group(2)),
    8.48 -                'event' : eval(m.group(3)) }
    8.49 +        args = {'cpu'   : cpu,
    8.50 +                'tsc'   : tsc,
    8.51 +                'event' : event,
    8.52 +                '1'     : d1,
    8.53 +                '2'     : d2,
    8.54 +                '3'     : d3,
    8.55 +                '4'     : d4,
    8.56 +                '5'     : d5    }
    8.57  
    8.58 -        i = 1
    8.59 -        for item in s:
    8.60 -            args[str(i)] = eval(item)
    8.61 -            i += 1
    8.62 -
    8.63 -        if defs.has_key(m.group(3)): print defs[m.group(3)] % args
    8.64 +        if defs.has_key(str(event)): print defs[str(event)] % args
    8.65          # silently skip lines we don't have a format for - a 'complain' option
    8.66          # should be added if needed
    8.67  
    8.68 -    except IOError: sys.exit()
    8.69 +    except IOError, struct.error: sys.exit()
     9.1 --- a/tools/xentrace/xentrace_format.1	Wed May 12 09:12:53 2004 +0000
     9.2 +++ b/tools/xentrace/xentrace_format.1	Wed May 12 14:41:15 2004 +0000
     9.3 @@ -8,9 +8,9 @@ xentrace_format \- pretty-print Xen trac
     9.4  ]
     9.5  .SH DESCRIPTION
     9.6  .B xentrace_format
     9.7 -parses trace data from standard input and reformats it according to
     9.8 -the rules in a file of definitions (\fIDEFS-FILE\fP), printing to
     9.9 -standard output.
    9.10 +parses trace data in \fBxentrace\fP binary format from standard input
    9.11 +and reformats it according to the rules in a file of definitions
    9.12 +(\fIDEFS-FILE\fP), printing to standard output.
    9.13  
    9.14  The rules in \fIDEFS-FILE\fP should have the format shown below:
    9.15  
    10.1 --- a/xen/arch/i386/entry.S	Wed May 12 09:12:53 2004 +0000
    10.2 +++ b/xen/arch/i386/entry.S	Wed May 12 14:41:15 2004 +0000
    10.3 @@ -151,7 +151,7 @@ NT_MASK		= 0x00004000
    10.4          movl %edx,%ds; \
    10.5          movl %edx,%es; \
    10.6          movl %edx,%fs; \
    10.7 -        movl %edx,%gs;
    10.8 +        movl %edx,%gs; \
    10.9          sti;
   10.10  
   10.11  #define GET_CURRENT(reg)   \