[PATCH v2 2/2] tracing: Invert the logic in mmio_read() to get rid of the goto
From: Steven Rostedt
Date: Thu Sep 10 2026 - 16:26:18 EST
From: Steven Rostedt <rostedt@xxxxxxxxxxx>
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@xxxxxxxxxx>
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
Changes since v1: https://patch.msgid.link/20260721212010.76e9ed61@xxxxxxxxxxxxxxxxxx
- 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