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 <[email protected]> Cc: Guenter Roeck <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Will Deacon <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Marco Elver <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Gabriele Paoloni <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Clark Williams <[email protected]> Cc: Tao Zhou <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Daniel Bristot de Oliveira <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent ccc319d commit 135b881

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

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 <[email protected]>
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)