[LTP] [PATCH] syscalls/fork13: Rewrite to new API + add .max_runtime

Petr Vorel pvorel@suse.cz
Thu Jun 16 23:43:10 CEST 2022


Hi Cyril,

> This fixes a problem we had for years, the test can run for more than
> half an hour on slow systems and it used to timeout quite often.
+1

> This commit introduces a max_runtime with a 10 minute limit which is
> more than enough for the test to complete on a modern hardware but at
> the same time it limits the runtime to a sensible value on older
> hardware and embedded.
+1

Original implementation was quite nicely written (at least some parts were
reused), which clearly demonstrates advantages of new LTP API.

LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

I'd just formatted the doc differently:

/*\
 * [Description]
 *
 * A race in pid generation that causes pids to be reused immediately
 *
 * From the mainline commit 5fdee8c4a5e1800489ce61963208f8cc55e42ea1:
 *
 * A program that repeatedly forks and waits is susceptible to having
 * the same pid repeated, especially when it competes with another
 * instance of the same program.  This is really bad for bash
 * implementation.  Furthermore, many shell scripts assume that pid
 * numbers will not be used for some length of time.
 *
 * [Race Description]
 * ---------------------------------------------------------------------
 * A                                   B
 *
 * // pid == offset == n               // pid == offset == n + 1
 * test_and_set_bit(offset, map->page)
 *                                     test_and_set_bit(offset, map->page);
 *                                     pid_ns->last_pid = pid;
 * pid_ns->last_pid = pid;
 *                                     // pid == n + 1 is freed (wait())
 *
 *                                     // Next fork()...
 *                                     last = pid_ns->last_pid; // == n
 *                                     pid = last + 1;
 * ---------------------------------------------------------------------
 */

Kind regards,
Petr


More information about the ltp mailing list