Re: [PATCH] tracing/fgraph: remove unnecessary unlikely()
Sorry for this place, I should consider this situation. -- Yangtao On Sun, Nov 4, 2018 at 10:06 PM Steven Rostedt wrote: > > On Sat, 3 Nov 2018 22:35:37 -0400 > Yangtao Li wrote: > > > WARN_ON() already contains an unlikely(), so it's not necessary to use > > unlikely. > > NACK... see below. > > > > > Signed-off-by: Yangtao Li > > --- > > kernel/trace/trace_functions_graph.c | 6 ++ > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/kernel/trace/trace_functions_graph.c > > b/kernel/trace/trace_functions_graph.c > > index 169b3c44ee97..f8c2a08e4985 100644 > > --- a/kernel/trace/trace_functions_graph.c > > +++ b/kernel/trace/trace_functions_graph.c > > @@ -201,9 +201,8 @@ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, > > unsigned long *ret, > > if (index < 0) > > index += FTRACE_NOTRACE_DEPTH; > > > > - if (unlikely(index < 0 || index >= FTRACE_RETFUNC_DEPTH)) { > > + if (WARN_ON(index < 0 || index >= FTRACE_RETFUNC_DEPTH)) { > > When function graph is enabled, the printk from the warn on will likely > be traced as well and trigger the same WARN_ON, which will again cause > a recursion loop and crash and reboot the box with no output at all. > > > ftrace_graph_stop(); > > Notice that I call ftrace_graph_stop() *before* the WARN_ON(). This > disables the ftrace graph tracer and prevents the recursion loop from > happening. > > There's a reason that the WARN_ON() is placed where it is. > > But thanks for the report, it shows that I need to add a comment here > so that someone else doesn't send a similar patch in the future. > > -- Steve > > > > - WARN_ON(1); > > /* Might as well panic, otherwise we have no where to go */ > > *ret = (unsigned long)panic; > > return; > > @@ -274,9 +273,8 @@ unsigned long ftrace_return_to_handler(unsigned long > > frame_pointer) > >*/ > > ftrace_graph_return(); > > > > - if (unlikely(!ret)) { > > + if (WARN_ON(!ret)) { > > ftrace_graph_stop(); > > - WARN_ON(1); > > /* Might as well panic. What else to do? */ > > ret = (unsigned long)panic; > > } >
Re: [PATCH] tracing/fgraph: remove unnecessary unlikely()
Sorry for this place, I should consider this situation. -- Yangtao On Sun, Nov 4, 2018 at 10:06 PM Steven Rostedt wrote: > > On Sat, 3 Nov 2018 22:35:37 -0400 > Yangtao Li wrote: > > > WARN_ON() already contains an unlikely(), so it's not necessary to use > > unlikely. > > NACK... see below. > > > > > Signed-off-by: Yangtao Li > > --- > > kernel/trace/trace_functions_graph.c | 6 ++ > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/kernel/trace/trace_functions_graph.c > > b/kernel/trace/trace_functions_graph.c > > index 169b3c44ee97..f8c2a08e4985 100644 > > --- a/kernel/trace/trace_functions_graph.c > > +++ b/kernel/trace/trace_functions_graph.c > > @@ -201,9 +201,8 @@ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, > > unsigned long *ret, > > if (index < 0) > > index += FTRACE_NOTRACE_DEPTH; > > > > - if (unlikely(index < 0 || index >= FTRACE_RETFUNC_DEPTH)) { > > + if (WARN_ON(index < 0 || index >= FTRACE_RETFUNC_DEPTH)) { > > When function graph is enabled, the printk from the warn on will likely > be traced as well and trigger the same WARN_ON, which will again cause > a recursion loop and crash and reboot the box with no output at all. > > > ftrace_graph_stop(); > > Notice that I call ftrace_graph_stop() *before* the WARN_ON(). This > disables the ftrace graph tracer and prevents the recursion loop from > happening. > > There's a reason that the WARN_ON() is placed where it is. > > But thanks for the report, it shows that I need to add a comment here > so that someone else doesn't send a similar patch in the future. > > -- Steve > > > > - WARN_ON(1); > > /* Might as well panic, otherwise we have no where to go */ > > *ret = (unsigned long)panic; > > return; > > @@ -274,9 +273,8 @@ unsigned long ftrace_return_to_handler(unsigned long > > frame_pointer) > >*/ > > ftrace_graph_return(); > > > > - if (unlikely(!ret)) { > > + if (WARN_ON(!ret)) { > > ftrace_graph_stop(); > > - WARN_ON(1); > > /* Might as well panic. What else to do? */ > > ret = (unsigned long)panic; > > } >
Re: [PATCH] tracing/fgraph: remove unnecessary unlikely()
On Sat, 3 Nov 2018 22:35:37 -0400 Yangtao Li wrote: > WARN_ON() already contains an unlikely(), so it's not necessary to use > unlikely. NACK... see below. > > Signed-off-by: Yangtao Li > --- > kernel/trace/trace_functions_graph.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/kernel/trace/trace_functions_graph.c > b/kernel/trace/trace_functions_graph.c > index 169b3c44ee97..f8c2a08e4985 100644 > --- a/kernel/trace/trace_functions_graph.c > +++ b/kernel/trace/trace_functions_graph.c > @@ -201,9 +201,8 @@ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, > unsigned long *ret, > if (index < 0) > index += FTRACE_NOTRACE_DEPTH; > > - if (unlikely(index < 0 || index >= FTRACE_RETFUNC_DEPTH)) { > + if (WARN_ON(index < 0 || index >= FTRACE_RETFUNC_DEPTH)) { When function graph is enabled, the printk from the warn on will likely be traced as well and trigger the same WARN_ON, which will again cause a recursion loop and crash and reboot the box with no output at all. > ftrace_graph_stop(); Notice that I call ftrace_graph_stop() *before* the WARN_ON(). This disables the ftrace graph tracer and prevents the recursion loop from happening. There's a reason that the WARN_ON() is placed where it is. But thanks for the report, it shows that I need to add a comment here so that someone else doesn't send a similar patch in the future. -- Steve > - WARN_ON(1); > /* Might as well panic, otherwise we have no where to go */ > *ret = (unsigned long)panic; > return; > @@ -274,9 +273,8 @@ unsigned long ftrace_return_to_handler(unsigned long > frame_pointer) >*/ > ftrace_graph_return(); > > - if (unlikely(!ret)) { > + if (WARN_ON(!ret)) { > ftrace_graph_stop(); > - WARN_ON(1); > /* Might as well panic. What else to do? */ > ret = (unsigned long)panic; > }
Re: [PATCH] tracing/fgraph: remove unnecessary unlikely()
On Sat, 3 Nov 2018 22:35:37 -0400 Yangtao Li wrote: > WARN_ON() already contains an unlikely(), so it's not necessary to use > unlikely. NACK... see below. > > Signed-off-by: Yangtao Li > --- > kernel/trace/trace_functions_graph.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/kernel/trace/trace_functions_graph.c > b/kernel/trace/trace_functions_graph.c > index 169b3c44ee97..f8c2a08e4985 100644 > --- a/kernel/trace/trace_functions_graph.c > +++ b/kernel/trace/trace_functions_graph.c > @@ -201,9 +201,8 @@ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, > unsigned long *ret, > if (index < 0) > index += FTRACE_NOTRACE_DEPTH; > > - if (unlikely(index < 0 || index >= FTRACE_RETFUNC_DEPTH)) { > + if (WARN_ON(index < 0 || index >= FTRACE_RETFUNC_DEPTH)) { When function graph is enabled, the printk from the warn on will likely be traced as well and trigger the same WARN_ON, which will again cause a recursion loop and crash and reboot the box with no output at all. > ftrace_graph_stop(); Notice that I call ftrace_graph_stop() *before* the WARN_ON(). This disables the ftrace graph tracer and prevents the recursion loop from happening. There's a reason that the WARN_ON() is placed where it is. But thanks for the report, it shows that I need to add a comment here so that someone else doesn't send a similar patch in the future. -- Steve > - WARN_ON(1); > /* Might as well panic, otherwise we have no where to go */ > *ret = (unsigned long)panic; > return; > @@ -274,9 +273,8 @@ unsigned long ftrace_return_to_handler(unsigned long > frame_pointer) >*/ > ftrace_graph_return(); > > - if (unlikely(!ret)) { > + if (WARN_ON(!ret)) { > ftrace_graph_stop(); > - WARN_ON(1); > /* Might as well panic. What else to do? */ > ret = (unsigned long)panic; > }
[PATCH] tracing/fgraph: remove unnecessary unlikely()
WARN_ON() already contains an unlikely(), so it's not necessary to use unlikely. Signed-off-by: Yangtao Li --- kernel/trace/trace_functions_graph.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c index 169b3c44ee97..f8c2a08e4985 100644 --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c @@ -201,9 +201,8 @@ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret, if (index < 0) index += FTRACE_NOTRACE_DEPTH; - if (unlikely(index < 0 || index >= FTRACE_RETFUNC_DEPTH)) { + if (WARN_ON(index < 0 || index >= FTRACE_RETFUNC_DEPTH)) { ftrace_graph_stop(); - WARN_ON(1); /* Might as well panic, otherwise we have no where to go */ *ret = (unsigned long)panic; return; @@ -274,9 +273,8 @@ unsigned long ftrace_return_to_handler(unsigned long frame_pointer) */ ftrace_graph_return(); - if (unlikely(!ret)) { + if (WARN_ON(!ret)) { ftrace_graph_stop(); - WARN_ON(1); /* Might as well panic. What else to do? */ ret = (unsigned long)panic; } -- 2.17.0
[PATCH] tracing/fgraph: remove unnecessary unlikely()
WARN_ON() already contains an unlikely(), so it's not necessary to use unlikely. Signed-off-by: Yangtao Li --- kernel/trace/trace_functions_graph.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c index 169b3c44ee97..f8c2a08e4985 100644 --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c @@ -201,9 +201,8 @@ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret, if (index < 0) index += FTRACE_NOTRACE_DEPTH; - if (unlikely(index < 0 || index >= FTRACE_RETFUNC_DEPTH)) { + if (WARN_ON(index < 0 || index >= FTRACE_RETFUNC_DEPTH)) { ftrace_graph_stop(); - WARN_ON(1); /* Might as well panic, otherwise we have no where to go */ *ret = (unsigned long)panic; return; @@ -274,9 +273,8 @@ unsigned long ftrace_return_to_handler(unsigned long frame_pointer) */ ftrace_graph_return(); - if (unlikely(!ret)) { + if (WARN_ON(!ret)) { ftrace_graph_stop(); - WARN_ON(1); /* Might as well panic. What else to do? */ ret = (unsigned long)panic; } -- 2.17.0