[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <84a2f916-47c5-4c6f-9d36-771f60db35fc@huaweicloud.com>
Date: Fri, 22 Aug 2025 09:26:22 +0800
From: Tengda Wu <wutengda@...weicloud.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Masami Hiramatsu <mhiramat@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Ingo Molnar <mingo@...e.hu>, linux-trace-kernel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH -next v2] ftrace: Fix potential warning in
trace_printk_seq during ftrace_dump
On 2025/8/21 23:05, Steven Rostedt wrote:
> On Thu, 21 Aug 2025 02:11:20 +0000
> Tengda Wu <wutengda@...weicloud.com> wrote:
>
> tested this and was writing the change log for the pull request when I
> realized an issue.
>
>> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
>> index 4283ed4e8f59..b4cec22753ea 100644
>> --- a/kernel/trace/trace.c
>> +++ b/kernel/trace/trace.c
>> @@ -10617,6 +10617,7 @@ static void ftrace_dump_one(struct trace_array *tr, enum ftrace_dump_mode dump_m
>> */
>>
>> while (!trace_empty(&iter)) {
>> + void *ent;
>>
>> if (!cnt)
>> printk(KERN_TRACE "---------------------------------\n");
>> @@ -10625,17 +10626,18 @@ static void ftrace_dump_one(struct trace_array *tr, enum ftrace_dump_mode dump_m
>>
>> trace_iterator_reset(&iter);
>> iter.iter_flags |= TRACE_FILE_LAT_FMT;
>> + ent = trace_find_next_entry_inc(&iter);
>>
>> - if (trace_find_next_entry_inc(&iter) != NULL) {
>> + if (ent) {
>
> Why do we need "ent"?
>
>
>> int ret;
>>
>> ret = print_trace_line(&iter);
>> if (ret != TRACE_TYPE_NO_CONSUME)
>> trace_consume(&iter);
>> +
>> + trace_printk_seq(&iter.seq);
>
> Isn't just moving trace_printk_seq() enough?
>
> The code is no different with or without the "ent" as "ent" is not used in
> the if block.
>
> -- Steve
I apologize, as this is a trace left over from the initial patch modification
process. While working with the original code, I added an `if (ent)` branch
directly to trace_printk_seq and later realized it could be merged with the
previous `if (ent)` branch. However, I forgot to remove the now-redundant ent
after the merge.
I will correct this immediately and resend a new version.
-- Tengda
>
>
>> }
>> touch_nmi_watchdog();
>> -
>> - trace_printk_seq(&iter.seq);
>> }
>>
>> if (!cnt)
Powered by blists - more mailing lists