Skip to main content

Module cpumask

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

Constants§

MASK_WIDTH_OVERRIDE 🔒
Per-thread override for Cpumask width. 0 means use *NR_CPU_IDS. Thread-local so parallel test threads don’t interfere.

Functions§

mask_width 🔒
Return the effective Cpumask width: the test override if set, else *NR_CPU_IDS.
read_cpulist
set_cpumask_test_width
Override the Cpumask width for the current thread. All subsequent Cpumask::new(), from_str(), and related calls on this thread will use this width instead of NR_CPU_IDS. Set to 0 to restore the default.