ia64/xen-unstable

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