Skip to content

Commit 135b881

Browse files
Daniel Bristot de Oliveirarostedt
authored andcommitted
rv/reactor: Add the printk reactor
A reactor that printks the reaction message. Link: https://lkml.kernel.org/r/b65f18a7fd6dc6659a3008fd7b7392de3465d47b.1659052063.git.bristot@kernel.org Cc: Wim Van Sebroeck <wim@linux-watchdog.org> Cc: Guenter Roeck <linux@roeck-us.net> Cc: Jonathan Corbet <corbet@lwn.net> 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: Tao Zhou <tao.zhou@linux.dev> Cc: Randy Dunlap <rdunlap@infradead.org> 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> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent ccc319d commit 135b881

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

kernel/trace/rv/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ config RV_REACTORS
6060
on the model's execution. By default, the monitors have
6161
tracing reactions, printing the monitor output via tracepoints,
6262
but other reactions can be added (on-demand) via this interface.
63+
64+
config RV_REACT_PRINTK
65+
bool "Printk reactor"
66+
depends on RV_REACTORS
67+
default y
68+
help
69+
Enables the printk reactor. The printk reactor emits a printk()
70+
message if an exception is found.

kernel/trace/rv/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22

33
obj-$(CONFIG_RV) += rv.o
4-
obj-$(CONFIG_RV_REACTORS) += rv_reactors.o
54
obj-$(CONFIG_RV_MON_WIP) += monitors/wip/wip.o
65
obj-$(CONFIG_RV_MON_WWNR) += monitors/wwnr/wwnr.o
6+
obj-$(CONFIG_RV_REACTORS) += rv_reactors.o
7+
obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o

kernel/trace/rv/reactor_printk.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (C) 2019-2022 Red Hat, Inc. Daniel Bristot de Oliveira <bristot@kernel.org>
4+
*
5+
* Printk RV reactor:
6+
* Prints the exception msg to the kernel message log.
7+
*/
8+
#include <linux/ftrace.h>
9+
#include <linux/tracepoint.h>
10+
#include <linux/kernel.h>
11+
#include <linux/module.h>
12+
#include <linux/init.h>
13+
#include <linux/rv.h>
14+
15+
static void rv_printk_reaction(char *msg)
16+
{
17+
printk_deferred(msg);
18+
}
19+
20+
static struct rv_reactor rv_printk = {
21+
.name = "printk",
22+
.description = "prints the exception msg to the kernel message log.",
23+
.react = rv_printk_reaction
24+
};
25+
26+
static int register_react_printk(void)
27+
{
28+
rv_register_reactor(&rv_printk);
29+
return 0;
30+
}
31+
32+
static void unregister_react_printk(void)
33+
{
34+
rv_unregister_reactor(&rv_printk);
35+
}
36+
37+
module_init(register_react_printk);
38+
module_exit(unregister_react_printk);
39+
40+
MODULE_LICENSE("GPL");
41+
MODULE_AUTHOR("Daniel Bristot de Oliveira");
42+
MODULE_DESCRIPTION("printk rv reactor: printk if an exception is hit.");

0 commit comments

Comments
 (0)