Skip to content

Commit

Permalink
lib: multiply the max_runtime if detect slow kconfigs
Browse files Browse the repository at this point in the history
The method adjusts the max_runtime for test cases by multiplying
it by a factor (4x) if any slower 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 <[email protected]>
Reviewed-by: Petr Vorel <[email protected]>
Reviewed-by: Cyril Hrubis <[email protected]>
  • Loading branch information
wangli5665 committed Dec 18, 2024
1 parent 1d8f6b5 commit 2da30df
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/tst_kconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,16 @@ struct tst_kcmdline_var {
*/
void tst_kcmdline_parse(struct tst_kcmdline_var params[], size_t params_len);

/*
* tst_has_slow_kconfig() - Check if any performance-degrading kernel configs are enabled.
*
* This function iterates over the list of slow kernel configuration options
* (`tst_slow_kconfigs`) and checks if any of them are enabled in the running kernel.
*
* Return:
* - 1 if at least one slow kernel config is enabled.
* - 0 if none of the slow kernel configs are enabled.
*/
int tst_has_slow_kconfig(void);

#endif /* TST_KCONFIG_H__ */
38 changes: 38 additions & 0 deletions lib/tst_kconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,41 @@ void tst_kcmdline_parse(struct tst_kcmdline_var params[], size_t params_len)

SAFE_FCLOSE(f);
}

/*
* List of kernel config options that may degrade performance when enabled.
*/
static struct tst_kconfig_var slow_kconfigs[] = {
TST_KCONFIG_INIT("CONFIG_PROVE_LOCKING"),
TST_KCONFIG_INIT("CONFIG_LOCKDEP"),
TST_KCONFIG_INIT("CONFIG_DEBUG_SPINLOCK"),
TST_KCONFIG_INIT("CONFIG_DEBUG_RT_MUTEXES"),
TST_KCONFIG_INIT("CONFIG_DEBUG_MUTEXES"),
TST_KCONFIG_INIT("CONFIG_KASAN"),
TST_KCONFIG_INIT("CONFIG_SLUB_RCU_DEBUG"),
TST_KCONFIG_INIT("CONFIG_TRACE_IRQFLAGS"),
TST_KCONFIG_INIT("CONFIG_LATENCYTOP"),
TST_KCONFIG_INIT("CONFIG_DEBUG_NET"),
TST_KCONFIG_INIT("CONFIG_EXT4_DEBUG"),
TST_KCONFIG_INIT("CONFIG_QUOTA_DEBUG"),
TST_KCONFIG_INIT("CONFIG_FAULT_INJECTION"),
TST_KCONFIG_INIT("CONFIG_DEBUG_OBJECTS")
};

int tst_has_slow_kconfig(void)
{
unsigned int i;

tst_kconfig_read(slow_kconfigs, ARRAY_SIZE(slow_kconfigs));

for (i = 0; i < ARRAY_SIZE(slow_kconfigs); i++) {
if (slow_kconfigs[i].choice == 'y') {
tst_res(TINFO,
"%s kernel option detected which might slow the execution",
slow_kconfigs[i].id);
return 1;
}
}

return 0;
}
3 changes: 3 additions & 0 deletions lib/tst_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@ static int multiply_runtime(int max_runtime)

parse_mul(&runtime_mul, "LTP_RUNTIME_MUL", 0.0099, 100);

if (tst_has_slow_kconfig())
max_runtime *= 4;

return max_runtime * runtime_mul;
}

Expand Down

0 comments on commit 2da30df

Please sign in to comment.