[LTP] getrusage03: Pin the test to a single CPU
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Fri Sep 4 14:17:17 CEST 2026
Hi Jan,
On Sep 4, 2026, Jan Stancek wrote:
> getrusage03: Pin the test to a single CPU
> +/*
> + * Pin the process (and everything it forks) to the CPU it currently runs on.
> + * Since commit f1a7941243c1 ("mm: convert mm's rss stats into percpu_counter")
> + * the RSS is tracked in a percpu counter whose fast read
> + * (percpu_counter_read_positive) only returns the global count, ignoring the
> + * per-CPU caches.
High: This setup makes the affected 100 MB child report pass instead of
exposing the approximately 64 MB getrusage(2) result. That is a kernel bug
workaround; keep the test migratable so the incorrect result remains visible.
> + unsigned int cpu;
> + cpu_set_t set;
> +
> + if (getcpu(&cpu, NULL))
> + tst_brk(TBROK | TERRNO, "getcpu() failed");
> +
> + CPU_ZERO(&set);
> + CPU_SET(cpu, &set);
> + if (sched_setaffinity(0, sizeof(set), &set))
> + tst_brk(TBROK | TERRNO, "sched_setaffinity() failed");
Medium: cpu_set_t cannot represent valid CPU IDs of CPU_SETSIZE or higher, so
CPU_SET() leaves the mask empty and sched_setaffinity() fails with EINVAL.
Use a dynamically allocated mask with CPU_ALLOC_SIZE(tst_ncpus_max()) and the
CPU_ZERO_S()/CPU_SET_S() interfaces.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list