Getting values of performance counters (value_api.h)

API is defined in the header file sysroot-*-kos/include/coresrv/stat/value_api.h from the KasperskyOS SDK.

This API lets you receive the values of performance counters, such as counters for the uptime, sizes of memory and objects.

Information about API functions is provided in the table below.

Using the API

To receive the values of performance counters, use the following functions:

The KnStatGetValueAsInt64() and KnStatGetValueAsUInt64() functions use the name parameter to receive the name of the performance counter. The KnStatGetValues() and KnStatGetObjectValues() functions use the names parameter to receive an array containing the names of the performance counters. A performance counter name is a string consisting of one or more segments separated by a dot (see the tables containing the names and values of performance counters below).

The optional prefix parameter is used by the KnStatGetValueAsInt64() and KnStatGetValueAsUInt64() functions to receive the prefix for the performance counter name defined via the name parameter, and the KnStatGetValues() function receives the prefix for the performance counter names defined via the names parameter. This prefix is the initial part of the performance counter name consisting of one or more segments separated by a dot, and it ends with a dot. The prefix parameter is convenient to use when you need to receive the values of multiple performance counters with names that have an identical initial or final part. The prefix also may contain an identical or different initial part.

You can use the KnStatGetObjectValues() function to receive the values of only those performance counters that are associated with a process or thread defined via the handle parameter. However, the names of performance counters associated with a process must be specified without the initial part task.<PID>., and the names of performance counters associated with a thread must be specified without the initial part task.<PID>.thread.<TID>.

Information about API functions

value_api.h functions

Function

Information about the function

KnStatGetValueAsInt64()

Purpose

Gets the value of a performance counter in 64-bit signed integer format.

Parameters

  • [in,optional] prefix – pointer to the prefix for the performance counter name, or RTL_NULL if you do not need to use a prefix.
  • [in] name – pointer to the name of the performance counter.
  • [out] value – pointer to the value of the performance counter.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

KnStatGetValueAsUInt64()

Purpose

Gets the value of a performance counter in 64-bit unsigned integer format.

Parameters

  • [in,optional] prefix – pointer to the prefix for the performance counter name, or RTL_NULL if you do not need to use a prefix.
  • [in] name – pointer to the name of the performance counter.
  • [out] value – pointer to the value of the performance counter.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

KnStatGetValues()

Purpose

Gets the values of performance counters.

Parameters

  • [in,optional] prefix – pointer to the prefix for the performance counter names, or RTL_NULL if you do not need to use a prefix.
  • [in] names – pointer to the array containing the names of performance counters.
  • [in] count – quantity of performance counters.
  • [out] values – pointer to the array of structures containing the values of performance counters.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

KnStatGetObjectValues()

Purpose

Gets the values of performance counters associated with a system resource (process or thread).

Parameters

  • [in] handle – handle of the system resource.
  • [in] names – pointer to the array containing the names of performance counters.
  • [in] count – quantity of performance counters.
  • [out] values – pointer to the array of structures containing the values of performance counters.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

Names and values of performance counters

Uptime counters have values in nanoseconds. Uptime is counted from the startup of the KasperskyOS kernel. Most memory size counters have values defined in memory pages. The size of a memory page is 4 KB for all hardware platforms supported by KasperskyOS. The names of performance counters associated with a process contain the process identifier (PID). The names of performance counters associated with a thread contain the process identifier (PID) and thread identifier (TID). The qualified names of core endpoints can be viewed in Methods of KasperskyOS core endpoints.

System performance counters

Counter name

Counter value

tasks

Number of processes (excluding the kernel process)

threads

Number of threads (including kernel threads)

time.user

Total uptime of all processors in user mode

time.kernel

Total uptime of all processors in kernel mode

time.idle

Total uptime of all processors in idle mode

time.sleep.ipc

Total locking time of all threads awaiting IPC

time.sleep.futex

Total locking time of all threads resulting from futex use

time.sleep.voluntary

Total locking time of all threads resulting from calls of the KosThreadSleep() and KnSleep() functions

time.sleep.other

Total locking time of all threads due to reasons not related to pending IPC, futex use, or calls of the KosThreadSleep() and KnSleep() functions

mem.total

Size of installed physical memory, in memory pages

mem.free

Size of free physical memory, in memory pages

mem.shmem

Size of physical memory used as shared memory, in memory pages

mem.exsize

Size of physical memory with the "execution access" attribute, in memory pages

mem.kmalloc.total

Size of physical memory reserved for kernel allocator distribution, in memory pages

mem.kmalloc.free

Size of free physical memory reserved for kernel allocator distribution, in memory pages

mem.kmalloc.count

Quantity of physical memory regions distributed by the kernel allocator

mem.kmalloc.size

Size of physical memory distributed by the kernel allocator (in bytes)

mem.kmalloc.cached

Size of free physical memory that is reserved for kernel allocator distribution and is not available on every processor (computing core), but instead is available only separately on each processor, in bytes

dma.count

Quantity of DMA buffers

dma.allocated

Total size of all DMA buffers, in memory pages

romfs.is_initial

Indicator of ROMFS image in kernel memory (rtl_true or 1 – yes, rtl_false or 0 – no)

romfs.files.count

Quantity of files in ROMFS image

romfs.size

Size of ROMFS image, in memory pages

objects.total

Quantity of kernel objects

handles.total

Quantity of handles

handles.tables.size

Total size of handle tables, including used and unused identifiers (in bytes)

sid.used

Quantity of security identifiers (SIDs)

