mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] lockdep: call time_hardirqs_off after clearing hardirqs_enabled
@ 2017-03-14  2:00 Qi Hou
  2017-03-14  3:03 ` Paul Gortmaker
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Qi Hou @ 2017-03-14  2:00 UTC (permalink / raw)
  To: mingo, rostedt, tglx; +Cc: linux-kernel, C.Emde, paul.gortmaker, bruce.ashfield

The current order of calls within trace_hardirqs_off_caller() would provoke
an "unannotated irqs-off" WARNING.

This warning was reported by check_flags() when it found that the hardirqs has
been disabled but the irq-flags state, "hardirqs_enabled", has not been cleared.

Check_flags() is called via trace_hardirqs_off(), and trace_hardirqs_off() will
be called by functions kind of local_irq_disable() if CONFIG_TRACE_IRQFLAGS has
been enabled.

The calltrace from functions kind of local_irq_diasble() to check_flags()
simplied as below:

local_irq_disable()
 |- trace_hardirqs_off()
     |- trace_hardirqs_off_caller()
         |- time_hardirqs_off()
             |- trace_preemptirqsoff_hist_rcuidle()
                |- __DO_TRACE()
                   |- rcu_dereference_sched()
                      |- rcu_read_lock_sched_held()
                          |- lock_is_held()
                              |- check_flags()

The order of calls within trace_hardirqs_off_caller() simplified as below:

local_irq_disable()
 |- raw_local_irq_disable()
 |- trace_hardirqs_off()
     |- trace_hardirqs_off_caller()
         |- time_hardirqs_off()     -->    check_flags()
         |- hardirqs_enabled = 0

We could find that the call to check_flags() has been made between disabling
hardirqs and clearing hardirqs_enabled. That will definitely cause an
"unannotated irqs-off" warning.

To fix this "unannotated irqs-off" warning, we must call time_hardirqs_off()
after that we clear hardirqs_enabled.

Signed-off-by: Qi Hou <qi.hou@windriver.com>
---
 kernel/locking/lockdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 577f026..e8b35e4 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -2627,8 +2627,6 @@ __visible void trace_hardirqs_off_caller(unsigned long ip)
 {
 	struct task_struct *curr = current;
 
-	time_hardirqs_off(CALLER_ADDR0, ip);
-
 	if (unlikely(!debug_locks || current->lockdep_recursion))
 		return;
 
@@ -2649,6 +2647,8 @@ __visible void trace_hardirqs_off_caller(unsigned long ip)
 		debug_atomic_inc(hardirqs_off_events);
 	} else
 		debug_atomic_inc(redundant_hardirqs_off);
+
+	time_hardirqs_off(CALLER_ADDR0, ip);
 }
 EXPORT_SYMBOL(trace_hardirqs_off_caller);
 
-- 
1.9.1

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

* Re: [PATCH] lockdep: call time_hardirqs_off after clearing hardirqs_enabled
  2017-03-14  2:00 [PATCH] lockdep: call time_hardirqs_off after clearing hardirqs_enabled Qi Hou
@ 2017-03-14  3:03 ` Paul Gortmaker
  2017-03-14  3:04 ` Steven Rostedt
  2017-03-14  8:44 ` Thomas Gleixner
  2 siblings, 0 replies; 5+ messages in thread
From: Paul Gortmaker @ 2017-03-14  3:03 UTC (permalink / raw)
  To: Qi Hou; +Cc: Ingo Molnar, rostedt, tglx, LKML, C.Emde, bruce.ashfield

Please stop sending "guesswork" patches.  This message to you is not
new.   I am running out of avenues where I can ask you to cease and
desist;  spamming maintainers like this is not acceptable.  You are
one step away from being in a kill-file.

On Mon, Mar 13, 2017 at 10:00 PM, Qi Hou <qi.hou@windriver.com> wrote:
> The current order of calls within trace_hardirqs_off_caller() would provoke
> an "unannotated irqs-off" WARNING.
>
> This warning was reported by check_flags() when it found that the hardirqs has
> been disabled but the irq-flags state, "hardirqs_enabled", has not been cleared.
>
> Check_flags() is called via trace_hardirqs_off(), and trace_hardirqs_off() will
> be called by functions kind of local_irq_disable() if CONFIG_TRACE_IRQFLAGS has
> been enabled.
>
> The calltrace from functions kind of local_irq_diasble() to check_flags()
> simplied as below:
>
> local_irq_disable()
>  |- trace_hardirqs_off()
>      |- trace_hardirqs_off_caller()
>          |- time_hardirqs_off()
>              |- trace_preemptirqsoff_hist_rcuidle()
>                 |- __DO_TRACE()
>                    |- rcu_dereference_sched()
>                       |- rcu_read_lock_sched_held()
>                           |- lock_is_held()
>                               |- check_flags()
>
> The order of calls within trace_hardirqs_off_caller() simplified as below:
>
> local_irq_disable()
>  |- raw_local_irq_disable()
>  |- trace_hardirqs_off()
>      |- trace_hardirqs_off_caller()
>          |- time_hardirqs_off()     -->    check_flags()
>          |- hardirqs_enabled = 0
>
> We could find that the call to check_flags() has been made between disabling
> hardirqs and clearing hardirqs_enabled. That will definitely cause an
> "unannotated irqs-off" warning.
>
> To fix this "unannotated irqs-off" warning, we must call time_hardirqs_off()
> after that we clear hardirqs_enabled.
>
> Signed-off-by: Qi Hou <qi.hou@windriver.com>
> ---
>  kernel/locking/lockdep.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 577f026..e8b35e4 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -2627,8 +2627,6 @@ __visible void trace_hardirqs_off_caller(unsigned long ip)
>  {
>         struct task_struct *curr = current;
>
> -       time_hardirqs_off(CALLER_ADDR0, ip);
> -
>         if (unlikely(!debug_locks || current->lockdep_recursion))
>                 return;
>
> @@ -2649,6 +2647,8 @@ __visible void trace_hardirqs_off_caller(unsigned long ip)
>                 debug_atomic_inc(hardirqs_off_events);
>         } else
>                 debug_atomic_inc(redundant_hardirqs_off);
> +
> +       time_hardirqs_off(CALLER_ADDR0, ip);
>  }
>  EXPORT_SYMBOL(trace_hardirqs_off_caller);
>
> --
> 1.9.1
>

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

