ia64/xen-unstable
changeset 1116:8829a6af2d2c
bitkeeper revision 1.743 (403b37106MV2R0Wr2iE98QHJWFPRMw)
trace.h, dom0_ops.h, trace.c, setup.c, xentrace.c, Makefile:
Cleanups to new trace code.
trace.h, dom0_ops.h, trace.c, setup.c, xentrace.c, Makefile:
Cleanups to new trace code.
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Tue Feb 24 11:35:44 2004 +0000 (2004-02-24) |
parents | bc02f2f73b0e |
children | ff30aea0a126 |
files | tools/xentrace/Makefile tools/xentrace/xentrace.c xen/arch/i386/setup.c xen/common/trace.c xen/include/hypervisor-ifs/dom0_ops.h xen/include/xeno/trace.h |
line diff
1.1 --- a/tools/xentrace/Makefile Tue Feb 24 11:00:58 2004 +0000 1.2 +++ b/tools/xentrace/Makefile Tue Feb 24 11:35:44 2004 +0000 1.3 @@ -29,4 +29,4 @@ clean: 1.4 $(RM) *.a *.so *.o *.rpm $(BIN) 1.5 1.6 %: %.c $(HDRS) Makefile 1.7 - $(CC) $(CFLAGS) -o $@ $< -lxc 1.8 + $(CC) $(CFLAGS) -o $@ $< -L../xc/lib -lxc
2.1 --- a/tools/xentrace/xentrace.c Tue Feb 24 11:00:58 2004 +0000 2.2 +++ b/tools/xentrace/xentrace.c Tue Feb 24 11:35:44 2004 +0000 2.3 @@ -1,5 +1,4 @@ 2.4 /****************************************************************************** 2.5 - * 2.6 * tools/xentrace/xentrace.c 2.7 * 2.8 * Tool for collecting trace buffer data from Xen. 2.9 @@ -8,8 +7,7 @@ 2.10 * 2.11 * Author: Mark Williamson, mark.a.williamson@intel.com 2.12 * Date: February 2004 2.13 - * 2.14 - *****************************************************************************/ 2.15 + */ 2.16 2.17 #include <time.h> 2.18 #include <stdlib.h> 2.19 @@ -25,7 +23,6 @@ 2.20 2.21 #include "../xc/lib/xc_private.h" 2.22 2.23 -#define TRACE_BUFFER /* need to define this for trace.h */ 2.24 #include <xeno/trace.h> 2.25 2.26 extern FILE *stdout; 2.27 @@ -99,7 +96,7 @@ void print_rec(unsigned int cpu, struct 2.28 * be dereferenced immediately, since it is a physical address of memory in Xen 2.29 * space - they are used in this program to mmap the right area from /dev/mem. 2.30 */ 2.31 -struct t_buf *get_tbuf_ptrs() 2.32 +unsigned long get_tbuf_ptrs(void) 2.33 { 2.34 int ret; 2.35 dom0_op_t op; /* dom0 op we'll build */ 2.36 @@ -112,7 +109,8 @@ struct t_buf *get_tbuf_ptrs() 2.37 2.38 xc_interface_close(xc_handle); 2.39 2.40 - if(ret) { 2.41 + if ( ret != 0 ) 2.42 + { 2.43 PERROR("Failure to get trace buffer pointer from Xen"); 2.44 exit(EXIT_FAILURE); 2.45 } 2.46 @@ -128,14 +126,14 @@ struct t_buf *get_tbuf_ptrs() 2.47 * address space by memory mapping /dev/mem. Returns a pointer to the location 2.48 * the buffers have been mapped to. 2.49 */ 2.50 -struct t_buf *map_tbufs(struct t_buf *tbufs_phys) 2.51 +struct t_buf *map_tbufs(unsigned long tbufs_phys) 2.52 { 2.53 int dm_fd; /* file descriptor for /dev/mem */ 2.54 struct t_buf *tbufs_mapped; 2.55 2.56 dm_fd = open("/dev/mem", O_RDONLY); 2.57 - 2.58 - if(dm_fd < 0) { 2.59 + if ( dm_fd < 0 ) 2.60 + { 2.61 PERROR("Open /dev/mem when mapping trace buffers\n"); 2.62 exit(EXIT_FAILURE); 2.63 } 2.64 @@ -146,7 +144,8 @@ struct t_buf *map_tbufs(struct t_buf *tb 2.65 2.66 close(dm_fd); 2.67 2.68 - if(tbufs_mapped == MAP_FAILED) { 2.69 + if ( tbufs_mapped == MAP_FAILED ) 2.70 + { 2.71 PERROR("Failed to mmap trace buffers"); 2.72 exit(EXIT_FAILURE); 2.73 } 2.74 @@ -168,15 +167,15 @@ struct t_buf **init_bufs_ptrs(void *bufs 2.75 struct t_buf **user_ptrs; 2.76 2.77 user_ptrs = (struct t_buf **)calloc(opts.num_cpus, sizeof(struct t_buf *)); 2.78 - 2.79 - if(!user_ptrs) { 2.80 + if ( user_ptrs == NULL ) 2.81 + { 2.82 PERROR( "Failed to allocate memory for buffer pointers\n"); 2.83 exit(EXIT_FAILURE); 2.84 } 2.85 2.86 /* initialise pointers to the trace buffers - given the size of a trace 2.87 * buffer and the value of bufs_maped, we can easily calculate these */ 2.88 - for(i = 0; i<opts.num_cpus; i++) 2.89 + for ( i = 0; i<opts.num_cpus; i++ ) 2.90 user_ptrs[i] = (struct t_buf *)( 2.91 (unsigned long)bufs_mapped + TB_SIZE * i); 2.92 2.93 @@ -194,7 +193,7 @@ struct t_buf **init_bufs_ptrs(void *bufs 2.94 * mapped in user space. Note that the trace buffer metadata contains physical 2.95 * pointers - the array returned allows more convenient access to them. 2.96 */ 2.97 -struct t_rec **init_rec_ptrs(struct t_buf *tbufs_phys, 2.98 +struct t_rec **init_rec_ptrs(unsigned long tbufs_phys, 2.99 struct t_buf *tbufs_mapped, 2.100 struct t_buf **meta) 2.101 { 2.102 @@ -202,19 +201,15 @@ struct t_rec **init_rec_ptrs(struct t_bu 2.103 struct t_rec **data; 2.104 2.105 data = calloc(opts.num_cpus, sizeof(struct t_rec *)); 2.106 - 2.107 - if(!data) { 2.108 - PERROR( "Failed to allocate memory for data pointers\n"); 2.109 + if ( data == NULL ) 2.110 + { 2.111 + PERROR("Failed to allocate memory for data pointers\n"); 2.112 exit(EXIT_FAILURE); 2.113 } 2.114 2.115 - for(i = 0; i<opts.num_cpus; i++) { 2.116 - data[i] = (struct t_rec *)( 2.117 - (unsigned long)meta[i]->data 2.118 - - (unsigned long)tbufs_phys 2.119 - + (unsigned long)tbufs_mapped 2.120 - ); 2.121 - } 2.122 + for ( i = 0; i<opts.num_cpus; i++ ) 2.123 + data[i] = (struct t_rec *)((unsigned long)meta[i]->data - 2.124 + tbufs_phys + (unsigned long)tbufs_mapped); 2.125 2.126 return data; 2.127 } 2.128 @@ -232,12 +227,13 @@ int *init_tail_idxs(struct t_buf **bufs) 2.129 int i; 2.130 int *tails = calloc(opts.num_cpus, sizeof(unsigned int)); 2.131 2.132 - if(!tails) { 2.133 + if ( tails == NULL ) 2.134 + { 2.135 PERROR("Failed to allocate memory for tail pointers\n"); 2.136 exit(EXIT_FAILURE); 2.137 } 2.138 2.139 - for(i = 0; i<opts.num_cpus; i++) 2.140 + for ( i = 0; i<opts.num_cpus; i++ ) 2.141 tails[i] = bufs[i]->head; 2.142 2.143 return tails; 2.144 @@ -256,7 +252,7 @@ int monitor_tbufs(FILE *logfile) 2.145 struct t_rec **data; /* pointers to the trace buffer data areas 2.146 * where they are mapped into user space. */ 2.147 int *tails; /* store tail indexes for the trace buffers */ 2.148 - struct t_buf *tbufs_phys; /* physical address of the tbufs */ 2.149 + unsigned long tbufs_phys; /* physical address of the tbufs */ 2.150 2.151 /* setup access to trace buffers */ 2.152 tbufs_phys = get_tbuf_ptrs(); 2.153 @@ -268,18 +264,22 @@ int monitor_tbufs(FILE *logfile) 2.154 tails = init_tail_idxs (meta); 2.155 2.156 /* now, scan buffers for events */ 2.157 - while(!interrupted) { 2.158 - for(i = 0; i < opts.num_cpus; i++) { 2.159 + while ( !interrupted ) 2.160 + { 2.161 + for ( i = 0; i < opts.num_cpus; i++ ) 2.162 + { 2.163 signed long newdata = meta[i]->head - tails[i]; 2.164 signed long prewrap = newdata; 2.165 2.166 /* correct newdata and prewrap in case of a pointer wrap */ 2.167 - if(newdata < 0) { 2.168 + if ( newdata < 0 ) 2.169 + { 2.170 newdata += meta[i]->size; 2.171 prewrap = meta[i]->size - tails[i]; 2.172 } 2.173 2.174 - if(newdata >= opts.new_data_thresh) { 2.175 + if ( newdata >= opts.new_data_thresh ) 2.176 + { 2.177 /* output pre-wrap data */ 2.178 for(j = 0; j < prewrap; j++) 2.179 print_rec(i, data[i] + tails[i] + j, logfile); 2.180 @@ -316,22 +316,23 @@ error_t cmd_parser(int key, char *arg, s 2.181 { 2.182 settings_t *setup = (settings_t *)state->input; 2.183 2.184 - switch(key) 2.185 + switch ( key ) 2.186 { 2.187 case 't': /* set new records threshold for logging */ 2.188 { 2.189 char *inval; 2.190 setup->new_data_thresh = strtol(arg, &inval, 0); 2.191 - if(inval == arg) argp_usage(state); 2.192 + if ( inval == arg ) 2.193 + argp_usage(state); 2.194 } 2.195 - 2.196 break; 2.197 2.198 case 's': /* set sleep time (given in milliseconds) */ 2.199 { 2.200 char *inval; 2.201 setup->poll_sleep = millis_to_timespec(strtol(arg, &inval, 0)); 2.202 - if(inval == arg) argp_usage(state); 2.203 + if ( inval == arg ) 2.204 + argp_usage(state); 2.205 } 2.206 break; 2.207 2.208 @@ -339,16 +340,19 @@ error_t cmd_parser(int key, char *arg, s 2.209 { 2.210 char *inval; 2.211 setup->num_cpus = strtol(arg, &inval, 0); 2.212 - if(inval == arg) argp_usage(state); 2.213 + if (inval == arg ) 2.214 + argp_usage(state); 2.215 } 2.216 break; 2.217 2.218 case ARGP_KEY_ARG: 2.219 - if(state->arg_num == 0) 2.220 + { 2.221 + if ( state->arg_num == 0 ) 2.222 setup->outfile = arg; 2.223 else 2.224 argp_usage(state); 2.225 - break; 2.226 + } 2.227 + break; 2.228 2.229 default: 2.230 return ARGP_ERR_UNKNOWN; 2.231 @@ -413,9 +417,8 @@ int main(int argc, char **argv) 2.232 2.233 argp_parse(&parser_def, argc, argv, 0, 0, &opts); 2.234 2.235 - if(opts.outfile) { 2.236 + if ( opts.outfile ) 2.237 logfile = fopen(opts.outfile, "w"); 2.238 - } 2.239 2.240 /* ensure that if we get a signal, we'll do cleanup, then exit */ 2.241 sigaction(SIGHUP, &act, 0);
3.1 --- a/xen/arch/i386/setup.c Tue Feb 24 11:00:58 2004 +0000 3.2 +++ b/xen/arch/i386/setup.c Tue Feb 24 11:35:44 2004 +0000 3.3 @@ -451,7 +451,5 @@ void __init start_of_day(void) 3.4 3.5 watchdog_on = 1; 3.6 3.7 -#ifdef TRACE_BUFFER 3.8 - init_trace_bufs(); /* initialise trace buffers */ 3.9 -#endif 3.10 + init_trace_bufs(); 3.11 }
4.1 --- a/xen/common/trace.c Tue Feb 24 11:00:58 2004 +0000 4.2 +++ b/xen/common/trace.c Tue Feb 24 11:35:44 2004 +0000 4.3 @@ -1,5 +1,4 @@ 4.4 /****************************************************************************** 4.5 - * 4.6 * common/trace.c 4.7 * 4.8 * Xen Trace Buffer 4.9 @@ -15,12 +14,11 @@ 4.10 * 4.11 * See also include/xeno/trace.h and the dom0 op in 4.12 * include/hypervisor-ifs/dom0_ops.h 4.13 - * 4.14 - *****************************************************************************/ 4.15 + */ 4.16 4.17 #include <xeno/config.h> 4.18 4.19 -#ifdef TRACE_BUFFER /* don't compile this stuff in unless explicitly enabled */ 4.20 +#ifdef TRACE_BUFFER 4.21 4.22 #include <asm/timex.h> 4.23 #include <asm/types.h> 4.24 @@ -33,14 +31,11 @@ 4.25 #include <xeno/trace.h> 4.26 #include <asm/atomic.h> 4.27 4.28 - 4.29 - 4.30 /* Pointers to the meta-data objects for all system trace buffers */ 4.31 struct t_buf *t_bufs[NR_CPUS]; 4.32 4.33 /* a flag recording whether initialisation has been done */ 4.34 -atomic_t tb_init_done = ATOMIC_INIT(0); 4.35 - 4.36 +int tb_init_done = 0; 4.37 4.38 /** 4.39 * init_trace_bufs - performs initialisation of the per-cpu trace buffers. 4.40 @@ -49,55 +44,52 @@ atomic_t tb_init_done = ATOMIC_INIT(0); 4.41 * trace buffers. The trace buffers are then available for debugging use, via 4.42 * the %TRACE_xD macros exported in <xeno/trace.h>. 4.43 */ 4.44 -void init_trace_bufs() 4.45 +void init_trace_bufs(void) 4.46 { 4.47 - int i; 4.48 - void *d; /* trace buffer area pointer */ 4.49 + int i; 4.50 + char *rawbuf; 4.51 + struct t_buf *buf; 4.52 4.53 - d = kmalloc(smp_num_cpus * TB_SIZE, GFP_KERNEL); 4.54 - 4.55 - if( d == NULL ) { 4.56 + if ( (rawbuf = kmalloc(smp_num_cpus * TB_SIZE, GFP_KERNEL)) == NULL ) 4.57 + { 4.58 printk("Xen trace buffers: memory allocation failed\n"); 4.59 return; 4.60 } 4.61 4.62 - for(i = 0; i < smp_num_cpus; i++) { 4.63 - struct t_buf *buf = t_bufs[i] 4.64 - = (struct t_buf *)( (unsigned int)d + TB_SIZE * i ); 4.65 + for ( i = 0; i < smp_num_cpus; i++ ) 4.66 + { 4.67 + buf = t_bufs[i] = (struct t_buf *)&rawbuf[i*TB_SIZE]; 4.68 4.69 - /* for use in Xen */ 4.70 - buf->vdata = (struct t_rec *) 4.71 - ( (unsigned int)buf + sizeof(struct t_buf) ); 4.72 + /* For use in Xen. */ 4.73 + buf->vdata = (struct t_rec *)(buf+1); 4.74 buf->head_ptr = buf->vdata; 4.75 - spin_lock_init(&buf->lock); 4.76 + spin_lock_init(&buf->lock); 4.77 4.78 - /* for use in user space */ 4.79 + /* For use in user space. */ 4.80 buf->data = (struct t_rec *)__pa(buf->vdata); 4.81 - buf->head = 0; 4.82 + buf->head = 0; 4.83 4.84 - /* for use in both */ 4.85 - buf->size = (TB_SIZE - sizeof(struct t_buf)) / sizeof(struct t_rec); 4.86 + /* For use in both. */ 4.87 + buf->size = (TB_SIZE - sizeof(struct t_buf)) / sizeof(struct t_rec); 4.88 } 4.89 4.90 printk("Xen trace buffers: initialised\n"); 4.91 4.92 wmb(); /* above must be visible before tb_init_done flag set */ 4.93 4.94 - atomic_set(&tb_init_done, 1); 4.95 + tb_init_done = 1; 4.96 } 4.97 4.98 - 4.99 - 4.100 /** 4.101 * get_tb_ptr - return physical address of the trace buffers. 4.102 * 4.103 * Called by the %DOM0_GETTBUFS dom0 op to fetch the physical address of the 4.104 * trace buffers. 4.105 */ 4.106 -struct t_buf *get_tb_ptr() 4.107 +unsigned long get_tb_ptr(void) 4.108 { 4.109 - /* a physical address (user space maps this using /dev/mem) */ 4.110 - return (struct t_buf *)__pa(t_bufs[0]); 4.111 + /* Return the physical address. */ 4.112 + return __pa(t_bufs[0]); 4.113 } 4.114 4.115 -#endif /* #ifdef TRACE_BUFFER */ 4.116 +#endif /* TRACE_BUFFER */
5.1 --- a/xen/include/hypervisor-ifs/dom0_ops.h Tue Feb 24 11:00:58 2004 +0000 5.2 +++ b/xen/include/hypervisor-ifs/dom0_ops.h Tue Feb 24 11:35:44 2004 +0000 5.3 @@ -215,7 +215,7 @@ typedef struct dom0_pincpudomain_st 5.4 typedef struct dom0_gettbufs_st 5.5 { 5.6 /* OUT variable - location of the trace buffers */ 5.7 - struct t_buf *phys_addr; 5.8 + unsigned long phys_addr; 5.9 } dom0_gettbufs_t; 5.10 5.11 typedef struct dom0_op_st 5.12 @@ -244,8 +244,4 @@ typedef struct dom0_op_st 5.13 } u; 5.14 } dom0_op_t; 5.15 5.16 - 5.17 - 5.18 - 5.19 - 5.20 -#endif 5.21 +#endif /* __DOM0_OPS_H__ */
6.1 --- a/xen/include/xeno/trace.h Tue Feb 24 11:00:58 2004 +0000 6.2 +++ b/xen/include/xeno/trace.h Tue Feb 24 11:35:44 2004 +0000 6.3 @@ -1,5 +1,4 @@ 6.4 /****************************************************************************** 6.5 - * 6.6 * include/xeno/trace.h 6.7 * 6.8 * Xen Trace Buffer 6.9 @@ -17,15 +16,45 @@ 6.10 * trace buffer contents can then be performed using a userland tool. 6.11 * 6.12 * See also common/trace.c and the dom0 op in include/hypervisor-ifs/dom0_ops.h 6.13 - * 6.14 - *****************************************************************************/ 6.15 - 6.16 -#ifdef TRACE_BUFFER 6.17 + */ 6.18 6.19 #ifndef __XENO_TRACE_H__ 6.20 #define __XENO_TRACE_H__ 6.21 6.22 +/* 6.23 + * How much space is allowed for a single trace buffer, including data and 6.24 + * metadata (and maybe some waste). 6.25 + */ 6.26 +#define TB_SIZE PAGE_SIZE 6.27 + 6.28 +/* This structure represents a single trace buffer record. */ 6.29 +struct t_rec { 6.30 + u64 cycles; /* 64 bit cycle counter timestamp */ 6.31 + u32 event; /* 32 bit event ID */ 6.32 + u32 d1, d2, d3, d4, d5; /* event data items */ 6.33 +}; 6.34 + 6.35 +/* 6.36 + * This structure contains the metadata for a single trace buffer. The head 6.37 + * field, indexes into an array of struct t_rec's. 6.38 + */ 6.39 +struct t_buf { 6.40 + struct t_rec *data; /* pointer to data area. physical address 6.41 + * for convenience in user space code */ 6.42 + 6.43 + unsigned int size; /* size of the data area, in t_recs */ 6.44 + unsigned int head; /* array index of the most recent record */ 6.45 + 6.46 #ifdef __KERNEL__ 6.47 + struct t_rec *head_ptr; /* pointer to the head record */ 6.48 + struct t_rec *vdata; /* virtual address pointer to data */ 6.49 + spinlock_t lock; /* ensure mutually exlusive access (for inserts) */ 6.50 +#endif 6.51 + 6.52 + /* never add anything here - the kernel stuff must be the last elements */ 6.53 +}; 6.54 + 6.55 +#ifdef TRACE_BUFFER 6.56 6.57 #include <xeno/spinlock.h> 6.58 #include <asm/page.h> 6.59 @@ -35,50 +64,11 @@ 6.60 #include <asm/current.h> 6.61 #include <asm/msr.h> 6.62 6.63 -#endif /* #ifdef __KERNEL__ */ 6.64 - 6.65 -/****************************************************************************** 6.66 - * Data structure declarations 6.67 - *****************************************************************************/ 6.68 - 6.69 -/* This structure represents a single trace buffer record. */ 6.70 -struct t_rec { 6.71 - u64 cycles; /* 64 bit cycle counter timestamp */ 6.72 - u32 event; /* 32 bit event ID */ 6.73 - u32 d1, d2, d3, d4, d5; /* event data items */ 6.74 -}; 6.75 - 6.76 -/* This structure contains the metadata for a single trace buffer. The head 6.77 - * field, indexes into an array of struct t_rec's. 6.78 - */ 6.79 -struct t_buf { 6.80 - struct t_rec *data; /* pointer to data area. physical address 6.81 - * for convenience in user space code */ 6.82 - 6.83 - unsigned int size; /* size of the data area, in t_recs */ 6.84 - unsigned int head; /* array index of the most recent record */ 6.85 - 6.86 -#ifdef __KERNEL__ 6.87 - struct t_rec *head_ptr; /* pointer to the head record */ 6.88 - struct t_rec *vdata; /* virtual address pointer to data, 6.89 - * for use in Xen */ 6.90 - spinlock_t lock; /* ensure mutually exlusive access (for inserts) */ 6.91 -#endif /* #ifdef __KERNEL__ */ 6.92 - 6.93 - /* never add anything here - the kernel stuff must be the last elements */ 6.94 -}; 6.95 - 6.96 -/****************************************************************************** 6.97 - * Functions 6.98 - *****************************************************************************/ 6.99 - 6.100 -#ifdef __KERNEL__ 6.101 - 6.102 /* Used to initialise trace buffer functionality */ 6.103 -void init_trace_bufs(); 6.104 +void init_trace_bufs(void); 6.105 6.106 /* used to retrieve the physical address of the trace buffers */ 6.107 -struct t_buf *get_tb_ptr(); 6.108 +struct t_buf *get_tb_ptr(void); 6.109 6.110 /** 6.111 * trace - Enters a trace tuple into the trace buffer for the current CPU. 6.112 @@ -92,19 +82,19 @@ struct t_buf *get_tb_ptr(); 6.113 static inline int trace(u32 event, u32 d1, u32 d2, u32 d3, u32 d4, u32 d5) 6.114 { 6.115 extern struct t_buf *t_bufs[]; /* global array of pointers to bufs */ 6.116 - extern atomic_t tb_init_done; /* set when buffers are initialised */ 6.117 + extern int tb_init_done; /* set when buffers are initialised */ 6.118 unsigned long flags; /* for saving interrupt flags */ 6.119 struct t_buf *buf; /* the buffer we're working on */ 6.120 struct t_rec *rec; /* next record to fill out */ 6.121 6.122 6.123 - if(!atomic_read(&tb_init_done)) return -1; 6.124 + if ( !tb_init_done ) 6.125 + return -1; 6.126 6.127 buf = t_bufs[smp_processor_id()]; 6.128 rec = buf->head_ptr; 6.129 6.130 spin_lock_irqsave(&buf->lock, flags); 6.131 - /* interrupts _disabled locally_ during the following code */ 6.132 6.133 rdtscll(rec->cycles); 6.134 rec->event = event; 6.135 @@ -116,45 +106,32 @@ static inline int trace(u32 event, u32 d 6.136 6.137 wmb(); /* above must be visible before reader sees index updated */ 6.138 6.139 - if( likely( buf->head_ptr < ( buf->vdata + buf->size - 1) ) ) { 6.140 + if ( likely(buf->head_ptr < (buf->vdata + buf->size - 1)) ) 6.141 + { 6.142 buf->head_ptr++; 6.143 buf->head++; 6.144 - } else { 6.145 - buf->head = 0; 6.146 + } 6.147 + else 6.148 + { 6.149 + buf->head = 0; 6.150 buf->head_ptr = buf->vdata; 6.151 } 6.152 6.153 spin_unlock_irqrestore(&buf->lock, flags); 6.154 - /* Interrupts now _re-enabled locally_ */ 6.155 6.156 return 0; 6.157 } 6.158 6.159 - 6.160 -#endif /* #ifdef __KERNEL__ */ 6.161 - 6.162 - 6.163 -/****************************************************************************** 6.164 - * Macros 6.165 - *****************************************************************************/ 6.166 - 6.167 -/* How much space is allowed for a single trace buffer, including data and 6.168 - * metadata (and maybe some waste). 6.169 - */ 6.170 -#define TB_SIZE PAGE_SIZE 6.171 - 6.172 -#ifdef __KERNEL__ 6.173 - 6.174 -/* avoids troubling the caller with casting their arguments to a trace macro */ 6.175 +/* Avoids troubling the caller with casting their arguments to a trace macro */ 6.176 #define trace_do_casts(e,d1,d2,d3,d4,d5) \ 6.177 trace(e, \ 6.178 - (unsigned long)d1, \ 6.179 - (unsigned long)d2, \ 6.180 - (unsigned long)d3, \ 6.181 - (unsigned long)d4, \ 6.182 - (unsigned long)d5) 6.183 + (unsigned long)d1, \ 6.184 + (unsigned long)d2, \ 6.185 + (unsigned long)d3, \ 6.186 + (unsigned long)d4, \ 6.187 + (unsigned long)d5) 6.188 6.189 -/* convenience macros for calling the trace function */ 6.190 +/* Convenience macros for calling the trace function. */ 6.191 #define TRACE_0D(event) trace_do_casts(event,0, 0, 0, 0, 0 ) 6.192 #define TRACE_1D(event,d) trace_do_casts(event,d, 0, 0, 0, 0 ) 6.193 #define TRACE_2D(event,d1,d2) trace_do_casts(event,d1,d2,0, 0, 0 ) 6.194 @@ -162,13 +139,10 @@ static inline int trace(u32 event, u32 d 6.195 #define TRACE_4D(event,d1,d2,d3,d4) trace_do_casts(event,d1,d2,d3,d4,0 ) 6.196 #define TRACE_5D(event,d1,d2,d3,d4,d5) trace_do_casts(event,d1,d2,d3,d4,d5) 6.197 6.198 -#endif /* #ifdef __KERNEL__ */ 6.199 - 6.200 -#endif /* #ifndef __XENO_TRACE_H__ */ 6.201 +#else 6.202 6.203 -#else /* #ifdef TRACE_BUFFER */ 6.204 +#define init_trace_bufs() ((void)0) 6.205 6.206 -/* define out macros so that they can be left in code when tracing is disabled */ 6.207 #define TRACE_0D(event) ((void)0) 6.208 #define TRACE_1D(event,d) ((void)0) 6.209 #define TRACE_2D(event,d1,d2) ((void)0) 6.210 @@ -176,4 +150,6 @@ static inline int trace(u32 event, u32 d 6.211 #define TRACE_4D(event,d1,d2,d3,d4) ((void)0) 6.212 #define TRACE_5D(event,d1,d2,d3,d4,d5) ((void)0) 6.213 6.214 -#endif /* #ifdef TRACE_BUFFER */ 6.215 +#endif /* TRACE_BUFFER */ 6.216 + 6.217 +#endif /* __XENO_TRACE_H__ */