FreeBSD/Linux Kernel Cross Reference
sys/sys/evcnt.h
1 /* $NetBSD: evcnt.h,v 1.3 2006/08/28 00:16:54 christos Exp $ */
2
3 /*
4 * Copyright (c) 1996, 2000 Christopher G. Demetriou
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed for the
18 * NetBSD Project. See http://www.NetBSD.org/ for
19 * information about NetBSD.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 * --(license Id: LICENSE.proto,v 1.1 2000/06/13 21:40:26 cgd Exp )--
35 */
36
37 /*
38 * Copyright (c) 1992, 1993
39 * The Regents of the University of California. All rights reserved.
40 *
41 * This software was developed by the Computer Systems Engineering group
42 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
43 * contributed to Berkeley.
44 *
45 * All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by the University of
48 * California, Lawrence Berkeley Laboratories.
49 *
50 * Redistribution and use in source and binary forms, with or without
51 * modification, are permitted provided that the following conditions
52 * are met:
53 * 1. Redistributions of source code must retain the above copyright
54 * notice, this list of conditions and the following disclaimer.
55 * 2. Redistributions in binary form must reproduce the above copyright
56 * notice, this list of conditions and the following disclaimer in the
57 * documentation and/or other materials provided with the distribution.
58 * 3. Neither the name of the University nor the names of its contributors
59 * may be used to endorse or promote products derived from this software
60 * without specific prior written permission.
61 *
62 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * SUCH DAMAGE.
73 */
74
75 #ifndef _SYS_EVCNT_H_
76 #define _SYS_EVCNT_H_
77
78 #include <sys/queue.h>
79
80 /*
81 * event counters
82 */
83
84 struct evcnt {
85 uint64_t ev_count; /* how many have occurred */
86 TAILQ_ENTRY(evcnt) ev_list; /* entry on list of all counters */
87 unsigned char ev_type; /* counter type; see below */
88 unsigned char ev_grouplen; /* 'group' len, excluding NUL */
89 unsigned char ev_namelen; /* 'name' len, excluding NUL */
90 char ev_pad1; /* reserved (for now); 0 */
91 const struct evcnt *ev_parent; /* parent, for hierarchical ctrs */
92 const char *ev_group; /* name of group */
93 const char *ev_name; /* name of specific event */
94 };
95 TAILQ_HEAD(evcntlist, evcnt);
96
97 /* maximum group/name lengths, including trailing NUL */
98 #define EVCNT_STRING_MAX 256
99
100 /* ev_type values */
101 #define EVCNT_TYPE_MISC 0 /* miscellaneous; catch all */
102 #define EVCNT_TYPE_INTR 1 /* interrupt; count with vmstat -i */
103 #define EVCNT_TYPE_TRAP 2 /* processor trap/execption */
104
105 /*
106 * initializer for an event count structure. the lengths are initted and
107 * it is added to the evcnt list at attach time.
108 */
109 #define EVCNT_INITIALIZER(type, parent, group, name) \
110 { \
111 0, /* ev_count */ \
112 { NULL, NULL }, /* ev_list */ \
113 type, /* ev_type */ \
114 0, /* ev_grouplen */ \
115 0, /* ev_namelen */ \
116 0, /* ev_pad1 */ \
117 parent, /* ev_parent */ \
118 group, /* ev_group */ \
119 name, /* ev_name */ \
120 }
121
122 /*
123 * Attach a static event counter. This uses a link set to do the work.
124 * NOTE: "ev" should not be a pointer to the object, but rather a direct
125 * reference to the object itself.
126 */
127 #define EVCNT_ATTACH_STATIC(ev) __link_set_add_data(evcnts, ev)
128 #define EVCNT_ATTACH_STATIC2(ev, n) __link_set_add_data2(evcnts, ev, n)
129
130 #ifdef _KERNEL
131
132 extern struct evcntlist allevents; /* list of all event counters */
133
134 void evcnt_init(void);
135 void evcnt_attach_static(struct evcnt *);
136 void evcnt_attach_dynamic(struct evcnt *, int, const struct evcnt *,
137 const char *, const char *);
138 void evcnt_detach(struct evcnt *);
139
140 #ifdef DDB
141 void event_print(int, void (*)(const char *, ...));
142 #endif
143 #endif /* _KERNEL */
144
145 #endif /* !_SYS_EVCNT_H_ */
Cache object: b615271d9ae55cf55f214cf81973dea7
|