Linux Trace Kernel
 help / color / mirror / Atom feed
From: Gabriele Monaco <gmonaco@redhat.com>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Gabriele Monaco <gmonaco@redhat.com>,
	Masami Hiramatsu <mhiramat@kernel.org>
Cc: Nam Cao <namcao@linutronix.de>,
	Thomas Weissschuh <thomas.weissschuh@linutronix.de>,
	Tomas Glozar <tglozar@redhat.com>, John Kacur <jkacur@redhat.com>,
	Wen Yang <wen.yang@linux.dev>
Subject: [PATCH v2 10/14] rv: Add KUnit stub to rv_react() and rv_*_task_monitor_slot()
Date: Thu, 14 May 2026 17:20:51 +0200	[thread overview]
Message-ID: <20260514152055.229162-11-gmonaco@redhat.com> (raw)
In-Reply-To: <20260514152055.229162-1-gmonaco@redhat.com>

Add KUNIT_STATIC_STUB_REDIRECT to allow those functions to be stubbed in
a KUnit test. This is useful to catch reaction without creating a custom
reactor and going through the effort of setting it from a test.
rv_{get/put}_task_monitor_slot() rely on a lock, but this isn't
necessary during a unit test, so simply skip the calls.

Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
---
 kernel/trace/rv/rv.c          | 5 +++++
 kernel/trace/rv/rv_reactors.c | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/kernel/trace/rv/rv.c b/kernel/trace/rv/rv.c
index ee4e68102f17..f59385a24fa1 100644
--- a/kernel/trace/rv/rv.c
+++ b/kernel/trace/rv/rv.c
@@ -142,6 +142,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <kunit/static_stub.h>
 
 #ifdef CONFIG_RV_MON_EVENTS
 #define CREATE_TRACE_POINTS
@@ -171,6 +172,8 @@ int rv_get_task_monitor_slot(void)
 {
 	int i;
 
+	KUNIT_STATIC_STUB_REDIRECT(rv_get_task_monitor_slot);
+
 	lockdep_assert_held(&rv_interface_lock);
 
 	if (task_monitor_count == CONFIG_RV_PER_TASK_MONITORS)
@@ -192,6 +195,8 @@ int rv_get_task_monitor_slot(void)
 
 void rv_put_task_monitor_slot(int slot)
 {
+	KUNIT_STATIC_STUB_REDIRECT(rv_put_task_monitor_slot, slot);
+
 	lockdep_assert_held(&rv_interface_lock);
 
 	if (slot < 0 || slot >= CONFIG_RV_PER_TASK_MONITORS) {
diff --git a/kernel/trace/rv/rv_reactors.c b/kernel/trace/rv/rv_reactors.c
index 460af07f7aba..3435dcedc7ee 100644
--- a/kernel/trace/rv/rv_reactors.c
+++ b/kernel/trace/rv/rv_reactors.c
@@ -63,6 +63,7 @@
 
 #include <linux/lockdep.h>
 #include <linux/slab.h>
+#include <kunit/static_stub.h>
 
 #include "rv.h"
 
@@ -468,6 +469,12 @@ void rv_react(struct rv_monitor *monitor, const char *msg, ...)
 	static DEFINE_WAIT_OVERRIDE_MAP(rv_react_map, LD_WAIT_FREE);
 	va_list args;
 
+	__diag_push();
+	__diag_ignore(GCC, all, "-Wsuggest-attribute=format",
+		      "Not a valid __printf() conversion candidate.");
+	KUNIT_STATIC_STUB_REDIRECT(rv_react, monitor, msg);
+	__diag_pop();
+
 	if (!rv_reacting_on() || !monitor->react)
 		return;
 
-- 
2.54.0


  parent reply	other threads:[~2026-05-14 15:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14 15:20 [PATCH v2 00/14] rv: Add selftests to tools and KUnit tests Gabriele Monaco
2026-05-14 15:20 ` [PATCH v2 01/14] tools/rv: Fix substring match bug in monitor name search Gabriele Monaco
2026-05-14 15:20 ` [PATCH v2 02/14] tools/rv: Fix substring match when listing container monitors Gabriele Monaco
2026-05-14 15:20 ` [PATCH v2 03/14] tools/rv: Fix exit status when monitor execution fails Gabriele Monaco
2026-05-14 15:20 ` [PATCH v2 04/14] tools/rv: Fix cleanup after failed trace setup Gabriele Monaco
2026-05-14 15:20 ` [PATCH v2 05/14] tools/rv: Add selftests Gabriele Monaco
2026-05-14 15:20 ` [PATCH v2 06/14] verification/rvgen: Fix options shared among commands Gabriele Monaco
2026-05-14 15:20 ` [PATCH v2 07/14] verification/rvgen: Fix ltl2k writing True as a literal Gabriele Monaco
2026-05-14 15:20 ` [PATCH v2 08/14] verification/rvgen: Add golden and spec folders for tests Gabriele Monaco
2026-05-14 15:20 ` [PATCH v2 09/14] verification/rvgen: Add selftests Gabriele Monaco
2026-05-14 15:20 ` Gabriele Monaco [this message]
2026-05-14 15:20 ` [PATCH v2 11/14] rv: Add KUnit tests for some DA/HA monitors Gabriele Monaco
2026-05-14 15:20 ` [PATCH v2 12/14] rv: Add KUnit stubs for current and smp_processor_id() Gabriele Monaco
2026-05-14 15:20 ` [PATCH v2 13/14] rv: Prevent unintentional tracepoints during KUnit tests Gabriele Monaco
2026-05-14 15:20 ` [PATCH v2 14/14] rv: Add KUnit tests for some LTL monitors Gabriele Monaco

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260514152055.229162-11-gmonaco@redhat.com \
    --to=gmonaco@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=namcao@linutronix.de \
    --cc=rostedt@goodmis.org \
    --cc=tglozar@redhat.com \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=wen.yang@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox