To assist in performance tuning, the Oracle Solaris kernel provides the kstat(3KSTAT) facility. The stat facility provides a set of functions and data structures for device drivers and other kernel modules to export module-specific kernel statistics.
A stat is a data structure for recording quantifiable aspects of a device's usage. A stat is stored as a null-terminated linked list. Each stat has a common header section and a type-specific data section. The header section is defined by the kstat_t structure.
The members of a stat structure are:
Categorizes the stat type as bus, controller, device_error, disk, hat, kmem_cache, stat, misc, net, nfs, pages, partition, rps, Ufa, vm, or men.
Time at which the stat was created. ks_crtime is commonly used in calculating rates of various counters.
Points to the data section for the stat.
Total size of the data section in bytes.
The instance of the kernel module that created this stat. ks_instance is combined with ks_module and ks_name to give the stat a unique, meaningful name.
Unique ID for the stat.
Identifies the kernel module that created this stat. ks_module is combined with ks_instance and ks_name to give the stat a unique, meaningful name. KSTAT_STRLEN sets the maximum length of ks_module.
A name assigned to the stat in combination with ks_module and ks_instance. KSTAT_STRLEN sets the maximum length of ks_module.
Indicates the number of data records for those stat types that support multiple records: KSTAT_TYPE_RAW, KSTAT_TYPE_NAMED, and KSTAT_TYPE_TIMER
Points to next stat in the chain.
A reserved field.
The timestamps for the last data snapshot, useful in calculating rates.
The data type, which can be KSTAT_TYPE_RAW for binary data, KSTAT_TYPE_NAMED for name/value pairs, KSTAT_TYPE_INTR for interrupt statistics, KSTAT_TYPE_IO for I/O statistics, and KSTAT_TYPE_TIMER for event timers.
The structures for the different kinds of stats are:
Each kernel statistic (stat) that is exported by device drivers consists of a header section and a data section. The stat (9S) structure is the header portion of the statistic.
Structure for interrupt stats. The types of interrupts are:
Hard interrupt – Sources from the hardware device itself
Soft interrupt – Induced by the system through the use of some system interrupt source
Watchdog interrupt – Induced by a periodic timer call
Spurious interrupt – An interrupt entry point was entered but there was no interrupt to service
Multiple service – An interrupt was detected and serviced just prior to returning from any of the other types
Drivers generally report only claimed hard interrupts and soft interrupts from their handlers, but measurement of the spurious class of interrupts is useful for auto-vectored devices to locate any interrupt latency problems in a particular system configuration. Devices that have more than one interrupt of the same type should use multiple structures.
Structure for I/O stats.
Structure for named stats. A named stat is an array of name-value pairs. These pairs are kept in the kstat_named structure.
The functions for using stats are:
Allocate and initialize a kstat(9S) structure.
Remove a stat from the system.
Add a fully initialized stat to the system.
Initialize a named stat. kstat_named_setstr() associates st, a string, with the named stat pointer.
A large number of I/O subsystems have at least two basic queues of transactions to be managed. One queue is for transactions that have been accepted for processing but for which processing has yet to begin. The other queue is for transactions that are actively being processed but not yet done. For this reason, two cumulative time statistics are kept: wait time and run time. Wait time is prior to service. Run time is during the service. The kstat_queue() family of functions manages these times based on the transitions between the driver wait queue and run queue:
The stat interface described in the following table is an effective way to obtain Ethernet physical layer statistics from the driver. Ethernet drivers should export these statistics to guide users in better diagnosis and repair of Ethernet physical layer problems. With exception of link_up, all statistics have a default value of 0 when not present. The value of the link_up statistic should be assumed to be 1.
The following example gives all the shared link setup. In this case Mei is used to filter statistics.
stat ce:0:mii:link_*
|