Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935426AbdCLUyA (ORCPT ); Sun, 12 Mar 2017 16:54:00 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35142 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934692AbdCLUxv (ORCPT ); Sun, 12 Mar 2017 16:53:51 -0400 From: Daniel Vetter To: Intel Graphics Development Cc: Daniel Vetter , Chris Wilson , Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Daniel Vetter Subject: [PATCH] drm/i915: annote drop_caches debugfs interface with lockdep Date: Sun, 12 Mar 2017 21:53:40 +0100 Message-Id: <20170312205340.16202-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170312192716.15172-1-daniel.vetter@ffwll.ch> References: <20170312192716.15172-1-daniel.vetter@ffwll.ch> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2813 Lines: 85 The trouble we have is that we can't really test all the shrinker recursion stuff exhaustively in BAT because any kind of thrashing stress test just takes too long. But that leaves a really big gap open, since shrinker recursions are one of the most annoying bugs. Now lockdep already has support for checking allocation deadlocks: - Direct reclaim paths are marked up with lockdep_set_current_reclaim_state() and lockdep_clear_current_reclaim_state(). - Any allocation paths are marked with lockdep_trace_alloc(). If we simply mark up our debugfs with the reclaim annotations, any code and locks taken in there will automatically complete the picture with any allocation paths we already have, as long as we have a simple testcase in BAT which throws out a few objects using this interface. Not stress test or thrashing needed at all. v2: Need to EXPORT_SYMBOL_GPL to make it compile as a module. v3: Fixup rebase fail (spotted by Chris). Cc: Chris Wilson Cc: Peter Zijlstra Cc: Ingo Molnar Cc: linux-kernel@vger.kernel.org Signed-off-by: Daniel Vetter -- Peter/Ingo, We want this to validate the i915 shrinker locking in our fast tests without thrashing badly (that takes too long, we can only thrash in the extended runs). Can you pls take a look and if it's ok ack for merging through drm-intel.git? Thanks, Daniel --- drivers/gpu/drm/i915/i915_debugfs.c | 2 ++ kernel/locking/lockdep.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 82fb005a5e22..fbe761a3f5bd 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -4273,6 +4273,7 @@ i915_drop_caches_set(void *data, u64 val) if (val & (DROP_RETIRE | DROP_ACTIVE)) i915_gem_retire_requests(dev_priv); + lockdep_set_current_reclaim_state(GFP_KERNEL); if (val & DROP_BOUND) i915_gem_shrink(dev_priv, LONG_MAX, I915_SHRINK_BOUND); @@ -4281,6 +4282,7 @@ i915_drop_caches_set(void *data, u64 val) if (val & DROP_SHRINK_ALL) i915_gem_shrink_all(dev_priv); + lockdep_clear_current_reclaim_state(); unlock: mutex_unlock(&dev->struct_mutex); diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 12e38c213b70..508cbf31d43e 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3856,11 +3856,13 @@ void lockdep_set_current_reclaim_state(gfp_t gfp_mask) { current->lockdep_reclaim_gfp = gfp_mask; } +EXPORT_SYMBOL_GPL(lockdep_set_current_reclaim_state); void lockdep_clear_current_reclaim_state(void) { current->lockdep_reclaim_gfp = 0; } +EXPORT_SYMBOL_GPL(lockdep_clear_current_reclaim_state); #ifdef CONFIG_LOCK_STAT static int -- 2.11.0