[LTP] [PATCH 1/2] lib/checkpoint: add configurable timeout for checkpoint wake
Vasileios Almpanis
vasileios.almpanis@virtuozzo.com
Mon Mar 30 12:20:24 CEST 2026
tst_safe_checkpoint_wake() always used DEFAULT_MSEC_TIMEOUT (10s) for
tst_checkpoint_wake(), which is too short when parents wait much longer
(e.g. slow storage, KASAN, lockdep) while children allocate memory before
they reach the matching checkpoint wait.
Extend tst_safe_checkpoint_wake(..., msec_timeout) so callers can pass an
explicit millisecond budget; msec_timeout 0 preserves the previous 10s
default.
Add TST_CHECKPOINT_WAKE_TIMEOUT and TST_CHECKPOINT_WAKE2_TIMEOUT macros.
Existing TST_CHECKPOINT_WAKE*, TST_CHECKPOINT_WAKE2, and
TST_CHECKPOINT_WAKE_AND_WAIT pass 0 for the new argument so behavior is
unchanged unless tests opt in.
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
include/tst_checkpoint.h | 41 ++++++++++++++++++++++++++++++++-----
include/tst_checkpoint_fn.h | 2 +-
lib/tst_checkpoint.c | 9 ++++++--
3 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/include/tst_checkpoint.h b/include/tst_checkpoint.h
index f202dd03d..36089c1c5 100644
--- a/include/tst_checkpoint.h
+++ b/include/tst_checkpoint.h
@@ -57,7 +57,7 @@
* was reached the function calls tst_brk(TBROK, ...) which exits the test.
*/
#define TST_CHECKPOINT_WAKE(id) \
- tst_safe_checkpoint_wake(__FILE__, __LINE__, NULL, id, 1)
+ tst_safe_checkpoint_wake(__FILE__, __LINE__, NULL, id, 1, 0)
/**
* TST_CHECKPOINT_WAKE2() - Wakes up several checkpoints.
@@ -66,13 +66,44 @@
* @nr_wake: A number of processes to wake.
*
* Wakes up nr_wake processes suspended on a checkpoint and retries if there
- * wasn't enough process suspended on the checkpoint yet. The call does not
+ * weren't enough processes suspended on the checkpoint yet. The call does not
* retry indefinitely but gives up if it does not wake nr_wake processes after
* 10 seconds. If an error happened or timeout was reached the function calls
* tst_brk(TBROK, ...) which exits the test.
*/
#define TST_CHECKPOINT_WAKE2(id, nr_wake) \
- tst_safe_checkpoint_wake(__FILE__, __LINE__, NULL, id, nr_wake)
+ tst_safe_checkpoint_wake(__FILE__, __LINE__, NULL, id, nr_wake, 0)
+
+/**
+ * TST_CHECKPOINT_WAKE_TIMEOUT() - Wakes up a checkpoint.
+ *
+ * @id: A checkpoint id a positive integer.
+ * @msec_timeout: A timeout.
+ *
+ * Wakes up a process suspended on a checkpoint and retries if there is no
+ * process suspended on the checkpoint yet. The call does not retry
+ * indefinitely but gives up if it does not wake a process after the timeout.
+ * If an error happened or timeout was reached the function calls
+ * tst_brk(TBROK, ...) which exits the test.
+ */
+#define TST_CHECKPOINT_WAKE_TIMEOUT(id, msec_timeout) \
+ tst_safe_checkpoint_wake(__FILE__, __LINE__, NULL, id, 1, msec_timeout)
+
+/**
+ * TST_CHECKPOINT_WAKE2_TIMEOUT() - Wakes up several checkpoints.
+ *
+ * @id: A checkpoint id a positive integer.
+ * @nr_wake: A number of processes to wake.
+ * @msec_timeout: A timeout.
+ *
+ * Wakes up nr_wake processes suspended on a checkpoint and retries if there
+ * weren't enough processes suspended on the checkpoint yet. The call does not
+ * retry indefinitely but gives up if it does not wake nr_wake processes after
+ * the timeout. If an error happened or timeout was reached the function calls
+ * tst_brk(TBROK, ...) which exits the test.
+ */
+#define TST_CHECKPOINT_WAKE2_TIMEOUT(id, nr_wake, msec_timeout) \
+ tst_safe_checkpoint_wake(__FILE__, __LINE__, NULL, id, nr_wake, msec_timeout)
/**
* TST_CHECKPOINT_WAKE_AND_WAIT() - Wakes up a checkpoint and immediately waits on it.
@@ -82,8 +113,8 @@
* This is a combination of TST_CHECKPOINT_WAKE() and TST_CHECKPOINT_WAIT().
*/
#define TST_CHECKPOINT_WAKE_AND_WAIT(id) do { \
- tst_safe_checkpoint_wake(__FILE__, __LINE__, NULL, id, 1); \
- tst_safe_checkpoint_wait(__FILE__, __LINE__, NULL, id, 0); \
+ tst_safe_checkpoint_wake(__FILE__, __LINE__, NULL, id, 1, 0); \
+ tst_safe_checkpoint_wait(__FILE__, __LINE__, NULL, id, 0); \
} while (0)
#endif /* TST_CHECKPOINT__ */
diff --git a/include/tst_checkpoint_fn.h b/include/tst_checkpoint_fn.h
index e061e00b9..13196b323 100644
--- a/include/tst_checkpoint_fn.h
+++ b/include/tst_checkpoint_fn.h
@@ -30,6 +30,6 @@ void tst_safe_checkpoint_wait(const char *file, const int lineno,
void tst_safe_checkpoint_wake(const char *file, const int lineno,
void (*cleanup_fn)(void), unsigned int id,
- unsigned int nr_wake);
+ unsigned int nr_wake, unsigned int msec_timeout);
#endif /* TST_CHECKPOINT_FN__ */
diff --git a/lib/tst_checkpoint.c b/lib/tst_checkpoint.c
index f2faf6563..b9e6443e0 100644
--- a/lib/tst_checkpoint.c
+++ b/lib/tst_checkpoint.c
@@ -100,9 +100,14 @@ void tst_safe_checkpoint_wait(const char *file, const int lineno,
void tst_safe_checkpoint_wake(const char *file, const int lineno,
void (*cleanup_fn)(void), unsigned int id,
- unsigned int nr_wake)
+ unsigned int nr_wake, unsigned int msec_timeout)
{
- int ret = tst_checkpoint_wake(id, nr_wake, DEFAULT_MSEC_TIMEOUT);
+ int ret;
+
+ if (!msec_timeout)
+ msec_timeout = DEFAULT_MSEC_TIMEOUT;
+
+ ret = tst_checkpoint_wake(id, nr_wake, msec_timeout);
if (ret) {
tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
--
2.43.0
More information about the ltp
mailing list