[LTP] [Patch V2] lib: multiply the max_runtime if detect kernel debug options

Li Wang liwang@redhat.com
Tue Dec 10 09:48:13 CET 2024


On Mon, Dec 9, 2024 at 10:02 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > +/*
> > + * 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])) {
>
> I suppose that using tst_kconfig_check() here has a few flaws.
>
> First of all we are passing it one by one, which means that we are
> parsing the .config over and over. Also the tst_kconfig_check() is
> tailored to a special usecase where each of the strings is treated as an
> expression, which is slower. And lastly but not least will also print
> the "Constraint '%s' not satisfied" line for each option that is not set.
>
> We already have the tst_kconfig_var structure and tst_kconfig_read() so
> it would make more sense to use the simple interface as:
>
> static struct tst_kconfig_var debug_kconfigs[] = {
>         TST_KCONFIG_INIT("CONFIG_PROVE_LOCKING"),
>         ...
> };
>

This is a good suggestion, and besides, as I talked with Petr that I
would more like to name it "slow_kconfigs" but not "debug" prefix,
because the kernel configures is customized and maybe just enabled
partly on self-build kernel.

       if (tst_has_slow_kconfig())
               max_runtime *= 4;

And I agree all the rest comments.


> And then loop over the results as:
>
>         int is_debug_kernel = 0;
>
>         tst_kconfig_read(debug_kconfigs, ARRAY_SIZE(debug_kconfigs));
>
>         for (i = 0; i < ARRAY_SIZE(debug_kconfigs); i++) {
>                 if (debug_kconfigs[i].choice == 'y') {
>                         tst_res(TINFO,
>                                 "%s kernel debug option detected",
>                                 debug_kconfigs[i].id);
>                                 is_debug_kernel = 1;
>                 }
>         }
>
> > +                     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
> >
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
>

-- 
Regards,
Li Wang


More information about the ltp mailing list