Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938878AbcJGPgC (ORCPT ); Fri, 7 Oct 2016 11:36:02 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:41302 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938757AbcJGPW2 (ORCPT ); Fri, 7 Oct 2016 11:22:28 -0400 Message-Id: <20161007150210.927453282@infradead.org> User-Agent: quilt/0.63-1 Date: Fri, 07 Oct 2016 16:52:44 +0200 From: Peter Zijlstra To: Linus Torvalds , Waiman Long , Jason Low , Ding Tianhong , Thomas Gleixner , Will Deacon , Ingo Molnar , Imre Deak , Linux Kernel Mailing List , Davidlohr Bueso , Tim Chen , Terry Rudd , "Paul E. McKenney" , Jason Low , Peter Zijlstra Cc: Chris Wilson , Daniel Vetter , Rob Clark Subject: [PATCH -v4 1/8] locking/drm: Kill mutex trickery References: <20161007145243.361481786@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=peterz-revert-drm-i915-brainmelt.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2416 Lines: 91 Poking at lock internals is not cool. Since I'm going to change the implementation this will break, take it out. Cc: Daniel Vetter Cc: Chris Wilson Cc: Rob Clark Signed-off-by: Peter Zijlstra (Intel) --- drivers/gpu/drm/i915/i915_gem_shrinker.c | 26 +++----------------------- drivers/gpu/drm/msm/msm_gem_shrinker.c | 23 +++-------------------- 2 files changed, 6 insertions(+), 43 deletions(-) --- a/drivers/gpu/drm/i915/i915_gem_shrinker.c +++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c @@ -35,19 +35,6 @@ #include "i915_drv.h" #include "i915_trace.h" -static bool mutex_is_locked_by(struct mutex *mutex, struct task_struct *task) -{ - if (!mutex_is_locked(mutex)) - return false; - -#if defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER) - return mutex->owner == task; -#else - /* Since UP may be pre-empted, we cannot assume that we own the lock */ - return false; -#endif -} - static int num_vma_bound(struct drm_i915_gem_object *obj) { struct i915_vma *vma; @@ -238,17 +225,10 @@ unsigned long i915_gem_shrink_all(struct static bool i915_gem_shrinker_lock(struct drm_device *dev, bool *unlock) { - if (!mutex_trylock(&dev->struct_mutex)) { - if (!mutex_is_locked_by(&dev->struct_mutex, current)) - return false; - - if (to_i915(dev)->mm.shrinker_no_lock_stealing) - return false; - - *unlock = false; - } else - *unlock = true; + if (!mutex_trylock(&dev->struct_mutex)) + return false; + *unlock = true; return true; } --- a/drivers/gpu/drm/msm/msm_gem_shrinker.c +++ b/drivers/gpu/drm/msm/msm_gem_shrinker.c @@ -18,29 +18,12 @@ #include "msm_drv.h" #include "msm_gem.h" -static bool mutex_is_locked_by(struct mutex *mutex, struct task_struct *task) -{ - if (!mutex_is_locked(mutex)) - return false; - -#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_MUTEXES) - return mutex->owner == task; -#else - /* Since UP may be pre-empted, we cannot assume that we own the lock */ - return false; -#endif -} - static bool msm_gem_shrinker_lock(struct drm_device *dev, bool *unlock) { - if (!mutex_trylock(&dev->struct_mutex)) { - if (!mutex_is_locked_by(&dev->struct_mutex, current)) - return false; - *unlock = false; - } else { - *unlock = true; - } + if (!mutex_trylock(&dev->struct_mutex)) + return false; + *unlock = true; return true; }