All of lore.kernel.org
 help / color / mirror / Atom feed
From: linuxtestproject.agent@gmail.com
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] memcontrol03: Bind to single CPU on systems with 64KB pagesize
Date: Tue, 29 Sep 2026 04:35:12 +0000	[thread overview]
Message-ID: <20260929043512.8963-1-linuxtestproject.agent@gmail.com> (raw)
In-Reply-To: <20260929022340.524-1-wegao@suse.com>

Hi Wei,

On Tue Sep 29 02:23:32 2026 +0000, Wei Gao wrote:
> memcontrol03: Bind to single CPU on systems with 64KB pagesize

> diff --git a/testcases/kernel/controllers/memcg/memcontrol03.c b/testcases/kernel/controllers/memcg/memcontrol03.c
> index 96224c4ee..6007d5588 100644
> --- a/testcases/kernel/controllers/memcg/memcontrol03.c
> +++ b/testcases/kernel/controllers/memcg/memcontrol03.c
> @@ -235,6 +235,23 @@ static void test_memcg_min(void)
>  	SAFE_UNLINK(TMPDIR"/tmpfile");
>  }
>  
> +static void setup(void)
> +{

Add #include <sched.h> to memcontrol03.c. The test relies on transitive
inclusion for sched_getcpu(), sched_setaffinity(), and cpu_set_t.

> +	if (getpagesize() >= 64 * 1024) {

Use SAFE_SYSCONF(_SC_PAGESIZE) instead of getpagesize(). The latter is a
legacy API removed in POSIX.1-2001, and memcontrol_common.h already uses
SAFE_SYSCONF(_SC_PAGESIZE).

> +		cpu_set_t mask;
> +		int cpu = sched_getcpu();
> +
> +		if (cpu < 0)
> +			tst_brk(TBROK | TERRNO, "sched_getcpu() failed");
> +
> +		tst_res(TINFO, "Page size >= 64KB, binding to CPU %d", cpu);
> +		CPU_ZERO(&mask);
> +		CPU_SET(cpu, &mask);
> +		if (sched_setaffinity(0, sizeof(mask), &mask))
> +			tst_brk(TBROK | TERRNO, "sched_setaffinity() failed");

On systems with CPU IDs >= 1024 (e.g. large ppc64le systems where
CONFIG_NR_CPUS can be up to 8192), cpu_set_t cannot represent cpu.
CPU_SET() will silently drop the bit, leaving mask empty and causing
sched_setaffinity() to fail with EINVAL. Allocate the mask dynamically
using CPU_ALLOC() or verify cpu < CPU_SETSIZE. Also, check the return
value of sched_setaffinity() with < 0.

Verdict - Needs revision

Pre-existing issues:
- Line 194: sleep(1) is used in a retry loop; use exponential backoff
  polling instead of fixed sleep (Ground Rule 2).
- Lines 166 and 235: string concatenation without spaces (TMPDIR"/tmpfile").

---
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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-09-29  4:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29  2:23 [LTP] [PATCH v1] memcontrol03: Bind to single CPU on systems with 64KB pagesize Wei Gao via ltp
2026-09-29  4:35 ` linuxtestproject.agent [this message]
2026-09-29 17:01 ` Michal Koutný via ltp
2026-09-30  3:53 ` [LTP] [PATCH v2 0/2] memcontrol03, memcontrol04: Bind test process to a single CPU Wei Gao via ltp
2026-09-30  3:53   ` [LTP] [PATCH v2 1/2] memcontrol: Add bind_to_current_cpu() helper Wei Gao via ltp
2026-09-30  8:11     ` [LTP] " linuxtestproject.agent
2026-09-30 11:25       ` Wei Gao via ltp
2026-09-30  3:53   ` [LTP] [PATCH v2 2/2] memcontrol03, memcontrol04: Bind test process to a single CPU Wei Gao via ltp
     [not found] ` <20260929-second-foyer-87225078267f@there>
2026-09-30  3:55   ` [LTP] [PATCH v1] memcontrol03: Bind to single CPU on systems with 64KB pagesize Wei Gao via ltp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260929043512.8963-1-linuxtestproject.agent@gmail.com \
    --to=linuxtestproject.agent@gmail.com \
    --cc=ltp@lists.linux.it \
    --cc=wegao@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.