sid.capacity

Maximum possible quantity of security identifiers (SIDs)

ipc.recv

Quantity of Recv() system calls executed by all threads

ipc.reply

Quantity of Reply() system calls executed by all threads

ipc.call

Quantity of Call() system calls executed by all threads

Performance counters associated with a processor (computing core)

Counter name

Counter value

cpu.<processor index>.time.user

CPU uptime in user mode

cpu.<processor index>.time.kernel

CPU uptime in kernel mode

cpu.<processor index>.time.idle

CPU uptime in idle mode

cpu.<processor index>.conswitches

Quantity of thread context switches on the processor

cpu.<processor index>.irqs

Quantity of interrupts handled on the processor

cpu.<processor index>.irq.clock

Quantity of timer interrupts handled on the processor

cpu.<processor index>.irq.dsptch

Quantity of thread rescheduling interrupts handled on the processor

Performance counters associated with interrupts

Counter name

Counter value

irqs.count

Maximum number of hardware interrupts that can be registered, including MSI interrupts and interrupts that occur when devices query the interrupt controller via hardware interrupt lines

irq.<interrupt number>.cpu.<processor index>

Quantity of interrupts received by the processor (computing core)

irq.<interrupt number>.ipl

Priority of the interrupt

irq.<interrupt number>.enabled

Indicator that at least one thread is attached to the interrupt (rtl_true or 1 – yes, rtl_false or 0 – no)

irq.<interrupt number>.handlers

Quantity of interrupt handlers

irq.<interrupt number>.mode

Interrupt conditions (according to the irqmode_t list defined in the header file sysroot-*-kos/include/hal/irqmode.h from the KasperskyOS SDK)

Performance counters associated with a process

Counter name

Counter value

task.<PID>.state

State of the process (according to the list of TaskExecutionStates defined in the header file sysroot-*-kos/include/task/pcbpage.h from the KasperskyOS SDK)

task.<PID>.threads

Number of threads in the process

task.<PID>.start

Time between kernel startup and loading of the program image into process memory

task.<PID>.imsize

Size of program image in process memory, in bytes

task.<PID>.ppid

Parent process ID (PPID)

task.<PID>.prio

Priority of the initial thread of the process

task.<PID>.allocated

Size of physical memory used by the process, in memory pages (describes only the memory that is allocated directly for the process; for example, if the memory of a process is mapped to an MDL buffer created by another process, the size of this buffer is not included in this value)

task.<PID>.vmsize

Size of process virtual memory, in memory pages

task.<PID>.shmem

Size of process virtual memory mapped to shared physical memory, in memory pages

task.<PID>.ptsize

Size of process pages table, in memory pages

task.<PID>.dma.mapped

Size of DMA memory mapped to process virtual memory, in memory pages

task.<PID>.mmio.mapped

Size of MMIO memory mapped to process virtual memory, in memory pages

task.<PID>.time.user

Total execution time of all process threads in user mode

task.<PID>.time.kernel

Total execution time of all process threads in kernel mode

task.<PID>.time.sleep.ipc

Total locking time of all process threads awaiting IPC

task.<PID>.time.sleep.futex

Total locking time of all process threads resulting from futex use

task.<PID>.time.sleep.voluntary

Total locking time of all process threads resulting from calls of the KosThreadSleep() and KnSleep() functions

task.<PID>.time.sleep.other

Total locking time of all process threads due to reasons not related to pending IPC, futex use, or calls of the KosThreadSleep() and KnSleep() functions

task.<PID>.handles.allocated

Quantity of handles owned by the process

task.<PID>.handles.table.size

Size of process handles table, including used and unused identifiers (in bytes)

task.<PID>.handles.table.capacity

Quantity of handles that can be accommodated in the process handles table

task.<PID>.objects.user

Quantity of user resource handles created by the process

task.<PID>.ipc.recv

Quantity of Recv() system calls executed by all process threads

task.<PID>.ipc.reply

Quantity of Reply() system calls executed by all process threads

task.<PID>.ipc.call

Quantity of Call() system calls executed by all process threads

Performance counters associated with a thread

Counter name

Counter value

task.<PID>.thread.<TID>.time.user

Execution time of process thread in user mode

task.<PID>.thread.<TID>.time.kernel

Execution time of process thread in kernel mode

task.<PID>.thread.<TID>.time.sleep.ipc

Locking time of process thread awaiting IPC

task.<PID>.thread.<TID>.time.sleep.futex

Locking time of process thread resulting from futex use

task.<PID>.thread.<TID>.time.sleep.voluntary

Locking time of process thread resulting from calls of the KosThreadSleep() and KnSleep() functions

task.<PID>.thread.<TID>.time.sleep.other

Locking time of process thread due to reasons not related to pending IPC, futex use, or calls of the KosThreadSleep() and KnSleep() functions

task.<PID>.thread.<TID>.conswitches

Quantity of process thread evictions by other threads

task.<PID>.thread.<TID>.sched.prio

Priority of the thread.

task.<PID>.thread.<TID>.sched.policy

Thread scheduler class (in accordance with the ThreadSchedPolicy enumeration defined in the header file sysroot-*-kos/include/thread/tidtype.h from the KasperskyOS SDK)

task.<PID>.thread.<TID>.ipc.recv

Quantity of Recv() system calls executed by process thread

task.<PID>.thread.<TID>.ipc.reply

Quantity of Reply() system calls executed by process thread

task.<PID>.thread.<TID>.ipc.call

Quantity of Call() system calls executed by process thread

Page top