Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754182AbdCNDE1 (ORCPT ); Mon, 13 Mar 2017 23:04:27 -0400 Received: from mail-ua0-f196.google.com ([209.85.217.196]:34868 "EHLO mail-ua0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753667AbdCNDE0 (ORCPT ); Mon, 13 Mar 2017 23:04:26 -0400 MIME-Version: 1.0 In-Reply-To: <1489456807-160132-1-git-send-email-qi.hou@windriver.com> References: <1489456807-160132-1-git-send-email-qi.hou@windriver.com> From: Paul Gortmaker Date: Mon, 13 Mar 2017 23:03:54 -0400 Message-ID: Subject: Re: [PATCH] lockdep: call time_hardirqs_off after clearing hardirqs_enabled To: Qi Hou Cc: Ingo Molnar , rostedt@goodmis.org, "tglx@linutronix.de" , LKML , C.Emde@osadl.org, "bruce.ashfield" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2816 Lines: 76 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 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 > --- > 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 >