ia64/xen-unstable

annotate xen/include/xen/perfc.h @ 14081:644e9e18d2ef

Fix perfc=y build
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Thu Feb 22 14:58:26 2007 +0000 (2007-02-22)
parents d80684d19ef4
children 96f167771979
rev   line source
kaf24@1210 1
kaf24@1211 2 #ifndef __XEN_PERFC_H__
kaf24@1211 3 #define __XEN_PERFC_H__
kaf24@1210 4
kaf24@1444 5 #ifdef PERF_COUNTERS
kaf24@1274 6
kaf24@6497 7 #include <xen/lib.h>
Tim@14081 8 #include <xen/smp.h>
kaf24@1210 9 #include <asm/atomic.h>
kaf24@1210 10
kaf24@1210 11 /*
kaf24@1210 12 * NOTE: new counters must be defined in perfc_defn.h
kaf24@1210 13 *
kaf24@1210 14 * PERFCOUNTER (counter, string) define a new performance counter
kaf24@1210 15 * PERFCOUNTER_CPU (counter, string, size) define a counter per CPU
kaf24@1210 16 * PERFCOUNTER_ARRY (counter, string, size) define an array of counters
kaf24@1210 17 *
iap10@1221 18 * unlike "COUNTERS", "STATUS" variables DO NOT RESET
iap10@1221 19 * PERFSTATUS (counter, string) define a new performance stauts
iap10@1221 20 * PERFSTATUS_CPU (counter, string, size) define a status var per CPU
iap10@1221 21 * PERFSTATUS_ARRY (counter, string, size) define an array of status vars
iap10@1221 22 *
kaf24@1210 23 * unsigned long perfc_value (counter) get value of a counter
kaf24@1210 24 * unsigned long perfc_valuec (counter) get value of a per CPU counter
kaf24@1210 25 * unsigned long perfc_valuea (counter, index) get value of an array counter
kaf24@1210 26 * unsigned long perfc_set (counter, val) set value of a counter
kaf24@1210 27 * unsigned long perfc_setc (counter, val) set value of a per CPU counter
kaf24@1210 28 * unsigned long perfc_seta (counter, index, val) set value of an array counter
kaf24@1210 29 * void perfc_incr (counter) increment a counter
kaf24@1210 30 * void perfc_incrc (counter, index) increment a per CPU counter
kaf24@1210 31 * void perfc_incra (counter, index) increment an array counter
kaf24@1210 32 * void perfc_add (counter, value) add a value to a counter
kaf24@1210 33 * void perfc_addc (counter, value) add a value to a per CPU counter
kaf24@1210 34 * void perfc_adda (counter, index, value) add a value to array counter
kaf24@1210 35 * void perfc_print (counter) print out the counter
kaf24@1210 36 */
kaf24@1210 37
kaf24@1210 38 #define PERFCOUNTER( var, name ) \
kaf24@1210 39 atomic_t var[1];
kaf24@1210 40 #define PERFCOUNTER_CPU( var, name ) \
kaf24@1210 41 atomic_t var[NR_CPUS];
kaf24@1210 42 #define PERFCOUNTER_ARRAY( var, name, size ) \
kaf24@1210 43 atomic_t var[size];
iap10@1221 44 #define PERFSTATUS( var, name ) \
iap10@1221 45 atomic_t var[1];
iap10@1221 46 #define PERFSTATUS_CPU( var, name ) \
iap10@1221 47 atomic_t var[NR_CPUS];
iap10@1221 48 #define PERFSTATUS_ARRAY( var, name, size ) \
iap10@1221 49 atomic_t var[size];
kaf24@1210 50
kaf24@3918 51 struct perfcounter {
kaf24@1210 52 #include <xen/perfc_defn.h>
kaf24@1210 53 };
kaf24@1210 54
kaf24@3918 55 extern struct perfcounter perfcounters;
kaf24@1210 56
kaf24@1210 57 #define perfc_value(x) atomic_read(&perfcounters.x[0])
kaf24@1210 58 #define perfc_valuec(x) atomic_read(&perfcounters.x[smp_processor_id()])
kaf24@3958 59 #define perfc_valuea(x,y) \
kaf24@10213 60 ( (y) < (sizeof(perfcounters.x) / sizeof(*perfcounters.x)) ? \
kaf24@10213 61 atomic_read(&perfcounters.x[y]) : 0 )
kaf24@1210 62 #define perfc_set(x,v) atomic_set(&perfcounters.x[0], v)
kaf24@1210 63 #define perfc_setc(x,v) atomic_set(&perfcounters.x[smp_processor_id()], v)
kaf24@3958 64 #define perfc_seta(x,y,v) \
kaf24@3958 65 do { \
kaf24@3958 66 if ( (y) < (sizeof(perfcounters.x) / sizeof(*perfcounters.x)) ) \
kaf24@3958 67 atomic_set(&perfcounters.x[y], v); \
kaf24@3958 68 } while ( 0 )
kaf24@1210 69 #define perfc_incr(x) atomic_inc(&perfcounters.x[0])
iap10@1221 70 #define perfc_decr(x) atomic_dec(&perfcounters.x[0])
kaf24@1210 71 #define perfc_incrc(x) atomic_inc(&perfcounters.x[smp_processor_id()])
mafetter@4239 72 #define perfc_decrc(x) atomic_dec(&perfcounters.x[smp_processor_id()])
kaf24@3958 73 #define perfc_incra(x,y) \
kaf24@3958 74 do { \
kaf24@3958 75 if ( (y) < (sizeof(perfcounters.x) / sizeof(*perfcounters.x)) ) \
kaf24@3958 76 atomic_inc(&perfcounters.x[y]); \
kaf24@3958 77 } while ( 0 )
kaf24@1210 78 #define perfc_add(x,y) atomic_add((y), &perfcounters.x[0])
kaf24@1210 79 #define perfc_addc(x,y) atomic_add((y), &perfcounters.x[smp_processor_id()])
kaf24@3958 80 #define perfc_adda(x,y,z) \
kaf24@3958 81 do { \
kaf24@3958 82 if ( (y) < (sizeof(perfcounters.x) / sizeof(*perfcounters.x)) ) \
kaf24@3958 83 atomic_add((z), &perfcounters.x[y]); \
kaf24@3958 84 } while ( 0 )
kaf24@1210 85
kaf24@3958 86 /*
kaf24@3958 87 * Histogram: special treatment for 0 and 1 count. After that equally spaced
kaf24@3958 88 * with last bucket taking the rest.
kaf24@3958 89 */
kaf24@6497 90 #ifdef PERF_ARRAYS
kaf24@3958 91 #define perfc_incr_histo(_x,_v,_n) \
kaf24@3958 92 do { \
kaf24@3958 93 if ( (_v) == 0 ) \
kaf24@3958 94 perfc_incra(_x, 0); \
kaf24@3958 95 else if ( (_v) == 1 ) \
kaf24@3958 96 perfc_incra(_x, 1); \
kaf24@3958 97 else if ( (((_v)-2) / PERFC_ ## _n ## _BUCKET_SIZE) < \
kaf24@3958 98 (PERFC_MAX_ ## _n - 3) ) \
kaf24@3958 99 perfc_incra(_x, (((_v)-2) / PERFC_ ## _n ## _BUCKET_SIZE) + 2); \
kaf24@3958 100 else \
kaf24@3958 101 perfc_incra(_x, PERFC_MAX_ ## _n - 1); \
kaf24@3958 102 } while ( 0 )
mafetter@4823 103 #else
mafetter@4823 104 #define perfc_incr_histo(_x,_v,_n) ((void)0)
mafetter@4823 105 #endif
ack@13307 106
ack@13307 107 struct xen_sysctl_perfc_op;
ack@13307 108 int perfc_control(struct xen_sysctl_perfc_op *);
kaf24@3958 109
kaf24@1444 110 #else /* PERF_COUNTERS */
kaf24@1274 111
kaf24@1450 112 #define perfc_value(x) (0)
kaf24@1450 113 #define perfc_valuec(x) (0)
kaf24@1450 114 #define perfc_valuea(x,y) (0)
kaf24@1274 115 #define perfc_set(x,v) ((void)0)
kaf24@1274 116 #define perfc_setc(x,v) ((void)0)
kaf24@1274 117 #define perfc_seta(x,y,v) ((void)0)
kaf24@1274 118 #define perfc_incr(x) ((void)0)
kaf24@1274 119 #define perfc_decr(x) ((void)0)
kaf24@1274 120 #define perfc_incrc(x) ((void)0)
kaf24@4484 121 #define perfc_decrc(x) ((void)0)
kaf24@1274 122 #define perfc_incra(x,y) ((void)0)
kaf24@4484 123 #define perfc_decra(x,y) ((void)0)
kaf24@1274 124 #define perfc_add(x,y) ((void)0)
kaf24@1274 125 #define perfc_addc(x,y) ((void)0)
kaf24@1274 126 #define perfc_adda(x,y,z) ((void)0)
kaf24@3958 127 #define perfc_incr_histo(x,y,z) ((void)0)
kaf24@1274 128
kaf24@1444 129 #endif /* PERF_COUNTERS */
kaf24@1274 130
kaf24@1211 131 #endif /* __XEN_PERFC_H__ */