From 0e36ed33568ffcd31de80b05995abce637ce9ca4 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Thu, 23 Jun 2022 18:04:35 +0100 Subject: [PATCH 1/3] lisa._kmod: Use make -j for modules Use make -j in order to speedup module build. --- lisa/_kmod.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisa/_kmod.py b/lisa/_kmod.py index dcc46af1e..ce4396046 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): -- GitLab From a6a09e378af85e7ba0474d026f84e46f18ddbe28 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Thu, 23 Jun 2022 17:04:08 +0100 Subject: [PATCH 2/3] lisa._assets.kmodules.sched_tp: tp.h: Split enable/disable functions from feature definition Refactor so that it's possible to create the tracepoint-based enable/disable functions without defining the feature. This would allow features using tracepoints among other things to reuse the registering/deregistering logic. --- lisa/_assets/kmodules/sched_tp/tp.h | 35 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lisa/_assets/kmodules/sched_tp/tp.h b/lisa/_assets/kmodules/sched_tp/tp.h index 5faa3cfd2..8e929f1d0 100644 --- a/lisa/_assets/kmodules/sched_tp/tp.h +++ b/lisa/_assets/kmodules/sched_tp/tp.h @@ -22,22 +22,9 @@ __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; \ @@ -63,7 +50,7 @@ __attribute__((unused)) static struct tracepoint *__find_tracepoint(const char * } \ 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 +68,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); /** -- GitLab From eec954329f1719e07bfa71be648b3a22b331d0e4 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Fri, 24 Jun 2022 15:09:03 +0100 Subject: [PATCH 3/3] lisa._assets.kmodules.sched_tp: tp.h: Fix tp feature init FIX Fix tracepoint features init when the custom enable function does not succeed. It used to still register the tracepoint, leading to the probe assuming setup has been done when it has not. Instead, only register the tracepoint if the enable function succeeded. --- lisa/_assets/kmodules/sched_tp/tp.h | 41 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/lisa/_assets/kmodules/sched_tp/tp.h b/lisa/_assets/kmodules/sched_tp/tp.h index 8e929f1d0..27e54be87 100644 --- a/lisa/_assets/kmodules/sched_tp/tp.h +++ b/lisa/_assets/kmodules/sched_tp/tp.h @@ -29,24 +29,31 @@ __attribute__((unused)) static struct tracepoint *__find_tracepoint(const char * 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; \ } \ -- GitLab