kstat2_io - structure for v2 I/O kstats
#include <sys/types.h> #include <sys/kstat2.h> #include <sys/ddi.h> #include <sys/sunddi.h>
Solaris DDI specific (Solaris DDI)
I/O kstat statistics are kept in a kstat2_io structure. When kstat2_create(9F) function creates an I/O kstat, the ks2_data field is a pointer to one of these structures. The macro KSTAT2_IO_PTR() is provided to retrieve this field. It looks like this:
# define KSTAT2_IO_PTR(kptr) ((kstat2_io_t *)(kptr)->ks2_data)
kstat2_io_t is a data-structure which contains only kstat2_named_t fields. This behaves exactly like an array of kstat2_named_t entries, but with the advantage of being able to access the fields by name rather than having to remember array indices.
The following fields are updated by the driver:
kstat2_named_t nread; /* number of bytes read */ kstat2_named_t nwritten; /* number of bytes written *]/ kstat2_named_t reads; /* number of read operations */ kstat2_named_t writes; /* number of write operations */
Their values should be accessed through the following macros:
KSTAT2_IO_NREAD(kiop) KSTAT2_IO_NWRITTEN(kiop) KSTAT2_IO_READS(kiop) KSTAT2_IO_WRITES(kiop)
where kiop is obtained using:
kiop = KSTAT2_IO_PTR(kstatp);
The nread field is updated by the driver with the number of bytes successfully read upon completion.
The nwritten field is updated by the driver with the number of bytes successfully written upon completion.
The reads field is updated by the driver after each successful read operation.
The writes field is updated by the driver after each successful write operation.
The following fields are normally not updated by the driver directly as they are managed by the kstat2 queue functions. See kstat2_runq_enter(9F).
kstat2_named_t wtime; /* cumulative wait (pre-service) time */ kstat2_named_t wlentime; /* cumulative wait length*time product */ kstat2_named_t wlastupdate; /* last time wait queue changed */ kstat2_named_t rtime; /* cumulative run (service) time */ kstat2_named_t rlentime; /* cumulative run length*time product */ kstat2_named_t rlastupdate; /* last time run queue changed */ kstat2_named_t wcnt; /* count of elements in wait state */ kstat2_named_t rcnt; /* count of elements in run state */
The values of these fields are accessed using the following macros:
KSTAT2_IO_WTIME(kiop) KSTAT2_IO_WLENTIME(kiop) KSTAT2_IO_WLASTUPDATE(kiop) KSTAT2_IO_RTIME(kiop) KSTAT2_IO_RLENTIME(kiop) KSTAT2_IO_RLASTUPDATE(kiop) KSTAT2_IO_WCNT(kiop) KSTAT2_IO_RCNT(kiop)
/* * Initialize the kstat's name path segments. * This will result in a URI path for the kstat of: * /disk/mydrv/N/io * - where N is the disk instance number. */ const char *pseg[] = { "disk", "mydrv", ddi_inst_str, "io" }; /* * Lookup the IO kstat template. */ const kstat2_template_t *tmpl = kstat2_lookup_template(KSTAT2_MT_IO); /* * Now create a persistent IO kstat using the template. */ kstat2_t *ksp = kstat2_create_with_template(pseg, sizeof (pseg) / sizeof (char *), GLOBAL_ZONEID, io_tmpl, KSTAT2_FLAG_PERSISTENT, NULL, "mydrv disk io", KSTAT2_MF_NONE); if (ksp != NULL) { ksp->ks2_lock = mydrv->iomutex; mydrv->kstat = ksp; kstat2_install(ksp); }
kstat2_create(9F), kstat2(9S), kstat2_create_with_template(9F), kstat2_lookup_template(9F), kstat2_runq_back_to_waitq(9F), kstat2_runq_enter(9F), kstat2_runq_exit(9F), kstat2_waitq_enter(9F), kstat2_waitq_exit(9F), kstat2_waitq_to_runq(9F), kstat2_named(9S)