public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [Patch V2] lib: multiply the max_runtime if detect kernel debug options
Date: Sat,  7 Dec 2024 16:57:54 +0800	[thread overview]
Message-ID: <20241207085754.159597-1-liwang@redhat.com> (raw)

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2024-12-07  8:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-07  8:57 Li Wang [this message]
2024-12-09  4:43 ` [LTP] [Patch V2] lib: multiply the max_runtime if detect kernel debug options Petr Vorel
2024-12-09  6:36   ` Li Wang
2024-12-09 12:14     ` Petr Vorel
2024-12-09 14:02 ` Cyril Hrubis
2024-12-10  8:48   ` Li Wang
2024-12-10  8:58     ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241207085754.159597-1-liwang@redhat.com \
    --to=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox