Commit 3824e419 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Use mutex_lock_killable() from inside the shrinker

If the current process is being killed (it was interrupted with SIGKILL
or equivalent), it will not make any progress in page allocation and we
can abort performing the shrinking on its behalf. So we can use
mutex_lock_killable() instead (although this path should only be
reachable from kswapd currently).

Tvrtko pointed out that it should also be reachable from debugfs, which
he would prefer retain its interruptiblity. As a compromise, killable is a
step in the right direction!
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190109164204.23935-1-chris@chris-wilson.co.uk
parent 7f9e20ef
...@@ -39,18 +39,18 @@ static bool shrinker_lock(struct drm_i915_private *i915, ...@@ -39,18 +39,18 @@ static bool shrinker_lock(struct drm_i915_private *i915,
unsigned int flags, unsigned int flags,
bool *unlock) bool *unlock)
{ {
switch (mutex_trylock_recursive(&i915->drm.struct_mutex)) { struct mutex *m = &i915->drm.struct_mutex;
switch (mutex_trylock_recursive(m)) {
case MUTEX_TRYLOCK_RECURSIVE: case MUTEX_TRYLOCK_RECURSIVE:
*unlock = false; *unlock = false;
return true; return true;
case MUTEX_TRYLOCK_FAILED: case MUTEX_TRYLOCK_FAILED:
*unlock = false; *unlock = false;
if (flags & I915_SHRINK_ACTIVE) { if (flags & I915_SHRINK_ACTIVE &&
mutex_lock_nested(&i915->drm.struct_mutex, mutex_lock_killable_nested(m, I915_MM_SHRINKER) == 0)
I915_MM_SHRINKER);
*unlock = true; *unlock = true;
}
return *unlock; return *unlock;
case MUTEX_TRYLOCK_SUCCESS: case MUTEX_TRYLOCK_SUCCESS:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment