From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH v2 2/2] tracing: Invert the logic in mmio_read() to get rid of the goto
Date: Thu, 10 Sep 2026 16:24:23 -0400 [thread overview]
Message-ID: <20260910202528.700804592@kernel.org> (raw)
In-Reply-To: <20260910202421.612273038@kernel.org>
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
- 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
prev parent reply other threads:[~2026-09-10 20:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 20:24 [PATCH v2 0/2] tracing: Do not clean up hiter in mmiotrace read function Steven Rostedt
2026-09-10 20:24 ` [PATCH v2 1/2] " Steven Rostedt
2026-09-10 20:24 ` Steven Rostedt [this message]
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=20260910202528.700804592@kernel.org \
--to=rostedt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
/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
all inboxes | Powered by JetHome®