[LTP] memcontrol: Add bind_to_current_cpu() helper
Wei Gao
wegao@suse.com
Wed Sep 30 13:25:49 CEST 2026
On Wed, Sep 30, 2026 at 08:11:14AM +0000, linuxtestproject.agent@gmail.com wrote:
> 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).
>
The reason is in PATCH 2/2.
> > +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.
@Andrea Maybe we need update AI rules?
>
> 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