mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 04:04:45 +00:00
rustjail: fix blkio conversion
BFQ weight controller is using the same BFQ weight scheme (i.e 1->1000). Therefore, there is no need to do the conversion. More details here: https://github.com/opencontainers/runc/pull/2786 Fixes: #1440 Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
This commit is contained in:
parent
29d4abf23a
commit
dcea08697a
@ -274,36 +274,22 @@ fn set_hugepages_resources(
|
||||
}
|
||||
|
||||
fn set_block_io_resources(
|
||||
cg: &cgroups::Cgroup,
|
||||
_cg: &cgroups::Cgroup,
|
||||
blkio: &LinuxBlockIO,
|
||||
res: &mut cgroups::Resources,
|
||||
) -> Result<()> {
|
||||
info!(sl!(), "cgroup manager set block io");
|
||||
|
||||
if cg.v2() {
|
||||
res.blkio.weight = convert_blk_io_to_v2_value(blkio.weight);
|
||||
res.blkio.leaf_weight = convert_blk_io_to_v2_value(blkio.leaf_weight);
|
||||
} else {
|
||||
res.blkio.weight = blkio.weight;
|
||||
res.blkio.leaf_weight = blkio.leaf_weight;
|
||||
}
|
||||
res.blkio.weight = blkio.weight;
|
||||
res.blkio.leaf_weight = blkio.leaf_weight;
|
||||
|
||||
let mut blk_device_resources = vec![];
|
||||
for d in blkio.weight_device.iter() {
|
||||
let (w, lw) = if cg.v2() {
|
||||
(
|
||||
convert_blk_io_to_v2_value(blkio.weight),
|
||||
convert_blk_io_to_v2_value(blkio.leaf_weight),
|
||||
)
|
||||
} else {
|
||||
(blkio.weight, blkio.leaf_weight)
|
||||
};
|
||||
|
||||
let dr = BlkIoDeviceResource {
|
||||
major: d.blk.major as u64,
|
||||
minor: d.blk.minor as u64,
|
||||
weight: w,
|
||||
leaf_weight: lw,
|
||||
weight: blkio.weight,
|
||||
leaf_weight: blkio.leaf_weight,
|
||||
};
|
||||
blk_device_resources.push(dr);
|
||||
}
|
||||
@ -1107,20 +1093,6 @@ fn convert_memory_swap_to_v2_value(memory_swap: i64, memory: i64) -> Result<i64>
|
||||
Ok(memory_swap - memory)
|
||||
}
|
||||
|
||||
// Since the OCI spec is designed for cgroup v1, in some cases
|
||||
// there is need to convert from the cgroup v1 configuration to cgroup v2
|
||||
// the formula for BlkIOWeight is y = (1 + (x - 10) * 9999 / 990)
|
||||
// convert linearly from [10-1000] to [1-10000]
|
||||
// https://github.com/opencontainers/runc/blob/a5847db387ae28c0ca4ebe4beee1a76900c86414/libcontainer/cgroups/utils.go#L382
|
||||
fn convert_blk_io_to_v2_value(blk_io_weight: Option<u16>) -> Option<u16> {
|
||||
let v = blk_io_weight.unwrap_or(0);
|
||||
if v != 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(1 + (v - 10) * 9999 / 990 as u16)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
Loading…
Reference in New Issue
Block a user