All Products
Search
Document Center

Alibaba Cloud Linux:Use the latency statistics feature of memsli and sched_sli

Last Updated:Dec 04, 2024

In Linux, Control Groups (cgroups) provide a resource management and restriction mechanism that limits, records, and isolates physical resources, such as CPUs, memory, and I/O resources, that are allocated to tasks (processes) in cgroups. For example, cgroups in the memory subsystem manage the usage of memory resources, and cgroups in the cpuacct subsystem record information about CPU resources used by tasks in cgroups. memsli and sched_sli are used to collect latency statistics on cgroups in the memory and cpuacct subsystems. This topic describes the latency statistics feature of memsli and sched_sli and how to use the feature to query latency statistics on cgroups in the memory and cpuacct subsystems on an instance that runs Alibaba Cloud Linux 3.

Limits

To use the latency statistics feature of memsli and sched_sli, make sure that your instance meets the following requirements:

  • The instance runs Alibaba Cloud Linux 3.

  • The kernel version of the instance is 5.10.134-12 or later.

Procedure

Enable or disable the memsli latency statistics feature

  • Run the following command to enable the memsli latency statistics feature:

    echo 1 | sudo tee /proc/memsli/enabled
    Note

    By default, the memsli latency statistics feature is enabled.

  • Run the following command to disable the memsli latency statistics feature:

    echo 0 | sudo tee /proc/memsli/enabled

Enable or disable the sched_sli latency statistics feature

  • Run the following command to enable the sched_sli latency statistics feature:

    echo 1 | sudo tee /proc/cpusli/sched_lat_enabled
  • Run the following command to disable the sched_sli latency statistics feature:

    echo 0 | sudo tee /proc/cpusli/sched_lat_enabled
    Note

    By default, the sched_sli latency statistics feature is disabled.

Query memsli latency statistics

  • The following table describes the interfaces used to query memsli latency statistics.

    Interface name

    Description

    memory.direct_compact_latency

    The latency in direct memory compaction when a memory cgroup (memcg) allocates memory.

    memory.direct_reclaim_memcg_latency

    The latency in direct memory reclamation when memory usage in a memcg exceeds a specific limit.

    memory.direct_swapout_global_latency

    The latency in global direct memory swap-out for anonymous pages to be moved to swap space due to insufficient global memory during memcg memory allocation.

    memory.direct_reclaim_global_latency

    The latency in global direct memory reclamation due to insufficient global memory during memcg memory allocation.

    memory.direct_swapin_latency

    The latency in direct memory swap-in from swap space to memory when memcgs reclaim memory.

    memory.direct_swapout_memcg_latency

    The latency in direct memory swap-out for anonymous pages to be moved to swap space when memcg memory usage exceeds a specific limit and memcg memory is reclaimed.

  • Example of querying memsli latency statistics

    Run the following command to use the memory.direct_reclaim_memcg_latency interface to query latency statistics:

    sudo cat /sys/fs/cgroup/memory/memory.direct_reclaim_memcg_latency

    The following sample command output is returned:

    0-1ms:  0
    1-5ms:  0
    5-10ms:         0
    10-100ms:       0
    100-500ms:      0
    500-1000ms:     0
    >=1000ms:       0
    total(ms):      0

Query sched_sli latency statistics

  • The following table describes the interfaces used to query sched_sli latency statistics.

    Important

    The sched_sli latency statistics feature can be used only if the cpu and cpuacct subsystems are mounted to the same directory. By default, the cpu and cpuacct subsystems are mounted to the /sys/fs/cgroup/ directory in Alibaba Cloud Linux 3.

    Interface name

    Description

    cpuacct.block_latency

    The latency from the time when uninterruptible processes in the cpuacct subsystem dequeue to the time when the uninterruptible processes are awakened.

    cpuacct.cgroup_wait_latency

    The latency for processes waiting to be scheduled in the runqueue in the cpuacct subsystem.

    cpuacct.ioblock_latency

    The latency from the time when uninterruptible processes that wait for I/O operations in the cpuacct subsystem dequeue to the time when the uninterruptible processes are awakened.

    cpuacct.wait_latency

    The latency of processes that wait for scheduling in the runqueue in the cpuacct subsystem.

  • Example of querying sched_sli latency statistics

    Run the following command to use the cpuacct.ioblock_latency interface to query latency statistics:

    sudo cat /sys/fs/cgroup/cpuacct/cpuacct.ioblock_latency

    The following sample command output is returned:

    0-1ms:  0
    1-4ms:  0
    4-7ms:  0
    7-10ms:         0
    10-20ms:        0
    20-30ms:        0
    30-40ms:        0
    40-50ms:        0
    50-100ms:       0
    100-500ms:      0
    500-1000ms:     0
    1000-5000ms:    0
    5000-10000ms:   0
    >=10000ms:      0
    total(ms):      0
    nr:     0