Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1618614

Re: [Intel-gfx] [PATCH 1/5] i915: avoid kernel hang caused by synchronize rcu struct_mutex deadlock

From Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [Intel-gfx] [PATCH 1/5] i915: avoid kernel hang caused by synchronize rcu struct_mutex deadlock
Date 2017-04-07 11:10 +0200
Message-ID <tty41-59R-1@gated-at.bofh.it> (permalink)
References <tsbVU-7s-13@gated-at.bofh.it> <ttp0J-7ym-3@gated-at.bofh.it> <ttp0J-7ym-7@gated-at.bofh.it>
Organization Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo

Show all headers | View raw


On pe, 2017-04-07 at 01:23 +0200, Andrea Arcangeli wrote:
> synchronize_rcu/synchronize_sched/synchronize_rcu_expedited() will
> hang until its own workqueues are run. The i915 gem workqueues will
> wait on the struct_mutex to be released. So we cannot wait for a
> quiescent state using those rcu primitives while holding the
> struct_mutex or it creates a circular lock dependency resulting in
> kernel hangs (which is reproducible but goes undetected by lockdep).
> 
> This started in commit 3d3d18f086cdda72ee18a454db70ca72c6e3246c and
> lockdep didn't detect it apparently.

The right format is;

Fixes: 3d3d18f086cd ("drm/i915: Avoid rcu_barrier() from reclaim paths (shrinker)")

> @@ -324,6 +320,16 @@ i915_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc)
>  	if (unlock)
>  		mutex_unlock(&dev->struct_mutex);
>  
> +	if (likely(__mutex_owner(&dev->struct_mutex) != current))

This check can be dropped and synchronize_rcu_expedited() should be
embedded directly to the if (unlock) branch as it's functionally
equivalent. This can be applied to all the unlock cases, not just this
one. That should be the correct action to avoid the deadlock. I've sent
a patch to do this (Cc'd you), can you verify that it gets rid of the
problem for you?

> +		/*
> +		 * If reclaim was invoked by an allocation done while
> +		 * holding the struct mutex, we cannot call
> +		 * synchronize_rcu_expedited() as it depends on
> +		 * workqueues to run but the running workqueue may be
> +		 * blocked waiting on us to release struct_mutex.
> +		 */
> +		synchronize_rcu_expedited();
> +
>  	return freed;
>  }
>  
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [Intel-gfx] [BUG][REGRESSION] i915 gpu hangs under load Thorsten Leemhuis <regressions@leemhuis.info> - 2017-04-02 14:00 +0200
  Re: [Intel-gfx] [BUG][REGRESSION] i915 gpu hangs under load Martin Kepplinger <martink@posteo.de> - 2017-04-02 14:20 +0200
    Re: [Intel-gfx] [BUG][REGRESSION] i915 gpu hangs under load Jani Nikula <jani.nikula@linux.intel.com> - 2017-04-03 17:20 +0200
      [PATCH 1/5] i915: avoid kernel hang caused by synchronize rcu struct_mutex deadlock Andrea Arcangeli <aarcange@redhat.com> - 2017-04-07 01:30 +0200
        Re: [Intel-gfx] [PATCH 1/5] i915: avoid kernel hang caused by  synchronize rcu struct_mutex deadlock Joonas Lahtinen <joonas.lahtinen@linux.intel.com> - 2017-04-07 11:10 +0200
      [PATCH 3/5] i915: initialize the free_list of the fencing atomic_helper Andrea Arcangeli <aarcange@redhat.com> - 2017-04-07 01:30 +0200
        Re: [PATCH 3/5] i915: initialize the free_list of the fencing  atomic_helper Chris Wilson <chris@chris-wilson.co.uk> - 2017-04-07 12:40 +0200
      [PATCH 5/5] i915: fence workqueue optimization Andrea Arcangeli <aarcange@redhat.com> - 2017-04-07 01:30 +0200
        Re: [PATCH 5/5] i915: fence workqueue optimization Chris Wilson <chris@chris-wilson.co.uk> - 2017-04-07 12:00 +0200
          Re: [PATCH 5/5] i915: fence workqueue optimization Andrea Arcangeli <aarcange@redhat.com> - 2017-04-07 15:20 +0200
      [PATCH 4/5] i915: schedule while freeing the lists of gem objects Andrea Arcangeli <aarcange@redhat.com> - 2017-04-07 01:30 +0200
      [PATCH 0/5] Re: [Intel-gfx] [BUG][REGRESSION] i915 gpu hangs under load Andrea Arcangeli <aarcange@redhat.com> - 2017-04-07 01:30 +0200
        [PATCH 2/5] i915: flush gem obj freeing workqueues to add accuracy to the i915 shrinker Andrea Arcangeli <aarcange@redhat.com> - 2017-04-07 01:30 +0200
          Re: [PATCH 2/5] i915: flush gem obj freeing workqueues to add  accuracy to the i915 shrinker Chris Wilson <chris@chris-wilson.co.uk> - 2017-04-07 12:10 +0200
            Re: [PATCH 2/5] i915: flush gem obj freeing workqueues to add  accuracy to the i915 shrinker Andrea Arcangeli <aarcange@redhat.com> - 2017-04-07 15:10 +0200
              Re: [PATCH 2/5] i915: flush gem obj freeing workqueues to add  accuracy to the i915 shrinker Chris Wilson <chris@chris-wilson.co.uk> - 2017-04-07 17:40 +0200
                Re: [PATCH 2/5] i915: flush gem obj freeing workqueues to add  accuracy to the i915 shrinker Andrea Arcangeli <aarcange@redhat.com> - 2017-04-09 22:20 +0200
                Re: [PATCH 2/5] i915: flush gem obj freeing workqueues to add  accuracy to the i915 shrinker Chris Wilson <chris@chris-wilson.co.uk> - 2017-04-10 11:40 +0200
        Re: [PATCH 0/5] Re: [Intel-gfx] [BUG][REGRESSION] i915 gpu hangs  under load Martin Kepplinger <martink@posteo.de> - 2017-04-10 12:20 +0200

csiph-web