[LTP] [PATCH v5] semctl01: tolerate SEM_STAT races under parallel LTP runs

Andrea Cervesato andrea.cervesato@suse.com
Tue Jul 28 15:06:14 CEST 2026


Hi Stephen,

> +/*
> + * SEM_STAT takes an ipc idr index. Under parallel IPC tests that index can
> + * vanish between IPC_INFO and SEM_STAT (EIDRM/EINVAL). Refresh and retry.
> + */
> +static int do_sem_stat(union semun arg)
> +{
> +	int idx;
> +	unsigned int retries = 5;
> +
> +	do {
> +		int info_id = 0;
> +
> +		idx = SAFE_SEMCTL(info_id, 0, IPC_INFO, (union semun)&ipc_buf);
> +		TEST(semctl(idx, 0, SEM_STAT, arg));
> +		if (TST_RET >= 0)
> +			return TST_RET;
> +		if (TST_ERR != EIDRM && TST_ERR != EINVAL)
> +			tst_brk(TBROK | TERRNO, "semctl(SEM_STAT)");
> +	} while (--retries);
> +
> +	tst_brk(TBROK | TERRNO, "semctl(SEM_STAT) still failing after retries");
> +	return -1;
> +}
> +

In LTP we have TST_RETRY_FUNC/TST_RETRY_FN_EXP_BACKOFF, please use
this one instead.

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com


More information about the ltp mailing list