linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] time/sched_clock: mark sched_clock_read_begin/retry as notrace
@ 2020-09-29  1:50 quanyang.wang
  2020-09-29  7:49 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: quanyang.wang @ 2020-09-29  1:50 UTC (permalink / raw)
  To: linux-kernel, Peter Zijlstra
  Cc: Thomas Gleixner, Leo Yan, Will Deacon, a.darwish, Daniel Lezcano,
	Paul Cercueil, Randy Dunlap, ben.dooks

From: Quanyang Wang <quanyang.wang@windriver.com>

Since sched_clock_read_begin and sched_clock_read_retry are called
by notrace function sched_clock, they shouldn't be traceable either,
or else ftrace_graph_caller will run into a dead loop on the path
as below (arm for instance):

  ftrace_graph_caller
    prepare_ftrace_return
      function_graph_enter
        ftrace_push_return_trace
          trace_clock_local
            sched_clock
              sched_clock_read_begin/retry

Fixes: 1b86abc1c645 ("sched_clock: Expose struct clock_read_data")
Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
---
Changes:
V2: Add notrace to sched_clock_read_retry according to Peter's suggestion.

 kernel/time/sched_clock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
index 1c03eec6ca9b..f629e3f5afbe 100644
--- a/kernel/time/sched_clock.c
+++ b/kernel/time/sched_clock.c
@@ -68,13 +68,13 @@ static inline u64 notrace cyc_to_ns(u64 cyc, u32 mult, u32 shift)
 	return (cyc * mult) >> shift;
 }
 
-struct clock_read_data *sched_clock_read_begin(unsigned int *seq)
+notrace struct clock_read_data *sched_clock_read_begin(unsigned int *seq)
 {
 	*seq = raw_read_seqcount_latch(&cd.seq);
 	return cd.read_data + (*seq & 1);
 }
 
-int sched_clock_read_retry(unsigned int seq)
+int notrace sched_clock_read_retry(unsigned int seq)
 {
 	return read_seqcount_retry(&cd.seq, seq);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] time/sched_clock: mark sched_clock_read_begin/retry as notrace
  2020-09-29  1:50 [PATCH V2] time/sched_clock: mark sched_clock_read_begin/retry as notrace quanyang.wang
@ 2020-09-29  7:49 ` Peter Zijlstra
  2020-09-29  8:09   ` Quanyang Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2020-09-29  7:49 UTC (permalink / raw)
  To: quanyang.wang
  Cc: linux-kernel, Thomas Gleixner, Leo Yan, Will Deacon, a.darwish,
	Daniel Lezcano, Paul Cercueil, Randy Dunlap, ben.dooks

On Tue, Sep 29, 2020 at 09:50:51AM +0800, quanyang.wang@windriver.com wrote:
> From: Quanyang Wang <quanyang.wang@windriver.com>
> 
> Since sched_clock_read_begin and sched_clock_read_retry are called
> by notrace function sched_clock, they shouldn't be traceable either,
> or else ftrace_graph_caller will run into a dead loop on the path
> as below (arm for instance):
> 
>   ftrace_graph_caller
>     prepare_ftrace_return
>       function_graph_enter
>         ftrace_push_return_trace
>           trace_clock_local
>             sched_clock
>               sched_clock_read_begin/retry
> 
> Fixes: 1b86abc1c645 ("sched_clock: Expose struct clock_read_data")
> Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
> ---
> Changes:
> V2: Add notrace to sched_clock_read_retry according to Peter's suggestion.
> 
>  kernel/time/sched_clock.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
> index 1c03eec6ca9b..f629e3f5afbe 100644
> --- a/kernel/time/sched_clock.c
> +++ b/kernel/time/sched_clock.c
> @@ -68,13 +68,13 @@ static inline u64 notrace cyc_to_ns(u64 cyc, u32 mult, u32 shift)
>  	return (cyc * mult) >> shift;
>  }
>  
> -struct clock_read_data *sched_clock_read_begin(unsigned int *seq)
> +notrace struct clock_read_data *sched_clock_read_begin(unsigned int *seq)
>  {
>  	*seq = raw_read_seqcount_latch(&cd.seq);
>  	return cd.read_data + (*seq & 1);
>  }
>  
> -int sched_clock_read_retry(unsigned int seq)
> +int notrace sched_clock_read_retry(unsigned int seq)
>  {
>  	return read_seqcount_retry(&cd.seq, seq);
>  }

You're inconsistent in the placement of notrace, I prefer the first, the
second read like notrace is the return type instead of a qualifier.

In any case,

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] time/sched_clock: mark sched_clock_read_begin/retry as notrace
  2020-09-29  7:49 ` Peter Zijlstra
@ 2020-09-29  8:09   ` Quanyang Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Quanyang Wang @ 2020-09-29  8:09 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-kernel, Thomas Gleixner, Leo Yan, Will Deacon, a.darwish,
	Daniel Lezcano, Paul Cercueil, Randy Dunlap, ben.dooks

Hi Peter,

On 9/29/20 3:49 PM, Peter Zijlstra wrote:
> On Tue, Sep 29, 2020 at 09:50:51AM +0800, quanyang.wang@windriver.com wrote:
>> From: Quanyang Wang <quanyang.wang@windriver.com>
>>
>> Since sched_clock_read_begin and sched_clock_read_retry are called
>> by notrace function sched_clock, they shouldn't be traceable either,
>> or else ftrace_graph_caller will run into a dead loop on the path
>> as below (arm for instance):
>>
>>    ftrace_graph_caller
>>      prepare_ftrace_return
>>        function_graph_enter
>>          ftrace_push_return_trace
>>            trace_clock_local
>>              sched_clock
>>                sched_clock_read_begin/retry
>>
>> Fixes: 1b86abc1c645 ("sched_clock: Expose struct clock_read_data")
>> Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
>> ---
>> Changes:
>> V2: Add notrace to sched_clock_read_retry according to Peter's suggestion.
>>
>>   kernel/time/sched_clock.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
>> index 1c03eec6ca9b..f629e3f5afbe 100644
>> --- a/kernel/time/sched_clock.c
>> +++ b/kernel/time/sched_clock.c
>> @@ -68,13 +68,13 @@ static inline u64 notrace cyc_to_ns(u64 cyc, u32 mult, u32 shift)
>>   	return (cyc * mult) >> shift;
>>   }
>>   
>> -struct clock_read_data *sched_clock_read_begin(unsigned int *seq)
>> +notrace struct clock_read_data *sched_clock_read_begin(unsigned int *seq)
>>   {
>>   	*seq = raw_read_seqcount_latch(&cd.seq);
>>   	return cd.read_data + (*seq & 1);
>>   }
>>   
>> -int sched_clock_read_retry(unsigned int seq)
>> +int notrace sched_clock_read_retry(unsigned int seq)
>>   {
>>   	return read_seqcount_retry(&cd.seq, seq);
>>   }
> You're inconsistent in the placement of notrace, I prefer the first, the
> second read like notrace is the return type instead of a qualifier.

Thanks for your review. I will send a V3 patch to fix it.

Thanks,

Quanyang

>
> In any case,
>
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-29  8:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29  1:50 [PATCH V2] time/sched_clock: mark sched_clock_read_begin/retry as notrace quanyang.wang
2020-09-29  7:49 ` Peter Zijlstra
2020-09-29  8:09   ` Quanyang Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).