ia64/xen-unstable

view xen/include/xen/perfc.h @ 14594:96f167771979

xen: Make all performance counter per-cpu, avoiding the need to update
them with atomic (locked) ops.

Conversion here isn't complete in the sense that many places still use
the old per-CPU accessors (which are now redundant). Since the patch
is already rather big, I'd prefer replacing those in a subsequent
patch.

While doing this, I also converted x86's multicall macros to no longer
require inclusion of asm-offsets.h in the respective C file (on IA64
the use of asm-offsets.h in C sources seems more wide spread, hence
there I rather used IA64_ prefixes for the otherwise conflicting
performance counter indices).

On x86, a few counter increments get moved a little, to avoid
duplicate counting of preempted hypercalls.

Also, a few counters are being added.

IA64 changes only compile-tested, hence somebody doing active IA64
work may want to have a close look at those changes.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author kfraser@localhost.localdomain
date Tue Mar 27 16:35:37 2007 +0100 (2007-03-27)
parents 644e9e18d2ef
children ea0b50ca4999
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 <xen/percpu.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_ARRAY (counter, string, size) define an array of counters
16 *
17 * unlike "COUNTERS", "STATUS" variables DO NOT RESET
18 * PERFSTATUS (counter, string) define a new performance stauts
19 * PERFSTATUS_ARRAY (counter, string, size) define an array of status vars
20 *
21 * unsigned long perfc_value (counter) get value of a counter
22 * unsigned long perfc_valuea (counter, index) get value of an array counter
23 * unsigned long perfc_set (counter, val) set value of a counter
24 * unsigned long perfc_seta (counter, index, val) set value of an array counter
25 * void perfc_incr (counter) increment a counter
26 * void perfc_decr (counter) decrement a status
27 * void perfc_incra (counter, index) increment an array counter
28 * void perfc_add (counter, value) add a value to a counter
29 * void perfc_adda (counter, index, value) add a value to array counter
30 * void perfc_print (counter) print out the counter
31 */
33 #define PERFCOUNTER( name, descr ) \
34 PERFC_ ## name,
35 #define PERFCOUNTER_ARRAY( name, descr, size ) \
36 PERFC_ ## name, \
37 PERFC_LAST_ ## name = PERFC_ ## name + (size) - sizeof(char[2 * !!(size) - 1]),
39 #define PERFSTATUS PERFCOUNTER
40 #define PERFSTATUS_ARRAY PERFCOUNTER_ARRAY
42 /* Compatibility: This should go away once all users got converted. */
43 #define PERFCOUNTER_CPU PERFCOUNTER
45 enum perfcounter {
46 #include <xen/perfc_defn.h>
47 NUM_PERFCOUNTERS
48 };
50 #undef PERFCOUNTER
51 #undef PERFCOUNTER_ARRAY
52 #undef PERFSTATUS
53 #undef PERFSTATUS_ARRAY
55 typedef unsigned perfc_t;
56 #define PRIperfc ""
58 DECLARE_PER_CPU(perfc_t[NUM_PERFCOUNTERS], perfcounters);
60 #define perfc_value(x) this_cpu(perfcounters)[PERFC_ ## x]
61 #define perfc_valuea(x,y) \
62 ( (y) <= PERFC_LAST_ ## x - PERFC_ ## x ? \
63 this_cpu(perfcounters)[PERFC_ ## x + (y)] : 0 )
64 #define perfc_set(x,v) (this_cpu(perfcounters)[PERFC_ ## x] = (v))
65 #define perfc_seta(x,y,v) \
66 ( (y) <= PERFC_LAST_ ## x - PERFC_ ## x ? \
67 this_cpu(perfcounters)[PERFC_ ## x + (y)] = (v) : (v) )
68 #define perfc_incr(x) (++this_cpu(perfcounters)[PERFC_ ## x])
69 #define perfc_decr(x) (--this_cpu(perfcounters)[PERFC_ ## x])
70 #define perfc_incra(x,y) \
71 ( (y) <= PERFC_LAST_ ## x - PERFC_ ## x ? \
72 ++this_cpu(perfcounters)[PERFC_ ## x + (y)] : 0 )
73 #define perfc_add(x,v) (this_cpu(perfcounters)[PERFC_ ## x] += (v))
74 #define perfc_adda(x,y,v) \
75 ( (y) <= PERFC_LAST_ ## x - PERFC_ ## x ? \
76 this_cpu(perfcounters)[PERFC_ ## x + (y)] = (v) : (v) )
78 /*
79 * Histogram: special treatment for 0 and 1 count. After that equally spaced
80 * with last bucket taking the rest.
81 */
82 #ifdef PERF_ARRAYS
83 #define perfc_incr_histo(x,v) \
84 do { \
85 if ( (v) == 0 ) \
86 perfc_incra(x, 0); \
87 else if ( (v) == 1 ) \
88 perfc_incra(x, 1); \
89 else if ( (((v) - 2) / PERFC_ ## x ## _BUCKET_SIZE) < \
90 (PERFC_LAST_ ## x - PERFC_ ## x - 2) ) \
91 perfc_incra(x, (((v) - 2) / PERFC_ ## x ## _BUCKET_SIZE) + 2); \
92 else \
93 perfc_incra(x, PERFC_LAST_ ## x - PERFC_ ## x); \
94 } while ( 0 )
95 #else
96 #define perfc_incr_histo(x,v) ((void)0)
97 #endif
99 struct xen_sysctl_perfc_op;
100 int perfc_control(struct xen_sysctl_perfc_op *);
102 #else /* PERF_COUNTERS */
104 #define perfc_value(x) (0)
105 #define perfc_valuea(x,y) (0)
106 #define perfc_set(x,v) ((void)0)
107 #define perfc_seta(x,y,v) ((void)0)
108 #define perfc_incr(x) ((void)0)
109 #define perfc_decr(x) ((void)0)
110 #define perfc_incra(x,y) ((void)0)
111 #define perfc_decra(x,y) ((void)0)
112 #define perfc_add(x,y) ((void)0)
113 #define perfc_adda(x,y,z) ((void)0)
114 #define perfc_incr_histo(x,y,z) ((void)0)
116 #endif /* PERF_COUNTERS */
118 /* Compatibility: This should go away once all users got converted. */
119 #define perfc_incrc perfc_incr
121 #endif /* __XEN_PERFC_H__ */