[LTP] memcontrol: Add bind_to_current_cpu() helper
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Wed Sep 30 10:11:14 CEST 2026
Hi Wei,
On Wed Sep 30 03:53:14 2026 +0000, Wei Gao via ltp wrote:
> memcontrol: Add bind_to_current_cpu() helper
--- [PATCH 1/2] ---
> Add bind_to_current_cpu() to memcontrol_common.h to allow memcg tests
> to bind the test process to a single CPU.
The commit message only restates what changed. Explain why memcg tests
need to bind to a single CPU (e.g. to prevent multi-CPU per-CPU memcg stock
charge accumulation from causing reclaim variance in hierarchical tests).
> +static inline void bind_to_current_cpu(void)
> +{
> + int cpu = sched_getcpu();
> + size_t mask_size;
> + cpu_set_t *mask;
Include <sched.h> in memcontrol_common.h. The function uses sched_getcpu(),
cpu_set_t, CPU_ALLOC(), and sched_setaffinity(), but currently relies on
indirect inclusion via tst_test.h.
Verdict - Needs revision
Pre-existing issues:
- memcontrol03.c:209: sleep(1) is used in a polling loop. Polling loops
should use exponential backoff or checkpoint synchronization.
- memcontrol03.c:241, memcontrol04.c:240: fd validity is checked with
fd > -1 instead of the LTP convention fd != -1.
---
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