* Re: [PATCH] lockdep: call time_hardirqs_off after clearing hardirqs_enabled
  2017-03-14  2:00 [PATCH] lockdep: call time_hardirqs_off after clearing hardirqs_enabled Qi Hou
  2017-03-14  3:03 ` Paul Gortmaker
@ 2017-03-14  3:04 ` Steven Rostedt
  2017-03-14  8:44 ` Thomas Gleixner
  2 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2017-03-14  3:04 UTC (permalink / raw)
  To: Qi Hou; +Cc: mingo, tglx, linux-kernel, C.Emde, paul.gortmaker, bruce.ashfield

On Tue, 14 Mar 2017 10:00:07 +0800
Qi Hou <qi.hou@windriver.com> wrote:

> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 577f026..e8b35e4 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -2627,8 +2627,6 @@ __visible void trace_hardirqs_off_caller(unsigned long ip)
>  {
>  	struct task_struct *curr = current;
>  
> -	time_hardirqs_off(CALLER_ADDR0, ip);
> -
>  	if (unlikely(!debug_locks || current->lockdep_recursion))
>  		return;

You do realize that this breaks irqsoff tracing if lockdep ever
triggers. Right?

-- Steve

>  
> @@ -2649,6 +2647,8 @@ __visible void trace_hardirqs_off_caller(unsigned long ip)
>  		debug_atomic_inc(hardirqs_off_events);
>  	} else
>  		debug_atomic_inc(redundant_hardirqs_off);
> +
> +	time_hardirqs_off(CALLER_ADDR0, ip);
>  }
>  EXPORT_SYMBOL(trace_hardirqs_off_caller);
>  

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

* Re: [PATCH] lockdep: call time_hardirqs_off after clearing hardirqs_enabled
  2017-03-14  2:00 [PATCH] lockdep: call time_hardirqs_off after clearing hardirqs_enabled Qi Hou
  2017-03-14  3:03 ` Paul Gortmaker
  2017-03-14  3:04 ` Steven Rostedt
@ 2017-03-14  8:44 ` Thomas Gleixner
  2017-03-14  9:16   ` qhou
  2 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2017-03-14  8:44 UTC (permalink / raw)
  To: Qi Hou
  Cc: mingo, rostedt, linux-kernel, C.Emde, paul.gortmaker, bruce.ashfield

On Tue, 14 Mar 2017, Qi Hou wrote:

> The current order of calls within trace_hardirqs_off_caller() would provoke
> an "unannotated irqs-off" WARNING.

Can you finally provide information how you trigger this warning?

    - Kernel version
    - .config file
    - test case or instructions how to provoke it?

instead of sending guess work patches and wasting everybodys time.

Thanks,

	tglx

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

* Re: [PATCH] lockdep: call time_hardirqs_off after clearing hardirqs_enabled
  2017-03-14  8:44 ` Thomas Gleixner
@ 2017-03-14  9:16   ` qhou
  0 siblings, 0 replies; 5+ messages in thread
From: qhou @ 2017-03-14  9:16 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: mingo, rostedt, linux-kernel, C.Emde, paul.gortmaker, bruce.ashfield

Hi, all

Sorry for everybody concerned. Please ignore this patch.

I sent this patch without my supervisor's ACKed. I missed a lot of 
important information.

I'm a newbie for submitting patches to community and I should have sent 
a valid patch under

my supervisor's guidance.

Execuse me, everyone.

Qi Hou



On 2017年03月14日 16:44, Thomas Gleixner wrote:
> On Tue, 14 Mar 2017, Qi Hou wrote:
>
>> The current order of calls within trace_hardirqs_off_caller() would provoke
>> an "unannotated irqs-off" WARNING.
> Can you finally provide information how you trigger this warning?
>
>      - Kernel version
>      - .config file
>      - test case or instructions how to provoke it?
>
> instead of sending guess work patches and wasting everybodys time.
>
> Thanks,
>
> 	tglx

-- 
Best regards,
Qi Hou
Phone number: +86-10-8477-8608
Address: Floor 15, Building B, Wangjing Plaza, No.9 Zhong-Huan Nanlu, Chaoyang District

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

end of thread, other threads:[~2017-03-14  9:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-14  2:00 [PATCH] lockdep: call time_hardirqs_off after clearing hardirqs_enabled Qi Hou
2017-03-14  3:03 ` Paul Gortmaker
2017-03-14  3:04 ` Steven Rostedt
2017-03-14  8:44 ` Thomas Gleixner
2017-03-14  9:16   ` qhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®