Adds the instrumentation to the previously created wip monitor, as an
example of the developer work. It also adds a Makefile, Kconfig and
tracepoint entries.
This is a good example of the manual work that is left for the
developer to do.
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Marco Elver <elver@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Gabriele Paoloni <gpaoloni@redhat.com>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Clark Williams <williams@redhat.com>
Cc: linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-trace-devel@vger.kernel.org
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
---
include/trace/events/rv.h | 10 ++++++++++
kernel/trace/rv/Kconfig | 7 +++++++
kernel/trace/rv/Makefile | 1 +
kernel/trace/rv/monitors/wip/wip.c | 30 ++++++++++++++----------------
4 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/include/trace/events/rv.h b/include/trace/events/rv.h
index 9f40f2a49f84..4e0dabffcf29 100644
--- a/include/trace/events/rv.h
+++ b/include/trace/events/rv.h
@@ -56,6 +56,16 @@ DECLARE_EVENT_CLASS(error_da_monitor,
__entry->event,
__entry->state)
);
+
+#ifdef CONFIG_RV_MON_WIP
+DEFINE_EVENT(event_da_monitor, event_wip,
+ TP_PROTO(char *state, char *event, char *next_state, bool safe),
+ TP_ARGS(state, event, next_state, safe));
+
+DEFINE_EVENT(error_da_monitor, error_wip,
+ TP_PROTO(char *state, char *event),
+ TP_ARGS(state, event));
+#endif /* CONFIG_RV_MON_WIP */
#endif /* CONFIG_DA_MON_EVENTS_IMPLICIT */
#ifdef CONFIG_DA_MON_EVENTS_ID
diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig
index 1eafb5adcfcb..e9246b0bec9d 100644
--- a/kernel/trace/rv/Kconfig
+++ b/kernel/trace/rv/Kconfig
@@ -26,6 +26,13 @@ menuconfig RV
the system behavior.
if RV
+config RV_MON_WIP
+ depends on PREEMPTIRQ_TRACEPOINTS
+ select DA_MON_EVENTS_IMPLICIT
+ bool "WIP monitor"
+ help
+ Enable WIP sample monitor, this is a sample monitor that
+ illustrates the usage of per-cpu monitors.
config RV_REACTORS
bool "Runtime verification reactors"
diff --git a/kernel/trace/rv/Makefile b/kernel/trace/rv/Makefile
index 8944274d9b41..b41109d2750a 100644
--- a/kernel/trace/rv/Makefile
+++ b/kernel/trace/rv/Makefile
@@ -2,3 +2,4 @@
obj-$(CONFIG_RV) += rv.o
obj-$(CONFIG_RV_REACTORS) += rv_reactors.o
+obj-$(CONFIG_RV_MON_WIP) += monitors/wip/wip.o
diff --git a/kernel/trace/rv/monitors/wip/wip.c b/kernel/trace/rv/monitors/wip/wip.c
index 08950e09b823..123827db0a03 100644
--- a/kernel/trace/rv/monitors/wip/wip.c
+++ b/kernel/trace/rv/monitors/wip/wip.c
@@ -10,11 +10,9 @@
#define MODULE_NAME "wip"
-/*
- * XXX: include required tracepoint headers, e.g.,
- * #include <linux/trace/events/sched.h>
- */
#include <trace/events/rv.h>
+#include <trace/events/sched.h>
+#include <trace/events/preemptirq.h>
/*
* This is the self-generated part of the monitor. Generally, there is no need
@@ -37,17 +35,17 @@ DECLARE_DA_MON_PER_CPU(wip, char);
* are translated into model's event.
*
*/
-static void handle_preempt_disable(void *data, /* XXX: fill header */)
+static void handle_preempt_disable(void *data, unsigned long ip, unsigned long parent_ip)
{
da_handle_event_wip(preempt_disable_wip);
}
-static void handle_preempt_enable(void *data, /* XXX: fill header */)
+static void handle_preempt_enable(void *data, unsigned long ip, unsigned long parent_ip)
{
- da_handle_event_wip(preempt_enable_wip);
+ da_handle_init_event_wip(preempt_enable_wip);
}
-static void handle_sched_waking(void *data, /* XXX: fill header */)
+static void handle_sched_waking(void *data, struct task_struct *task)
{
da_handle_event_wip(sched_waking_wip);
}
@@ -60,9 +58,9 @@ static int start_wip(void)
if (retval)
return retval;
- rv_attach_trace_probe("wip", /* XXX: tracepoint */, handle_preempt_disable);
- rv_attach_trace_probe("wip", /* XXX: tracepoint */, handle_preempt_enable);
- rv_attach_trace_probe("wip", /* XXX: tracepoint */, handle_sched_waking);
+ rv_attach_trace_probe("wip", preempt_disable, handle_preempt_disable);
+ rv_attach_trace_probe("wip", preempt_enable, handle_preempt_enable);
+ rv_attach_trace_probe("wip", sched_waking, handle_sched_waking);
return 0;
}
@@ -71,9 +69,9 @@ static void stop_wip(void)
{
rv_wip.enabled = 0;
- rv_detach_trace_probe("wip", /* XXX: tracepoint */, handle_preempt_disable);
- rv_detach_trace_probe("wip", /* XXX: tracepoint */, handle_preempt_enable);
- rv_detach_trace_probe("wip", /* XXX: tracepoint */, handle_sched_waking);
+ rv_detach_trace_probe("wip", preempt_disable, handle_preempt_disable);
+ rv_detach_trace_probe("wip", preempt_enable, handle_preempt_enable);
+ rv_detach_trace_probe("wip", sched_waking, handle_sched_waking);
da_monitor_destroy_wip();
}
@@ -108,5 +106,5 @@ module_init(register_wip);
module_exit(unregister_wip);
MODULE_LICENSE("GPL");
-MODULE_AUTHOR("dot2k: auto-generated");
-MODULE_DESCRIPTION("wip");
+MODULE_AUTHOR("Daniel Bristot de Oliveira <bristot@kernel.org>");
+MODULE_DESCRIPTION("wip: wakeup in preemptive - per-cpu sample monitor.");
--
2.35.1
On 6/16/22 01:44, Daniel Bristot de Oliveira wrote: > diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig > index 1eafb5adcfcb..e9246b0bec9d 100644 > --- a/kernel/trace/rv/Kconfig > +++ b/kernel/trace/rv/Kconfig > @@ -26,6 +26,13 @@ menuconfig RV > the system behavior. > > if RV > +config RV_MON_WIP > + depends on PREEMPTIRQ_TRACEPOINTS > + select DA_MON_EVENTS_IMPLICIT > + bool "WIP monitor" Does WIP mean work-in-progress? (It does to me.) If not, please explain what it means in the help text. > + help > + Enable WIP sample monitor, this is a sample monitor that > + illustrates the usage of per-cpu monitors. thanks. -- ~Randy
On Thu, 16 Jun 2022 14:00:10 -0700 Randy Dunlap <rdunlap@infradead.org> wrote: > On 6/16/22 01:44, Daniel Bristot de Oliveira wrote: > > diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig > > index 1eafb5adcfcb..e9246b0bec9d 100644 > > --- a/kernel/trace/rv/Kconfig > > +++ b/kernel/trace/rv/Kconfig > > @@ -26,6 +26,13 @@ menuconfig RV > > the system behavior. > > > > if RV > > +config RV_MON_WIP > > + depends on PREEMPTIRQ_TRACEPOINTS > > + select DA_MON_EVENTS_IMPLICIT > > + bool "WIP monitor" > > Does WIP mean work-in-progress? (It does to me.) > > If not, please explain what it means in the help text. Yeah, that's exactly what I thought too ;-) -- Steve > > > + help > > + Enable WIP sample monitor, this is a sample monitor that > > + illustrates the usage of per-cpu monitors. > > thanks.
On 6/16/22 23:00, Randy Dunlap wrote: > > On 6/16/22 01:44, Daniel Bristot de Oliveira wrote: >> diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig >> index 1eafb5adcfcb..e9246b0bec9d 100644 >> --- a/kernel/trace/rv/Kconfig >> +++ b/kernel/trace/rv/Kconfig >> @@ -26,6 +26,13 @@ menuconfig RV >> the system behavior. >> >> if RV >> +config RV_MON_WIP >> + depends on PREEMPTIRQ_TRACEPOINTS >> + select DA_MON_EVENTS_IMPLICIT >> + bool "WIP monitor" > Does WIP mean work-in-progress? (It does to me.) > > If not, please explain what it means in the help text. > Wakeup in preemptive. I will add it to the description. Thanks Randy! -- Daniel
Hi Daniel,
I love your patch! Perhaps something to improve:
[auto build test WARNING on rostedt-trace/for-next]
[also build test WARNING on tip/sched/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Daniel-Bristot-de-Oliveira/The-Runtime-Verification-RV-interface/20220616-164837
base: https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git for-next
config: riscv-randconfig-r004-20220616 (https://download.01.org/0day-ci/archive/20220616/202206161937.RukeWKWk-lkp@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/a76032130de277ff6f39fc08277a70823fd85bf3
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Daniel-Bristot-de-Oliveira/The-Runtime-Verification-RV-interface/20220616-164837
git checkout a76032130de277ff6f39fc08277a70823fd85bf3
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash kernel/trace/rv/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
In file included from kernel/trace/rv/monitors/wip/wip.c:8:
kernel/trace/rv/monitors/wip/wip.c: In function 'start_wip':
include/rv/instrumentation.h:15:17: error: implicit declaration of function 'check_trace_callback_type_preempt_disable'; did you mean 'check_trace_callback_type_irq_disable'? [-Werror=implicit-function-declaration]
15 | check_trace_callback_type_##tp(rv_handler); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/rv/monitors/wip/wip.c:61:9: note: in expansion of macro 'rv_attach_trace_probe'
61 | rv_attach_trace_probe("wip", preempt_disable, handle_preempt_disable);
| ^~~~~~~~~~~~~~~~~~~~~
In file included from include/linux/printk.h:11,
from include/linux/kernel.h:29,
from include/linux/interrupt.h:6,
from include/linux/trace_recursion.h:5,
from include/linux/ftrace.h:10,
from kernel/trace/rv/monitors/wip/wip.c:2:
include/rv/instrumentation.h:16:27: error: implicit declaration of function 'register_trace_preempt_disable'; did you mean 'register_trace_prio_irq_disable'? [-Werror=implicit-function-declaration]
16 | WARN_ONCE(register_trace_##tp(rv_handler, NULL), \
| ^~~~~~~~~~~~~~~
include/linux/once_lite.h:15:41: note: in definition of macro 'DO_ONCE_LITE_IF'
15 | bool __ret_do_once = !!(condition); \
| ^~~~~~~~~
include/rv/instrumentation.h:16:17: note: in expansion of macro 'WARN_ONCE'
16 | WARN_ONCE(register_trace_##tp(rv_handler, NULL), \
| ^~~~~~~~~
kernel/trace/rv/monitors/wip/wip.c:61:9: note: in expansion of macro 'rv_attach_trace_probe'
61 | rv_attach_trace_probe("wip", preempt_disable, handle_preempt_disable);
| ^~~~~~~~~~~~~~~~~~~~~
In file included from kernel/trace/rv/monitors/wip/wip.c:8:
include/rv/instrumentation.h:15:17: error: implicit declaration of function 'check_trace_callback_type_preempt_enable'; did you mean 'check_trace_callback_type_irq_enable'? [-Werror=implicit-function-declaration]
15 | check_trace_callback_type_##tp(rv_handler); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/rv/monitors/wip/wip.c:62:9: note: in expansion of macro 'rv_attach_trace_probe'
62 | rv_attach_trace_probe("wip", preempt_enable, handle_preempt_enable);
| ^~~~~~~~~~~~~~~~~~~~~
In file included from include/linux/printk.h:11,
from include/linux/kernel.h:29,
from include/linux/interrupt.h:6,
from include/linux/trace_recursion.h:5,
from include/linux/ftrace.h:10,
from kernel/trace/rv/monitors/wip/wip.c:2:
include/rv/instrumentation.h:16:27: error: implicit declaration of function 'register_trace_preempt_enable'; did you mean 'register_trace_prio_irq_enable'? [-Werror=implicit-function-declaration]
16 | WARN_ONCE(register_trace_##tp(rv_handler, NULL), \
| ^~~~~~~~~~~~~~~
include/linux/once_lite.h:15:41: note: in definition of macro 'DO_ONCE_LITE_IF'
15 | bool __ret_do_once = !!(condition); \
| ^~~~~~~~~
include/rv/instrumentation.h:16:17: note: in expansion of macro 'WARN_ONCE'
16 | WARN_ONCE(register_trace_##tp(rv_handler, NULL), \
| ^~~~~~~~~
kernel/trace/rv/monitors/wip/wip.c:62:9: note: in expansion of macro 'rv_attach_trace_probe'
62 | rv_attach_trace_probe("wip", preempt_enable, handle_preempt_enable);
| ^~~~~~~~~~~~~~~~~~~~~
In file included from kernel/trace/rv/monitors/wip/wip.c:8:
kernel/trace/rv/monitors/wip/wip.c: In function 'stop_wip':
include/rv/instrumentation.h:22:17: error: implicit declaration of function 'unregister_trace_preempt_disable'; did you mean 'unregister_trace_irq_disable'? [-Werror=implicit-function-declaration]
22 | unregister_trace_##tp(rv_handler, NULL); \
| ^~~~~~~~~~~~~~~~~
kernel/trace/rv/monitors/wip/wip.c:72:9: note: in expansion of macro 'rv_detach_trace_probe'
72 | rv_detach_trace_probe("wip", preempt_disable, handle_preempt_disable);
| ^~~~~~~~~~~~~~~~~~~~~
include/rv/instrumentation.h:22:17: error: implicit declaration of function 'unregister_trace_preempt_enable'; did you mean 'unregister_trace_irq_enable'? [-Werror=implicit-function-declaration]
22 | unregister_trace_##tp(rv_handler, NULL); \
| ^~~~~~~~~~~~~~~~~
kernel/trace/rv/monitors/wip/wip.c:73:9: note: in expansion of macro 'rv_detach_trace_probe'
73 | rv_detach_trace_probe("wip", preempt_enable, handle_preempt_enable);
| ^~~~~~~~~~~~~~~~~~~~~
kernel/trace/rv/monitors/wip/wip.c: At top level:
>> kernel/trace/rv/monitors/wip/wip.c:91:5: warning: no previous prototype for 'register_wip' [-Wmissing-prototypes]
91 | int register_wip(void)
| ^~~~~~~~~~~~
>> kernel/trace/rv/monitors/wip/wip.c:97:6: warning: no previous prototype for 'unregister_wip' [-Wmissing-prototypes]
97 | void unregister_wip(void)
| ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/register_wip +91 kernel/trace/rv/monitors/wip/wip.c
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 90
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 @91 int register_wip(void)
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 92 {
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 93 rv_register_monitor(&rv_wip);
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 94 return 0;
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 95 }
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 96
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 @97 void unregister_wip(void)
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 98 {
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 99 if (rv_wip.enabled)
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 100 stop_wip();
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 101
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 102 rv_unregister_monitor(&rv_wip);
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 103 }
15679ffb99664f Daniel Bristot de Oliveira 2022-06-16 104
--
0-DAY CI Kernel Test Service
https://01.org/lkp
© 2016 - 2025 Red Hat, Inc.