Contained WithinFind More DocumentationFeatured Support Resources | Download this book in PDF (8966 KB)
cpustat(1M)Name | Synopsis | Description | Options | Usage | Examples | Warnings | Attributes | See Also | Notes Name
Synopsis
cpustat -c eventspec [-c eventspec]... [-p period] [-sntD]
[interval [count]]
cpustat -h DescriptionThe cpustat utility allows CPU performance counters to be used to monitor the overall behavior of the CPUs in the system. If interval is specified, cpustat samples activity every interval seconds, repeating forever. If a count is specified, the statistics are repeated count times. If neither are specified, an interval of five seconds is used, and there is no limit to the number of samples that are taken. Options
The following options are supported: UsageA closely related utility, cputrack(1), can be used to monitor the behavior of individual applications with little or no interference from other activities on the system. The cpustat utility must be run by the super-user, as there is an intrinsic conflict between the use of the CPU performance counters system-wide by cpustat and the use of the CPU performance counters to monitor an individual process (for example, by cputrack.) Once any instance of this utility has started, no further per-process or per-LWP use of the counters is allowed until the last instance of the utility terminates. The times printed by the command correspond to the wallclock time when the hardware counters were actually sampled, instead of when the program told the kernel to sample them. The time is derived from the same timebase as gethrtime(3C). The processor cycle counts enabled by the -t option always apply to both user and system modes, regardless of the settings applied to the performance counter registers. On some hardware platforms running in system mode using the “sys” token, the counters are implemented using 32-bit registers. While the kernel attempts to catch all overflows to synthesize 64-bit counters, because of hardware implementation restrictions, overflows can be lost unless the sampling interval is kept short enough. The events most prone to wrap are those that count processor clock cycles. If such an event is of interest, sampling should occur frequently so that less than 4 billion clock cycles can occur between samples. The output of cpustat is designed to be readily parseable by nawk(1) and perl(1), thereby allowing performance tools to be composed by embedding cpustat in scripts. Alternatively, tools can be constructed directly using the same APIs that cpustat is built upon using the facilities of libcpc(3LIB). See cpc(3CPC). The cpustat utility only monitors the CPUs that are accessible to it in the current processor set. Thus, several instances of the utility can be running on the CPUs in different processor sets. See psrset(1M) for more information about processor sets. Because cpustat uses LWPs bound to CPUs, the utility might have to be terminated before the configuration of the relevant processor can be changed. ExamplesSPARCExample 1 Measuring External Cache References and MissesThe following example measures misses and references in the external cache. These occur while the processor is operating in user mode on an UltraSPARC machine.
x86Example 2 Measuring Branch Prediction Success on Pentium 4The following example measures branch mispredictions and total branch instructions in user and system mode on a Pentium 4 machine.
Example 3 Counting Memory Accesses on OpteronThe following example determines the number of memory accesses made through each memory controller on an Opteron, broken down by internal memory latency:
WarningsBy running the cpustat command, the super-user forcibly invalidates all existing performance counter context. This can in turn cause all invocations of the cputrack command, and other users of performance counter context, to exit prematurely with unspecified errors. If cpustat is invoked on a system that has CPU performance counters which are not supported by Solaris, the following message appears:
This error message implies that cpc_open() has failed and is documented in cpc_open(3CPC). Review this documentation for more information about the problem and possible solutions. If a short interval is requested, cpustat might not be able to keep up with the desired sample rate. In this case, some samples might be dropped. AttributesSee attributes(5) for descriptions of the following attributes:
See Alsocputrack(1), nawk(1), perl(1), iostat(1M), prstat(1M), psrset(1M), vmstat(1M), cpc(3CPC), cpc_open(3CPC), cpc_bind_cpu(3CPC), gethrtime(3C), strtoll(3C), libcpc(3LIB), attributes(5) NotesWhen cpustat is run on a Pentium 4 with HyperThreading enabled, a CPC set is bound to only one logical CPU of each physical CPU. See cpc_bind_cpu(3CPC). Name | Synopsis | Description | Options | Usage | Examples | Warnings | Attributes | See Also | Notes |
|||||||||||