From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964953AbcBCQq1 (ORCPT ); Wed, 3 Feb 2016 11:46:27 -0500 Received: from mail-ob0-f177.google.com ([209.85.214.177]:35063 "EHLO mail-ob0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964856AbcBCQqY (ORCPT ); Wed, 3 Feb 2016 11:46:24 -0500 From: Boqun Feng To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , sasha.levin@oracle.com, Boqun Feng Subject: [RFC 1/6] lockdep: Add helper functions of irq_context Date: Thu, 4 Feb 2016 00:45:07 +0800 Message-Id: <1454517912-10457-2-git-send-email-boqun.feng@gmail.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454517912-10457-1-git-send-email-boqun.feng@gmail.com> References: <1454517912-10457-1-git-send-email-boqun.feng@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add two helper functions of irq_context: task_irq_context(): return the encoded irq_context of the task, the return value is encoded in the same as ->irq_context of held_lock. Always return 0 if !(CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING) is_same_irq_context(): compare whether two irq_context are the same. Always return true if !(CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING) These two functions are added for the future use of irq_context by LOCKED_ACCESS, because LOCKED_ACCESS needs to get the irq_context value of a task when a data access happens rather than when a lock is acquired, so it needs another way than getting the value from held_lock::irq_context Signed-off-by: Boqun Feng --- kernel/locking/lockdep.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 60ace56..c8a632b 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2839,6 +2839,16 @@ static int mark_irqflags(struct task_struct *curr, struct held_lock *hlock) return 1; } +static unsigned int task_irq_context(struct task_struct *task) +{ + return 2 * (task->hardirq_context ? 1 : 0) + task->softirq_context; +} + +static bool is_same_irq_context(unsigned int ctx1, unsigned int ctx2) +{ + return ctx1 == ctx2; +} + static int separate_irq_context(struct task_struct *curr, struct held_lock *hlock) { @@ -2847,8 +2857,7 @@ static int separate_irq_context(struct task_struct *curr, /* * Keep track of points where we cross into an interrupt context: */ - hlock->irq_context = 2*(curr->hardirq_context ? 1 : 0) + - curr->softirq_context; + hlock->irq_context = task_irq_context(curr); if (depth) { struct held_lock *prev_hlock; @@ -2880,6 +2889,16 @@ static inline int mark_irqflags(struct task_struct *curr, return 1; } +static unsigned int task_irq_context(struct task_struct *task) +{ + return 0; +} + +static bool is_same_irq_context(unsigned int ctx1, unsigned int ctx2) +{ + return true; +} + static inline int separate_irq_context(struct task_struct *curr, struct held_lock *hlock) { -- 2.7.0