Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753784AbcLKRwH (ORCPT ); Sun, 11 Dec 2016 12:52:07 -0500 Received: from mail-wj0-f195.google.com ([209.85.210.195]:33586 "EHLO mail-wj0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753457AbcLKRwF (ORCPT ); Sun, 11 Dec 2016 12:52:05 -0500 From: Chris Wilson To: linux-kernel@vger.kernel.org Cc: intel-gfx@lists.freedesktop.org, Chris Wilson , Peter Zijlstra , Ingo Molnar Subject: [PATCH 1/2] lockdep: Markup callers of might_lock() as potential sleepers Date: Sun, 11 Dec 2016 17:52:00 +0000 Message-Id: <20161211175201.12411-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1559 Lines: 43 If might_lock() is called on a mutex, it may also potentially sleep. Call might_sleep() in this case so that the caller is checked for both. This is similar to the might_sleep() that is checked by the real mutex_lock(). Signed-off-by: Chris Wilson Cc: Peter Zijlstra Cc: Ingo Molnar --- include/linux/lockdep.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index c1458fede1f9..0341e4246d00 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -549,9 +549,13 @@ static inline void print_irqtrace_events(struct task_struct *curr) #define lock_map_acquire_tryread(l) lock_acquire_shared_recursive(l, 0, 1, NULL, _THIS_IP_) #define lock_map_release(l) lock_release(l, 1, _THIS_IP_) +#define lock_is_mutex(lock) \ + __builtin_types_compatible_p(typeof(*lock), struct mutex) + #ifdef CONFIG_PROVE_LOCKING # define might_lock(lock) \ do { \ + might_sleep_if(lock_is_mutex(lock)); \ typecheck(struct lockdep_map *, &(lock)->dep_map); \ lock_acquire(&(lock)->dep_map, 0, 0, 0, 1, NULL, _THIS_IP_); \ lock_release(&(lock)->dep_map, 0, _THIS_IP_); \ @@ -563,7 +567,9 @@ do { \ lock_release(&(lock)->dep_map, 0, _THIS_IP_); \ } while (0) #else -# define might_lock(lock) do { } while (0) +# define might_lock(lock) do { \ + might_sleep_if(lock_is_mutex(lock)); \ +} while (0) # define might_lock_read(lock) do { } while (0) #endif -- 2.11.0