mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-05 02:40:18 +00:00
Merge pull request #6710 from Jordan9500/cherry-pick-cgroupv2-fix
rustjail: Use CPUWeight with systemd and CgroupsV2
This commit is contained in:
@@ -71,7 +71,7 @@ impl Cpu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// v2:
|
// v2:
|
||||||
// cpu.shares <-> CPUShares
|
// cpu.shares <-> CPUWeight
|
||||||
// cpu.period <-> CPUQuotaPeriodUSec
|
// cpu.period <-> CPUQuotaPeriodUSec
|
||||||
// cpu.period & cpu.quota <-> CPUQuotaPerSecUSec
|
// cpu.period & cpu.quota <-> CPUQuotaPerSecUSec
|
||||||
fn unified_apply(
|
fn unified_apply(
|
||||||
@@ -80,8 +80,8 @@ impl Cpu {
|
|||||||
systemd_version: &str,
|
systemd_version: &str,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if let Some(shares) = cpu_resources.shares {
|
if let Some(shares) = cpu_resources.shares {
|
||||||
let unified_shares = get_unified_cpushares(shares);
|
let weight = shares_to_weight(shares);
|
||||||
properties.push(("CPUShares", Value::U64(unified_shares)));
|
properties.push(("CPUWeight", Value::U64(weight)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(period) = cpu_resources.period {
|
if let Some(period) = cpu_resources.period {
|
||||||
@@ -104,7 +104,7 @@ impl Cpu {
|
|||||||
|
|
||||||
// ref: https://github.com/containers/crun/blob/main/crun.1.md#cgroup-v2
|
// ref: https://github.com/containers/crun/blob/main/crun.1.md#cgroup-v2
|
||||||
// [2-262144] to [1-10000]
|
// [2-262144] to [1-10000]
|
||||||
fn get_unified_cpushares(shares: u64) -> u64 {
|
fn shares_to_weight(shares: u64) -> u64 {
|
||||||
if shares == 0 {
|
if shares == 0 {
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user