From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, peterz@infradead.org
Subject: Re: [PATCH v2 4/5] tracing: Unify the logic for function tracing options
Date: Wed, 7 Apr 2021 16:34:11 +0300 [thread overview]
Message-ID: <3eb21018-d10d-6f05-cd91-e514d260f924@gmail.com> (raw)
In-Reply-To: <20210405181525.0d4a724e@gandalf.local.home>
Hi Steven,
Hi Steven,
On 6.04.21 г. 1:15, Steven Rostedt wrote:
>>
>> @@ -235,30 +248,31 @@ static struct tracer function_trace;
>> static int
>> func_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
>> {
>> - switch (bit) {
>> - case TRACE_FUNC_OPT_STACK:
>> - /* do nothing if already set */
>> - if (!!set == !!(func_flags.val & TRACE_FUNC_OPT_STACK))
>> - break;
>> + ftrace_func_t func;
>> + u32 new_flags_val;
> Nit, but the variable should just be "new_flags", which is consistent with
> old_flags. In the kernel we don't need to the variable names to be so
> verbose.
>
>>
>> - /* We can change this flag when not running. */
>> - if (tr->current_trace != &function_trace)
>> - break;
>> + /* Do nothing if already set. */
>> + if (!!set == !!(func_flags.val & bit))
>> + return 0;
>>
>> - unregister_ftrace_function(tr->ops);
>> + /* We can change this flag only when not running. */
>> + if (tr->current_trace != &function_trace)
>> + return 0;
>>
>> - if (set) {
>> - tr->ops->func = function_stack_trace_call;
>> - register_ftrace_function(tr->ops);
>> - } else {
>> - tr->ops->func = function_trace_call;
>> - register_ftrace_function(tr->ops);
>> - }
>> + new_flags_val = (func_flags.val & ~(1UL << (bit - 1)));
>> + new_flags_val |= (set << (bit - 1));
> bit is already the mask, no need to shift it, nor there's no reason for the
> extra set of parenthesis. And the above can be done in one line.
>
> new_flags = (func_flags.val & ~bit) | (set ? bit : 0);
>
OK, I totally misinterpreted the meaning of the "bit" argument of the
function. I did not realized it is a mask. I was thinking the argument
gives only the number of the bit that changes (like 5 for the 5-th bit
inside the mask).
Thanks!
Yordan
next prev parent reply other threads:[~2021-04-07 13:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-29 13:05 [PATCH v2 0/5] Add "func_no_repete" tracing option Yordan Karadzhov (VMware)
2021-03-29 13:05 ` [PATCH v2 1/5] tracing: Define new ftrace event "func_repeats" Yordan Karadzhov (VMware)
2021-04-05 21:28 ` Steven Rostedt
2021-03-29 13:05 ` [PATCH v2 2/5] tracing: Add "last_func_repeats" to struct trace_array Yordan Karadzhov (VMware)
2021-03-29 13:05 ` [PATCH v2 3/5] tracing: Add method for recording "func_repeats" events Yordan Karadzhov (VMware)
2021-03-29 13:05 ` [PATCH v2 4/5] tracing: Unify the logic for function tracing options Yordan Karadzhov (VMware)
2021-04-05 22:15 ` Steven Rostedt
2021-04-07 13:34 ` Yordan Karadzhov (VMware) [this message]
2021-03-29 13:05 ` [PATCH v2 5/5] tracing: Add "func_no_repeats" option for function tracing Yordan Karadzhov (VMware)
2021-04-05 22:25 ` Steven Rostedt
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=3eb21018-d10d-6f05-cd91-e514d260f924@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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