From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: probe-events: Cleanup entry-arg storing code
Date: Tue, 11 Mar 2025 10:29:28 +0900 [thread overview]
Message-ID: <20250311102928.ae96ceb8870e73e30f6f1279@kernel.org> (raw)
In-Reply-To: <20250306191404.69b0877e@gandalf.local.home>
On Thu, 6 Mar 2025 19:14:04 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Mon, 3 Mar 2025 18:02:29 +0900
> "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
>
> > + /* Search the offset for the sprcified argnum. */
> > + for (i = 0; i < earg->size - 1 && earg->code[i].op != FETCH_OP_END; i++) {
> > + if (earg->code[i].op != FETCH_OP_ARG || earg->code[i].param != argnum)
> > + continue;
>
> I wonder if you can save a loop by changing this to:
>
> if (earg->code[i].op != FETCH_OP_ARG) {
> last_offset = earg->code[i].offset;
> continue;
> }
>
> if (earg->code[i].param != argnum)
> continue;
>
>
> > +
> > + if (WARN_ON_ONCE(earg->code[i + 1].op != FETCH_OP_ST_EDATA))
> > + continue;
> > +
> > + return earg->code[i + 1].offset;
> > }
> > - return -ENOSPC;
> > + if (i >= earg->size - 1)
> > + return -ENOSPC;
> > +
> > + /* Not found, append new entry if possible. */
> > + offset = get_entry_arg_max_offset(earg) + sizeof(unsigned long);
>
> Then here you could use last_offset instead of running the loop again?
Yeah, but I would like it easier to read and safer (adding WARN_ON)
especially,
> if (earg->code[i].op != FETCH_OP_ARG) {
> last_offset = earg->code[i].offset;
> continue;
> }
this is a bit unsafe if we introduce another operation except for
the FETCH_OP_ARG and FETCH_OP_ST_EDATA. (and it is expecting the
offset is always increased.)
Thank you,
>
> -- Steve
>
>
> > + store_entry_arg_at(&earg->code[i], argnum, offset);
> > + return offset;
> > }
> >
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
prev parent reply other threads:[~2025-03-11 1:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 9:02 [PATCH] tracing: probe-events: Cleanup entry-arg storing code Masami Hiramatsu (Google)
2025-03-07 0:14 ` Steven Rostedt
2025-03-11 1:29 ` Masami Hiramatsu [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=20250311102928.ae96ceb8870e73e30f6f1279@kernel.org \
--to=mhiramat@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.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