[LTP] semctl: updates for multi worker testing.
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Tue Apr 14 19:15:12 CEST 2026
Hi Stephen,
On Tue, 14 Apr 2026, Stephen Bertram wrote:
> semctl: updates for multi worker testing.
>
> Changed semctl01, which required updates to
> reduce interference and provide an allowance
> for EINVAL and EIDRM failures.
The body should say *why* multi-worker support is needed — what harness
or runner exercises this in parallel, or what failure prompted the change.
> -static int sem_id = -1;
> -static int sem_index;
> +static __thread int sem_id = -1;
> +static __thread int sem_index;
> static struct semid_ds buf;
> static struct seminfo ipc_buf;
> static unsigned short array[PSEMS];
> static struct sembuf sops;
> static int pid_arr[NCHILD];
buf, ipc_buf, array, sops, pid_arr are still plain globals. Making only
sem_id/sem_index TLS leaves all the helper functions that read/write
these globals unsafe for concurrent use, so the parallelisation is
incomplete.
[...]
> + if (sid == -1)
> + sem_id = sid = SAFE_SEMGET(IPC_PRIVATE, PSEMS,
> + IPC_CREAT | IPC_EXCL | SEM_RA);
cleanup() runs in the main thread and only sees the main thread's TLS
sem_id. Worker threads that hit this path will leak their semaphore sets.
Either track all allocated IDs in a shared, mutex-protected list, or drop
__thread and keep the test single-threaded.
Also note struct tcases::semid is now always NULL and never read; the
field can be removed.
---
Note:
Our agent completed the review of the patch. The full review can be
found at: https://patchwork.ozlabs.org/project/ltp/list/?series=499874
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.
More information about the ltp
mailing list