master
  1/*	$NetBSD: trace.h,v 1.12 2017/12/19 18:47:58 kamil Exp $	*/
  2
  3/*-
  4 * Copyright (c) 1982, 1986, 1993
  5 *	The Regents of the University of California.  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. Neither the name of the University nor the names of its contributors
 16 *    may be used to endorse or promote products derived from this software
 17 *    without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 22 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 29 * SUCH DAMAGE.
 30 *
 31 *	@(#)trace.h	8.1 (Berkeley) 6/2/93
 32 */
 33
 34#ifndef _SYS_TRACE_H_
 35#define _SYS_TRACE_H_
 36
 37/*
 38 * File system buffer tracing points; all trace <pack(dev, size), bn>
 39 */
 40#define	TR_BREADHIT	0	/* buffer read found in cache */
 41#define	TR_BREADMISS	1	/* buffer read not in cache */
 42#define	TR_BWRITE	2	/* buffer written */
 43#define	TR_BREADHITRA	3	/* buffer read-ahead found in cache */
 44#define	TR_BREADMISSRA	4	/* buffer read-ahead not in cache */
 45#define	TR_XFODMISS	5	/* exe fod read */
 46#define	TR_XFODHIT	6	/* exe fod read */
 47#define	TR_BRELSE	7	/* brelse */
 48#define	TR_BREALLOC	8	/* expand/contract a buffer */
 49
 50/*
 51 * Memory allocator trace points; all trace the amount of memory involved
 52 */
 53#define	TR_MALL		10	/* memory allocated */
 54
 55/*
 56 * Paging trace points: all are <vaddr, pid>
 57 */
 58#define	TR_INTRANS	20	/* page intransit block */
 59#define	TR_EINTRANS	21	/* page intransit wait done */
 60#define	TR_FRECLAIM	22	/* reclaim from free list */
 61#define	TR_RECLAIM	23	/* reclaim from loop */
 62#define	TR_XSFREC	24	/* reclaim from free list instead of drum */
 63#define	TR_XIFREC	25	/* reclaim from free list instead of fsys */
 64#define	TR_WAITMEM	26	/* wait for memory in pagein */
 65#define	TR_EWAITMEM	27	/* end memory wait in pagein */
 66#define	TR_ZFOD		28	/* zfod page fault */
 67#define	TR_EXFOD	29	/* exec fod page fault */
 68#define	TR_VRFOD	30	/* vread fod page fault */
 69#define	TR_CACHEFOD	31	/* fod in file system cache */
 70#define	TR_SWAPIN	32	/* drum page fault */
 71#define	TR_PGINDONE	33	/* page in done */
 72#define	TR_SWAPIO	34	/* swap i/o request arrives */
 73
 74/*
 75 * Miscellaneous
 76 */
 77#define	TR_STAMP	45	/* user said vtrace(VTR_STAMP, value); */
 78
 79/*
 80 * This defines the size of the trace flags array.
 81 */
 82#define	TR_NFLAGS	100	/* generous */
 83
 84#define	TRCSIZ		4096
 85
 86/*
 87 * Specifications of the vtrace() system call, which takes one argument.
 88 */
 89#define	VTRACE		64+51
 90
 91#define	VTR_DISABLE	0		/* set a trace flag to 0 */
 92#define	VTR_ENABLE	1		/* set a trace flag to 1 */
 93#define	VTR_VALUE	2		/* return value of a trace flag */
 94#define	VTR_UALARM	3		/* set alarm to go off (sig 16) */
 95					/* in specified number of hz */
 96#define	VTR_STAMP	4		/* user specified stamp */
 97
 98#ifdef _KERNEL
 99#ifdef TRACE
100struct	proc *traceproc;
101int	tracewhich, tracebuf[TRCSIZ];
102u_int	tracex;
103char	traceflags[TR_NFLAGS];
104#define	pack(v,b)	(((v)->v_mount->mnt_stat.f_fsidx.__fsid_val[0])<<16)|(b)
105#define	trace(a,b,c) {							\
106	if (traceflags[a])						\
107		trace1(a,b,c);						\
108}
109#else
110#define	trace(a,b,c)
111#endif /* TRACE */
112#endif /* _KERNEL */
113
114#endif /* !_SYS_TRACE_H_ */