Thread (3 messages) 3 messages, 1 author, 2026-09-10

[PATCH v2 2/2] tracing: Invert the logic in mmio_read() to get rid of the goto

flat view
DORMANTno replies REVIEWED: 1 (1M)

From: Steven Rostedt <rostedt@kernel.org>
Date: 2026-09-10 20:24:09
Also in: lkml
Subsystem: the rest, tracing, tracing mmio accesses (mmiotrace) · Maintainers: Linus Torvalds, Steven Rostedt, Masami Hiramatsu

1 review trailer (1 from subsystem maintainers).

From: Steven Rostedt <rostedt@goodmis.org>

Simplify the logic by removing the goto in the first condition and
inverting the logic of the early return.

This changes the reading logic slightly. Before, the goto would exit the
function right away with the output of missed events. The next read would
then update print the saved hiter->dev and update it.

Now, in one iteration, if count_overruns() retruns !0, the lost events is
printed as well as the next hiter->dev without needing a second loop.

Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
Changes since v1: https://patch.msgid.link/20260721212010.76e9ed61@gandalf.local.home (local)

- Broke it up into two patches

 kernel/trace/trace_mmiotrace.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
index 0034d6af3d9d..c49738cdb439 100644
--- a/kernel/trace/trace_mmiotrace.c
+++ b/kernel/trace/trace_mmiotrace.c
@@ -143,16 +143,13 @@ static ssize_t mmio_read(struct trace_iterator *iter, struct file *filp,
 		if (!overrun_detected)
 			pr_warn("mmiotrace has lost events\n");
 		overrun_detected = true;
-		goto print_out;
 	}
 
-	if (!hiter || !hiter->dev)
-		return 0;
-
-	mmio_print_pcidev(s, hiter->dev);
-	hiter->dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, hiter->dev);
+	if (hiter && hiter->dev) {
+		mmio_print_pcidev(s, hiter->dev);
+		hiter->dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, hiter->dev);
+	}
 
-print_out:
 	ret = trace_seq_to_user(s, ubuf, cnt);
 	return (ret == -EBUSY) ? 0 : ret;
 }
-- 
2.53.0

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help