Linux Test Project
 help / color / mirror / Atom feed
From: linuxtestproject.agent@gmail.com
To: Stephen Bertram <sbertram@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] semctl01: fix SEM_STAT failures under parallel LTP runs
Date: Thu, 30 Jul 2026 05:46:53 +0000	[thread overview]
Message-ID: <20260730054653.8948-1-linuxtestproject.agent@gmail.com> (raw)
In-Reply-To: <20260730044737.107415-1-sbertram@redhat.com>

Hi Stephen,

On Thu, 30 Jul 2026, Stephen Bertram wrote:
> semctl01: fix SEM_STAT failures under parallel LTP runs

>  static void func_iinfo(int hidx)
>  {
> +	/*
> +	 * Return value is the highest used index. Our set is alive, so the
> +	 * highest used index must be at least our index.
> +	 */
> +	if (hidx >= sem_index)
> +		tst_res(TPASS, "IPC_INFO highest index %d >= our index %d",
> +			hidx, sem_index);
> +	else
> +		tst_res(TFAIL, "IPC_INFO highest index %d < our index %d",
> +			hidx, sem_index);
>  }

The comment states the reason why this condition can never be false:
ipc_get_maxidx() returns the highest index over all live sets, and this
test's set is live for the whole iteration, so hidx >= sem_index always
holds.

That makes the IPC_INFO test case unconditionally pass. The previous
"hidx >= 0" check was equally weak, since semctl_info() returns 0 when
max_idx < 0, so this is not a regression, but since the function is being
touched anyway, would it make sense to check what IPC_INFO actually
returns in the buffer?

IPC_INFO fills struct seminfo with the namespace limits, so semmni,
semmsl and semopm could be compared against /proc/sys/kernel/sem.

> +static int get_sem_idx_from_id(int id)
> +{
> +	struct seminfo info;
> +	struct semid_ds dummy_ds;
> +	union semun arg;
> +	int max_idx, i;
> +
> +	arg.__buf = &info;
> +	/* SEM_INFO ignores semid; but SAFE_SEMCTL requires an lvalue */
> +	max_idx = SAFE_SEMCTL(id, 0, SEM_INFO, arg);
> +
> +	arg.buf = &dummy_ds;
> +	for (i = 0; i <= max_idx; i++) {
> +		/*
> +		 * Bare semctl: unused/unreadable indices fail with
> +		 * EINVAL/EACCES; SAFE_SEMCTL would abort the test.
> +		 */
> +		if (semctl(i, 0, SEM_STAT, arg) == id)
> +			return i;
> +	}
> +
> +	return -1;
>  }

This is a near-copy of get_shm_idx_from_id() in
testcases/kernel/syscalls/shmctl/shmctl01.c, and msgctl will need the
same thing for MSG_STAT.

Would it be worth putting a generic helper into libs/newipc with a
declaration in include/tse_newipc.h instead, so the three IPC families
share one implementation?

> +	if (buf.sem_nsems == PSEMS && buf.sem_perm.mode == (SEM_RA | NEWMODE))
> +		tst_res(TPASS, "id and semaphore STAT info are correct (id=%d)", sem_id);

> +		tst_res(TINFO, "sem_id=%d maps to kernel index=%d", sem_id, sem_index);

Nit: these two lines are 89 and 87 columns with tabs expanded. checkpatch
as vendored allows 100 so make check stays silent, but LTP code is
normally kept at 80.

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

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

      reply	other threads:[~2026-07-30  5:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14 16:49 [LTP] [PATCH v2] semctl: updates for multi worker testing Stephen Bertram via ltp
2026-04-14 17:15 ` [LTP] " linuxtestproject.agent
2026-07-20 22:49 ` [LTP] [PATCH v3] semctl01: tolerate SEM_STAT races under parallel LTP runs Stephen Bertram via ltp
2026-07-20 23:13   ` [LTP] " linuxtestproject.agent
2026-07-20 23:56   ` [LTP] [PATCH v4] " Stephen Bertram via ltp
2026-07-21  2:38     ` [LTP] " linuxtestproject.agent
2026-07-21 13:55     ` [LTP] [PATCH v5] " Stephen Bertram via ltp
2026-07-21 14:40       ` [LTP] " linuxtestproject.agent
2026-07-28 13:06       ` [LTP] [PATCH v5] " Andrea Cervesato via ltp
2026-07-28 16:23       ` [LTP] [PATCH v6] " Stephen Bertram via ltp
2026-07-28 17:31         ` [LTP] " linuxtestproject.agent
2026-07-28 20:33         ` [LTP] [PATCH v7] semctl01: look up SEM_STAT index for this test's sem_id Stephen Bertram via ltp
2026-07-28 21:12           ` [LTP] " linuxtestproject.agent
2026-07-29 14:53           ` [LTP] [PATCH v8] semctl01: fix SEM_STAT failures under parallel LTP runs Stephen Bertram via ltp
2026-07-29 16:26             ` [LTP] " linuxtestproject.agent
2026-07-29 17:56             ` [LTP] [PATCH v9] " Stephen Bertram via ltp
2026-07-29 18:14               ` [LTP] " linuxtestproject.agent
2026-07-29 19:33             ` [LTP] [PATCH v10] " Stephen Bertram via ltp
2026-07-29 20:20               ` [LTP] " linuxtestproject.agent
2026-07-29 21:00               ` [LTP] [PATCH v11] " Stephen Bertram via ltp
2026-07-29 22:07                 ` [LTP] " linuxtestproject.agent
2026-07-30  2:08                 ` [LTP] [PATCH v12] " Stephen Bertram via ltp
2026-07-30  2:19                   ` [LTP] " linuxtestproject.agent
2026-07-30  4:47                   ` [LTP] [PATCH v13] " Stephen Bertram via ltp
2026-07-30  5:46                     ` linuxtestproject.agent [this message]

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=20260730054653.8948-1-linuxtestproject.agent@gmail.com \
    --to=linuxtestproject.agent@gmail.com \
    --cc=ltp@lists.linux.it \
    --cc=sbertram@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox