intel-cmt-cat icon indicating copy to clipboard operation
intel-cmt-cat copied to clipboard

Fix CPU detection in cgroup v2 constrained environments

Open rucoder opened this issue 1 month ago • 1 comments

Description

Remove sysconf(_SC_NPROCESSORS_CONF) validation that causes false failures when the library runs in a process with cgroup v2 CPU limits.

When cpu.max is set in cgroup v2, sysconf(_SC_NPROCESSORS_CONF) returns the cgroup-limited CPU count rather than the actual system CPU count. However, scanning /sys/devices/system/cpu always returns the real number of cores in the system, causing a mismatch and spurious check failures.

By removing the sysconf() call and relying solely on the sysfs scan, we ensure consistent CPU topology detection regardless of cgroup constraints.

Affected parts

  • [x] library
  • [ ] pqos utility
  • [ ] rdtset utility
  • [ ] other: (please specify)

Motivation and Context

https://github.com/lf-edge/eve uses libpqos from privileged system container pkg/pillar. This is a houskeeping conitainer that creates user workloads and it is restricted only to core 0 but has full visibility of /sys/fs so the library did not initilize

How Has This Been Tested?

This was tested from EVE OS on a real device with intel RDT support

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.

rucoder avatar Nov 26 '25 17:11 rucoder

@rucoder Please make sure that your patch follows the project's style. You should use the following commands for this: $ export CHECKPATCH=<path_to_checkpatch>checkpatch.pl $ make style Here, is the path to Linux Kernel's checkpatch.pl utility. For example <linux_kernel_repo>/scripts/checkpatch.pl

Also make sure that unit-tests are passed: $ cd unit-test <intel-cmt-cat/unit-test> make clean <intel-cmt-cat/unit-test> make <intel-cmt-cat/unit-test> make run

rstorozh avatar Dec 08 '25 11:12 rstorozh