Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Huawei Cloud EulerOS/ User Guide/ Kernel Functions and Interfaces/ Multi-level Hybrid Scheduling of Kernel CPU cgroups

Multi-level Hybrid Scheduling of Kernel CPU cgroups

Updated on 2024-09-14 GMT+08:00

Background

In hybrid deployments, the Linux kernel scheduler assigns more scheduling opportunities to high-priority tasks and minimizes the impact of low-priority tasks on kernel scheduling. However, the two-level scheduling of online and offline services cannot meet this requirement.

To solve the problem, HCE 2.0 allows multi-level scheduling of kernel CPU cgroups and provides the interface /sys/fs/cgroup/cpu/cpu.qos_level to extend the scheduling levels from two to five, allowing users to set the priority for each cgroup separately.

Constraints

Multi-level hybrid scheduling of the kernel CPU cgroups is developed based on the 5.10.0-60.18.0.50.r692_16.hce2.x86_64 kernel. cpu.qos_level supports only cgroup v1.

Interface Description

Rules for cpu.qos_level to take effect:

  • Completely Fair Scheduler (CFS) selects task_group level by level from top to bottom. cpu.qos_level takes effect for child cgroups under the same parent cgroup.
  • When a child cgroup is created, it inherits the cpu.qos_level value of the parent cgroup by default, but the cpu.qos_level value can be reconfigured.
  • For QoS levels with the same priority, their resource competition complies with the policy of CFS.
  • On the same CPU, the tasks whose qos_level is less than 0 are always unconditionally preempted by tasks whose qos_level is greater than or equal to is 0, regardless of their levels.

When a high-priority task is scheduled:

  • Online tasks can unconditionally preempt the CPU resources of offline tasks. During multi-core scheduling, online tasks can preferentially preempt the CPU resources of offline tasks on other cores. In the hyper-thread scenario, online tasks with priority 2 can evict offline tasks on the SMT.
  • When a task with a higher priority is woken up, the task is accelerated by time slicing and can immediately preempt the CPU resources of the task with a lower priority to obtain a response at a lower latency (the minimum running time slice of CFS is ignored).
Table 1 Interface description

Interface

Description

cpu.qos_level

Specifies the CPU priorities of the cgroups. The value is an integer ranging from -2 to 2. The default value is 0.

  • cpu.qos_level >= 0

    Tasks in the cgroup are online tasks, which can unconditionally preempt offline tasks.

    A lower value indicates a lower priority (0 < 1 < 2). Online tasks with a higher priority can obtain more CPU resources than those with a lower priority.

  • cpu.qos_level < 0

    Tasks in the cgroup are offline tasks. The priority of -1 is higher than that of -2, meaning that tasks at level -1 have more CPU resources than tasks at level -2.

    If the parent cgroup is set offline, the child cgroup can inherit only the priority of the parent cgroup, and the priority cannot be changed.

Interface Configuration Example

Create cgroups A, B, and C, and configure the cpu.qos_level interface.

Table 2 Data planning

cgroup

cpu.qos_level Value

A

1

B

-2

C

2

  1. Create cgroup A and child cgroups B and C, and set their CPU scheduling priorities to 1, -2, and 2.
    Tasks in cgroups A and C can unconditionally preempt CPU resources of the tasks in cgroup B. cgroup C preferentially preempts CPU resources because the priority of cgroup C is higher than that of cgroup A.
    mkdir -p /sys/fs/cgroup/cpu/A
    echo 1 > /sys/fs/cgroup/cpu/A/cpu.qos_level
    mkdir -p /sys/fs/cgroup/cpu/A/B
    echo -2 > /sys/fs/cgroup/cpu/A/B/cpu.qos_level
    mkdir -p /sys/fs/cgroup/cpu/A/C
    echo 2 > /sys/fs/cgroup/cpu/A/C/cpu.qos_level
  2. Add the task1, task2, and task3 processes to cgroup B.
    The CPU scheduling priority of the task1, task2, and task3 processes is -2.
    echo $PID1 > /sys/fs/cgroup/cpu/A/B/tasks
    echo $PID2 > /sys/fs/cgroup/cpu/A/B/tasks
    echo $PID3 > /sys/fs/cgroup/cpu/A/B/tasks
  3. Add the task4 and task5 processes to cgroup C.
    The CPU scheduling priority of the task4 and task5 processes is 2.
    echo $PID4 > /sys/fs/cgroup/cpu/A/C/tasks
    echo $PID5 > /sys/fs/cgroup/cpu/A/C/tasks
  4. View the CPU scheduling priority and processes of cgroup B.
    [root@localhost cpu_qos]# cat /sys/fs/cgroup/cpu/A/B/cpu.qos_level
    -2
    [root@localhost boot]# cat /sys/fs/cgroup/cpu/A/B/tasks
    1879
    1880
    1881
  5. View the CPU scheduling priority and processes of cgroup C.
    [root@localhost cpu_qos]# cat /sys/fs/cgroup/cpu/A/C/cpu.qos_level
    2
    [root@localhost boot]# cat /sys/fs/cgroup/cpu/A/C/tasks
    1882
    1883

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback