Skip to content

topology: Use cpumasks to iterate all possible or online CPUs #721

Open
@htejun

Description

@htejun

CPU IDs aren't guaranteed to be consecutive. To iterate all possible or currently online CPUs, the respective cpumask should be iterated. There are several issues in this area:

  • Some are iterating 0 to the number of online CPUS. This is incorrect as CPU IDs can have gaps and thus can miss higher numbered CPUs.
  • Some are iterating 0 to nr_cpu_ids. This is correct but not ideal in that the CPU IDs can have substantial gaps not online or unallocated.
  • The possible and online cpumasks can be accessed from BPF side using scx_bpf_get_possible_cpumask() and scx_bpf_get_online_cpumask(), respectively. However, scx_utils::toplogy doesn't expose the current possible or online CPU masks that are available through /sys/devices/system/cpu/possible and online.

Make scx_utils::topology expose the cpumasks and make all schedulers use the appropriate cpumask for iteration in both userspace and BPF code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions