diff --git a/lisa/_assets/kmodules/sched_tp/tp.h b/lisa/_assets/kmodules/sched_tp/tp.h index 5faa3cfd248c0b5a6f5e910fbb4684aa1076f4f9..27e54be876e38803bdda9f269582920c5fa0ff99 100644 --- a/lisa/_assets/kmodules/sched_tp/tp.h +++ b/lisa/_assets/kmodules/sched_tp/tp.h @@ -22,48 +22,42 @@ __attribute__((unused)) static struct tracepoint *__find_tracepoint(const char * return res.found; } -/** - * DEFINE_EXTENDED_TP_FEATURE() - Define a feature linked to a tracepoint. - * @feature_name: Name of the feature. - * @tp_name: Name of the tracepoint to attach to. - * @probe: Probe function passed to the relevant tracepoint registering function register_trace_*(). - * @enable_f: Additional enable function for the feature. It must take a struct - * feature * and return a non-zero int in case of failure. - * @disable_f: Additional disable function for the feature. Same signature as enable_f(). - * - * Define a feature with a probe attached to a tracepoint, with additional - * user-defined enable/disable functions. If the tracepoint is not found, the - * user functions will not be called. - */ -#define DEFINE_EXTENDED_TP_FEATURE(feature_name, tp_name, probe, enable_f, disable_f) \ +#define DEFINE_TP_ENABLE_DISABLE(feature_name, tp_name, probe, enable_name, enable_f, disable_name, disable_f) \ static bool __feature_tp_registered_##feature_name = false; \ - static int __tp_feature_enable_##feature_name(struct feature* feature) { \ + static int enable_name(struct feature* feature) { \ int ret = 0; \ int __ret; \ struct tracepoint *tp; \ int (*_enable_f)(struct feature*) = enable_f; \ - ret |= ENABLE_FEATURE(__tp); \ - tp = __find_tracepoint(#tp_name); \ - if (tp) { \ - if (_enable_f) { \ - __ret = _enable_f(feature); \ - ret |= __ret; \ - if (__ret) \ - pr_err(#feature_name ": init function " #enable_f "() failed with error: %i\n", __ret); \ + __ret = ENABLE_FEATURE(__tp); \ + ret |= __ret; \ + if (ret) { \ + pr_err(#feature_name ": could not enable tracepoint support: %i\n", __ret); \ + } else { \ + tp = __find_tracepoint(#tp_name); \ + if (tp) { \ + if (_enable_f) { \ + __ret = _enable_f(feature); \ + ret |= __ret; \ + if (__ret) \ + pr_err(#feature_name ": init function " #enable_f "() failed with error: %i\n", __ret); \ + } \ + if (!ret) { \ + __ret = tracepoint_probe_register(tp, (void *)probe, feature); \ + ret |= __ret; \ + if (__ret) \ + pr_err(#feature_name ": could not attach " #probe "() to tracepoint " #tp_name "\n"); \ + } \ + __feature_tp_registered_##feature_name = !ret; \ + return ret; \ + } else { \ + pr_err(#feature_name ": could not attach " #probe "() to undefined tracepoint " #tp_name "\n"); \ + ret |= 1; \ } \ - __ret = tracepoint_probe_register(tp, (void *)probe, feature); \ - ret |= __ret; \ - if (__ret) \ - pr_err(#feature_name ": could not attach " #probe "() to tracepoint " #tp_name "\n"); \ - __feature_tp_registered_##feature_name = !__ret; \ - return ret; \ - } else { \ - pr_err(#feature_name ": could not attach " #probe "() to undefined tracepoint " #tp_name "\n"); \ - ret |= 1; \ } \ return ret; \ } \ - static int __tp_feature_disable_##feature_name(struct feature* feature) { \ + static int disable_name(struct feature* feature) { \ int ret = 0; \ int __ret; \ int (*_disable_f)(struct feature*) = disable_f; \ @@ -81,6 +75,22 @@ __attribute__((unused)) static struct tracepoint *__find_tracepoint(const char * ret |= DISABLE_FEATURE(__tp); \ return ret; \ } \ + +/** + * DEFINE_EXTENDED_TP_FEATURE() - Define a feature linked to a tracepoint. + * @feature_name: Name of the feature. + * @tp_name: Name of the tracepoint to attach to. + * @probe: Probe function passed to the relevant tracepoint registering function register_trace_*(). + * @enable_f: Additional enable function for the feature. It must take a struct + * feature * and return a non-zero int in case of failure. + * @disable_f: Additional disable function for the feature. Same signature as enable_f(). + * + * Define a feature with a probe attached to a tracepoint, with additional + * user-defined enable/disable functions. If the tracepoint is not found, the + * user functions will not be called. + */ +#define DEFINE_EXTENDED_TP_FEATURE(feature_name, tp_name, probe, enable_f, disable_f) \ + DEFINE_TP_ENABLE_DISABLE(feature_name, tp_name, probe, __tp_feature_enable_##feature_name, enable_f, __tp_feature_disable_##feature_name, disable_f); \ DEFINE_FEATURE(feature_name, __tp_feature_enable_##feature_name, __tp_feature_disable_##feature_name); /** diff --git a/lisa/_kmod.py b/lisa/_kmod.py index dcc46af1eddee238d6965730a4f6a0d64cb0c5b8..ce4396046c31079e664bb78f48628c86dc1cc472 100644 --- a/lisa/_kmod.py +++ b/lisa/_kmod.py @@ -1582,7 +1582,9 @@ class KmodSrc(Loggable): for name, value in sorted(make_vars.items()) if value is not None ] - cmd = ['make', '-C', tree_path, *make_vars, 'modules'] + + nr_cpus = int(os.cpu_count() * 1.5) + cmd = ['make', f'-j{nr_cpus}', '-C', tree_path, *make_vars, 'modules'] return cmd def find_mod_file(path):