Module cpumask

Source
Expand description

§SCX Cpumask

A crate that allows creating, reading, and manipulating cpumasks.

§Cpumask

A Cpumask object is simply a BitVec of u64’s, along with a series of helper functions for creating, manipulating, and reading these BitVec objects.

Empty Cpumasks can be created directly, or they can be created from a hexadecimal string:

     use scx_utils::Cpumask;
     let all_zeroes = Cpumask::new();
     let from_str_mask = Cpumask::from_str("0xf0");

The hexadecimal string also supports the special values “none” and “all”, respectively to specify no CPU (empty mask) or all CPUs (full mask):

     use scx_utils::Cpumask;
     let str = String::from("none");
     let all_zeroes = Cpumask::from_str(&str);

     let str = String::from("all");
     let all_ones = Cpumask::from_str(&str);

A Cpumask can be queried and updated using its helper functions:

     use log::info;
     use scx_utils::Cpumask;
     let str = String::from("none");
     let mut mask = Cpumask::from_str(&str).unwrap();
     info!("{:#?}", mask); // 32:<11111111000000001111111100000000>
     assert!(!mask.test_cpu(0));
     mask.set_cpu(0);
     assert!(mask.test_cpu(0));

     mask.clear_all();
     info!("{:#?}", mask); // 32:<00000000000000000000000000000000>
     assert!(!mask.test_cpu(0));

     mask.set_all();
     info!("{:#?}", mask); // 32:<11111111111111111111111111111111>
     assert!(mask.test_cpu(0));

Structs§

Cpumask
CpumaskIterator

Functions§

read_cpulist