[LTP] [Patch V2] lib: multiply the max_runtime if detect kernel debug options
Li Wang
liwang@redhat.com
Sat Dec 7 09:57:54 CET 2024
The method adjusts the max_runtime for test cases by multiplying
it by a factor (4x) if any debug kernel options are detected.
Debug kernel configurations (such as CONFIG_KASAN, CONFIG_PROVE_LOCKING, etc.)
are known to degrade performance, and this adjustment ensures
that tests do not fail prematurely due to timeouts.
As Cyril pointed out that a debug kernel will typically run
slower by a factor of N, and while determining the exact value
of N is challenging, so a reasonable upper bound is sufficient
for practical purposes.
Signed-off-by: Li Wang <liwang@redhat.com>
---
Notes:
Hi, @Cyril, @Petr, I have no openSUSE and Ubuntu at my hands, could you
help check if the debug configures are useful to the other two platforms?
Or, should we add any more options there? Thanks.
include/tst_kconfig.h | 24 ++++++++++++++++++++++++
lib/tst_kconfig.c | 14 ++++++++++++++
lib/tst_test.c | 3 +++
3 files changed, 41 insertions(+)
diff --git a/include/tst_kconfig.h b/include/tst_kconfig.h
index 23f807409..18856df87 100644
--- a/include/tst_kconfig.h
+++ b/include/tst_kconfig.h
@@ -98,4 +98,28 @@ struct tst_kcmdline_var {
*/
void tst_kcmdline_parse(struct tst_kcmdline_var params[], size_t params_len);
+/*
+ * List of debug-kernel config options that may degrade performance when enabled.
+ */
+static const char * const tst_kconf_debug_options[][2] = {
+ {"CONFIG_PROVE_LOCKING=y", NULL},
+ {"CONFIG_LOCKDEP=y", NULL},
+ {"CONFIG_DEBUG_SPINLOCK=y", NULL},
+ {"CONFIG_DEBUG_RT_MUTEXES=y", NULL},
+ {"CONFIG_DEBUG_MUTEXES=y", NULL},
+ {"CONFIG_DEBUG_PAGEALLOC=y", NULL},
+ {"CONFIG_KASAN=y", NULL},
+ {"CONFIG_SLUB_RCU_DEBUG=y", NULL},
+ {"CONFIG_TRACE_IRQFLAGS=y", NULL},
+ {"CONFIG_LATENCYTOP=y", NULL},
+ {"CONFIG_DEBUG_NET=y", NULL},
+ {"CONFIG_EXT4_DEBUG=y", NULL},
+ {"CONFIG_QUOTA_DEBUG=y", NULL},
+ {"CONFIG_FAULT_INJECTION=y", NULL},
+ {"CONFIG_DEBUG_OBJECTS=y", NULL},
+ {NULL, NULL}
+};
+
+int tst_any_kconfig_debug_enabled(void);
+
#endif /* TST_KCONFIG_H__ */
diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
index 6d6b1da18..a99147a62 100644
--- a/lib/tst_kconfig.c
+++ b/lib/tst_kconfig.c
@@ -631,3 +631,17 @@ void tst_kcmdline_parse(struct tst_kcmdline_var params[], size_t params_len)
SAFE_FCLOSE(f);
}
+
+int tst_any_kconfig_debug_enabled(void)
+{
+ int i;
+
+ for (i = 0; tst_kconf_debug_options[i][0] != NULL; i++) {
+ if(!tst_kconfig_check(tst_kconf_debug_options[i])) {
+ tst_res(TINFO, "Detected kernel debug options. Likely running on a debug kernel");
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 8db554dea..00ac8f4f3 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -555,6 +555,9 @@ static int multiply_runtime(int max_runtime)
parse_mul(&runtime_mul, "LTP_RUNTIME_MUL", 0.0099, 100);
+ if (tst_any_kconfig_debug_enabled())
+ max_runtime *= 4;
+
return max_runtime * runtime_mul;
}
--
2.47.0
More information about the ltp
mailing list