xref: /openbsd/usr.sbin/kgmon/kgmon.8 (revision 582f75e7)
1.\" $OpenBSD: kgmon.8,v 1.14 2016/09/25 23:31:50 deraadt Exp $
2.\" Copyright (c) 1983, 1991, 1993
3.\"	The Regents of the University of California.  All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. Neither the name of the University nor the names of its contributors
14.\"    may be used to endorse or promote products derived from this software
15.\"    without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE.
28.\"
29.\"     from: @(#)kgmon.8	8.1 (Berkeley) 6/6/93
30.\"
31.Dd $Mdocdate: September 25 2016 $
32.Dt KGMON 8
33.Os
34.Sh NAME
35.Nm kgmon
36.Nd generate a dump of the operating system's profile buffers
37.Sh SYNOPSIS
38.Nm kgmon
39.Op Fl bhpr
40.Op Fl c Ar cpuid
41.Op Fl M Ar core
42.Op Fl N Ar system
43.Sh DESCRIPTION
44.Nm kgmon
45is a tool used when profiling the operating system.
46When no arguments are supplied,
47.Nm kgmon
48indicates the state of per-CPU operating system profilings as
49.Dq running ,
50.Dq off ,
51or
52.Dq not configured
53(see
54.Xr config 8 ) .
55If the
56.Fl p
57flag is specified,
58.Nm kgmon
59extracts profile data from the operating system and produces a file for each
60CPU suitable for later analysis by
61.Xr gprof 1 .
62.Pp
63The options are as follows:
64.Bl -tag -width Ds
65.It Fl b
66Resume the collection of profile data.
67.It Fl c Ar cpuid
68Operate on the CPU specified by
69.Pa cpuid ,
70instead of all of them.
71.It Fl h
72Stop the collection of profile data.
73.It Fl M Ar core
74Extract values associated with the name list from the specified
75.Ar core
76instead of the default
77.Pa /dev/kmem .
78.It Fl N Ar system
79Extract the name list from the specified
80.Ar system
81instead of the default
82.Pa /bsd .
83.It Fl p
84Dump the contents of the profile buffers into a
85.Pa gmon-<id>.out
86file, where
87.Dq id
88is the ID of the CPU.
89.It Fl r
90Reset all the profile buffers.
91If the
92.Fl p
93flag is also specified, the profile files are generated before the buffers are
94reset.
95.El
96.Pp
97If neither
98.Fl b
99nor
100.Fl h
101is specified, the state of profiling collection remains unchanged.
102For example, if the
103.Fl p
104flag is specified and profile data is being collected,
105profiling will be momentarily suspended,
106the operating system profile buffers will be dumped,
107and profiling will be immediately resumed.
108.Pp
109.Nm
110requires the ability to open
111.Pa /dev/kmem
112which may be restricted based upon the value of the
113.Ar kern.allowkmem
114.Xr sysctl 8 .
115.Sh FILES
116.Bl -tag -width /dev/kmemx -compact
117.It Pa /bsd
118default system
119.It Pa /dev/kmem
120default memory
121.El
122.Sh DIAGNOSTICS
123Users with only read permission on
124.Pa /dev/kmem
125cannot change the state
126of profiling collection.
127They can get profile files with the warning that the data may be inconsistent
128if profiling is in progress.
129.Sh SEE ALSO
130.Xr gprof 1 ,
131.Xr config 8
132.Sh HISTORY
133The
134.Nm
135command appeared in
136.Bx 4.2 .
137