[PATCH 2/9] async: Introduce kfence, a N:M completion mechanism

2016-07-13 Thread Peter Zijlstra
On Fri, Jun 24, 2016 at 10:08:46AM +0100, Chris Wilson wrote: > diff --git a/kernel/async.c b/kernel/async.c > index d2edd6efec56..d0bcb7cc4884 100644 > --- a/kernel/async.c > +++ b/kernel/async.c > @@ -50,6 +50,7 @@ asynchronous and synchronous parts of the kernel. > > #include > #include >

[PATCH 2/9] async: Introduce kfence, a N:M completion mechanism

2016-07-13 Thread Peter Zijlstra
On Fri, Jun 24, 2016 at 10:08:46AM +0100, Chris Wilson wrote: > +struct kfence { > + wait_queue_head_t wait; > + unsigned long flags; > + struct kref kref; > + atomic_t pending; > +}; > +#define KFENCE_CHECKED_BIT 0 > + > +static void kfence_free(struct kref *kref) > +{ > + s

[PATCH 5/9] async: Wrap hrtimer to provide a time source for a kfence

2016-07-13 Thread Peter Zijlstra
On Fri, Jun 24, 2016 at 10:08:49AM +0100, Chris Wilson wrote: > kfence_add_delay() is a convenience wrapper around > hrtimer_start_range_ns() to provide a time source for a kfence graph. Changelog could be greatly improved by telling us why we'd want this.

[PATCH 3/9] async: Extend kfence to allow struct embedding

2016-07-13 Thread Peter Zijlstra
On Fri, Jun 24, 2016 at 10:08:47AM +0100, Chris Wilson wrote: > @@ -151,7 +161,11 @@ static void kfence_free(struct kref *kref) > > WARN_ON(atomic_read(&fence->pending) > 0); > > - kfree(fence); > + if (fence->flags) { > + kfence_notify_t fn = (kfence_notify_t)fence->f

Re: [PATCH] mutex: fix deadlock injection

2013-07-30 Thread Peter Zijlstra
On Tue, Jul 30, 2013 at 10:13:41AM +0200, Maarten Lankhorst wrote: > The check needs to be for > 1, because ctx->acquired is already incremented. > This will prevent ww_mutex_lock_slow from returning -EDEADLK and not locking > the mutex. It caused a lot of false gpu lockups on radeon with > CONFIG_

Re: [BUG] completely bonkers use of set_need_resched + VM_FAULT_NOPAGE

2013-09-12 Thread Peter Zijlstra
On Thu, Sep 12, 2013 at 05:36:43PM +0200, Daniel Vetter wrote: > The set_need_resched in i915_gem.c:i915_gem_fault can actually be > removed. It was there to give the error handler a chance to sneak in > and reset the hw/sw tracking when the gpu is dead. That hack goes back > to the days when the l

Re: [BUG] completely bonkers use of set_need_resched + VM_FAULT_NOPAGE

2013-09-12 Thread Peter Zijlstra
On Thu, Sep 12, 2013 at 05:58:49PM +0200, Daniel Vetter wrote: > On Thu, Sep 12, 2013 at 5:43 PM, Peter Zijlstra wrote: > >> The one in ttm is just bonghits to shut up lockdep: ttm can recurse > >> into it's own pagefault handler and then deadlock, the trylock just >

Re: [PATCH 2/2] drm/udl: rip out set_need_resched

2013-09-12 Thread Peter Zijlstra
no other > reason for this just drop it. > > Reported-by: Peter Zijlstra Thanks! Acked-by: Peter Zijlstra ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [BUG] completely bonkers use of set_need_resched + VM_FAULT_NOPAGE

2013-09-12 Thread Peter Zijlstra
On Thu, Sep 12, 2013 at 05:35:43PM +0100, Chris Wilson wrote: > Not quite, as it would be possible for the evil userspace to trigger a > GPU hang that would cause the sane userspace to spin indefinitely > waiting for the error recovery to kick in. So with FIFOn+1 preempting FIFOn its a live-lock

Re: [PATCH 1/2] drm/i915: kill set_need_resched

2013-09-12 Thread Peter Zijlstra
> rip the reschedule-point out. > > Reported-by: Peter Zijlstra Thanks! Acked-by: Peter Zijlstra ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [BUG] completely bonkers use of set_need_resched + VM_FAULT_NOPAGE

2013-09-12 Thread Peter Zijlstra
On Thu, Sep 12, 2013 at 05:11:25PM +0200, Maarten Lankhorst wrote: > Op 12-09-13 17:06, Peter Zijlstra schreef: > > Hi Dave, > > > > So I'm poking around the preemption code and stumbled upon: > > > > drivers/gpu/drm/i915/i915_gem.c:set_n

[BUG] completely bonkers use of set_need_resched + VM_FAULT_NOPAGE

2013-09-12 Thread Peter Zijlstra
Hi Dave, So I'm poking around the preemption code and stumbled upon: drivers/gpu/drm/i915/i915_gem.c:set_need_resched(); drivers/gpu/drm/ttm/ttm_bo_vm.c:set_need_resched(); drivers/gpu/drm/ttm/ttm_bo_vm.c:set_need_resched(); drivers/

Re: [BUG] completely bonkers use of set_need_resched + VM_FAULT_NOPAGE

2013-09-13 Thread Peter Zijlstra
On Fri, Sep 13, 2013 at 09:46:03AM +0200, Thomas Hellstrom wrote: > >>if (!bo_tryreserve()) { > >> up_read mmap_sem(); // Release the mmap_sem to avoid deadlocks. > >> bo_reserve(); // Wait for the BO to become available > >> (interruptible) > >> bo_unreserve();

Re: [BUG] completely bonkers use of set_need_resched + VM_FAULT_NOPAGE

2013-09-13 Thread Peter Zijlstra
On Fri, Sep 13, 2013 at 10:41:54AM +0200, Daniel Vetter wrote: > On Fri, Sep 13, 2013 at 10:29 AM, Peter Zijlstra wrote: > > On Fri, Sep 13, 2013 at 09:46:03AM +0200, Thomas Hellstrom wrote: > >> >>if (!bo_tryreserve()) { > >> >> up_read mmap_sem(); //

[PATCH v2 01/11] drm/vgem: Use ww_mutex_(un)lock even with a NULL context

2016-12-01 Thread Peter Zijlstra
Just to let you know, I've not been ignoring all the ww_mutex stuff, I've been ill this week. I'm slowly returning to feeling human again, but am still fairly wrecked.

[PATCH v2 02/11] locking/ww_mutex: Re-check ww->ctx in the inner optimistic spin loop

2016-12-06 Thread Peter Zijlstra
On Thu, Dec 01, 2016 at 03:06:45PM +0100, Nicolai Hähnle wrote: > +++ b/kernel/locking/mutex.c > @@ -350,7 +350,8 @@ ww_mutex_set_context_slowpath(struct ww_mutex *lock, > * access and not reliable. > */ > static noinline > -bool mutex_spin_on_owner(struct mutex *lock, struct task_struct *own

[PATCH v2 04/11] locking/ww_mutex: Set use_ww_ctx even when locking without a context

2016-12-06 Thread Peter Zijlstra
On Thu, Dec 01, 2016 at 03:06:47PM +0100, Nicolai Hähnle wrote: > +++ b/include/linux/ww_mutex.h > @@ -222,11 +222,7 @@ extern int __must_check > __ww_mutex_lock_interruptible(struct ww_mutex *lock, > */ > static inline int ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx > *ctx) >

[PATCH v2 04/11] locking/ww_mutex: Set use_ww_ctx even when locking without a context

2016-12-06 Thread Peter Zijlstra
On Thu, Dec 01, 2016 at 03:06:47PM +0100, Nicolai Hähnle wrote: > @@ -640,10 +640,11 @@ __mutex_lock_common(struct mutex *lock, long state, > unsigned int subclass, > struct mutex_waiter waiter; > unsigned long flags; > bool first = false; > - struct ww_mutex *ww; > i

[PATCH v2 05/11] locking/ww_mutex: Add waiters in stamp order

2016-12-06 Thread Peter Zijlstra
On Thu, Dec 01, 2016 at 03:06:48PM +0100, Nicolai Hähnle wrote: > +static inline int __sched > +__ww_mutex_add_waiter(struct mutex_waiter *waiter, > + struct mutex *lock, > + struct ww_acquire_ctx *ww_ctx) > +{ > + struct mutex_waiter *cur; > + > + if (!

[PATCH v2 05/11] locking/ww_mutex: Add waiters in stamp order

2016-12-06 Thread Peter Zijlstra
On Thu, Dec 01, 2016 at 03:06:48PM +0100, Nicolai Hähnle wrote: > @@ -693,8 +748,12 @@ __mutex_lock_common(struct mutex *lock, long state, > unsigned int subclass, >* mutex_unlock() handing the lock off to us, do a trylock >* before testing the error conditions to

[PATCH v2 02/11] locking/ww_mutex: Re-check ww->ctx in the inner optimistic spin loop

2016-12-06 Thread Peter Zijlstra
On Tue, Dec 06, 2016 at 11:03:28AM -0500, Waiman Long wrote: > > The mutex_spin_on_owner() function was originally marked noinline > because it could be a major consumer of CPU cycles in a contended lock. > Having it shown separately in the perf output will help the users have a > better understan

[PATCH v2 05/11] locking/ww_mutex: Add waiters in stamp order

2016-12-16 Thread Peter Zijlstra
On Fri, Dec 16, 2016 at 03:19:43PM +0100, Nicolai Hähnle wrote: > Hi Peter and Chris, > > (trying to combine the handoff discussion here) > > On 06.12.2016 17:55, Peter Zijlstra wrote: > >On Thu, Dec 01, 2016 at 03:06:48PM +0100, Nicolai Hähnle wrote:

[PATCH v2 05/11] locking/ww_mutex: Add waiters in stamp order

2016-12-16 Thread Peter Zijlstra
On Fri, Dec 16, 2016 at 03:19:43PM +0100, Nicolai Hähnle wrote: > The concern about picking up a handoff that we didn't request is real, > though it cannot happen in the first iteration. Perhaps this __mutex_trylock > can be moved to the end of the loop? See below... > >>@@ -728,7 +800,7 @@ __mu

[PATCH v2 05/11] locking/ww_mutex: Add waiters in stamp order

2016-12-16 Thread Peter Zijlstra
On Fri, Dec 16, 2016 at 03:19:43PM +0100, Nicolai Hähnle wrote: > >>@@ -716,7 +775,20 @@ __mutex_lock_common(struct mutex *lock, long state, > >>unsigned int subclass, > >>spin_unlock_mutex(&lock->wait_lock, flags); > >>schedule_preempt_disabled(); > >> > >>- if

[PATCH v2 05/11] locking/ww_mutex: Add waiters in stamp order

2016-12-16 Thread Peter Zijlstra
On Fri, Dec 16, 2016 at 07:11:41PM +0100, Nicolai Hähnle wrote: > mutex_optimistic_spin() already calls __mutex_trylock, and for the no-spin > case, __mutex_unlock_slowpath() only calls wake_up_q() after releasing the > wait_lock. mutex_optimistic_spin() is a no-op when !CONFIG_MUTEX_SPIN_ON_OWNE

[PATCH v2 04/11] locking/ww_mutex: Set use_ww_ctx even when locking without a context

2016-12-17 Thread Peter Zijlstra
On Fri, Dec 16, 2016 at 02:17:25PM +0100, Nicolai Hähnle wrote: > On 06.12.2016 16:25, Peter Zijlstra wrote: > >On Thu, Dec 01, 2016 at 03:06:47PM +0100, Nicolai Hähnle wrote: > > > >>@@ -640,10 +640,11 @@ __mutex_lock_common(struct mutex *lock, long state, &

[PATCH v3 05/12] locking/ww_mutex: Remove the __ww_mutex_lock inline wrappers

2016-12-23 Thread Peter Zijlstra
On Wed, Dec 21, 2016 at 07:46:33PM +0100, Nicolai Hähnle wrote: > diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h > index a5960e5..b2eaaab 100644 > --- a/include/linux/ww_mutex.h > +++ b/include/linux/ww_mutex.h > @@ -186,11 +186,6 @@ static inline void ww_acquire_fini(struct ww_a

[PATCH v3 05/12] locking/ww_mutex: Remove the __ww_mutex_lock inline wrappers

2016-12-23 Thread Peter Zijlstra
On Fri, Dec 23, 2016 at 12:16:03PM +0100, Nicolai Hähnle wrote: > >For some reason this patch appears to make lib/locking-selftest.c really > >unhappy. > > > >I get endless streams of: > > > >../lib/locking-selftest.c: In function ‘ww_test_fail_acquire’: > >../lib/locking-selftest.c:1141:6: e

[Intel-gfx] [RFC 4/6] drm/i915: Add i915 perf event for Haswell OA unit

2015-09-29 Thread Peter Zijlstra
On Tue, Sep 29, 2015 at 10:55:39PM +0800, kbuild test robot wrote: > Hi Robert, > > [auto build test results on v4.3-rc3 -- if it's inappropriate base, please > ignore] > > config: i386-defconfig (attached as .config) > reproduce: > git checkout a1d59679ae8f3e7e7659e9723ae3fc69af2532e6 > # s

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-13 Thread Peter Zijlstra
/me wonders what's up with partial Cc's today.. On Wed, Jun 13, 2018 at 09:47:44AM +0200, Thomas Hellstrom wrote: > The current Wound-Wait mutex algorithm is actually not Wound-Wait but > Wait-Die. Implement also Wound-Wait as a per-ww-class choice. Wound-Wait > is, contrary to Wait-Die a preempt

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-13 Thread Peter Zijlstra
On Wed, Jun 13, 2018 at 12:40:29PM +0200, Thomas Hellstrom wrote: > On 06/13/2018 11:50 AM, Peter Zijlstra wrote: > > > > > + > > > + lockdep_assert_held(&lock->wait_lock); > > > + > > > + if (owner && hold_ctx && __ww_c

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-14 Thread Peter Zijlstra
On Wed, Jun 13, 2018 at 04:05:43PM +0200, Thomas Hellstrom wrote: > In short, with Wait-Die (before the patch) it's the process _taking_ the > contended lock that backs off if necessary. No preemption required. With > Wound-Wait, it's the process _holding_ the contended lock that gets wounded > (pr

Re: [PATCH v2 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-14 Thread Peter Zijlstra
On Thu, Jun 14, 2018 at 09:29:21AM +0200, Thomas Hellstrom wrote: > __ww_mutex_wakeup_for_backoff(struct mutex *lock, struct ww_acquire_ctx > *ww_ctx) > { > struct mutex_waiter *cur; > + unsigned int is_wait_die = ww_ctx->ww_class->is_wait_die; > > lockdep_assert_held(&lock->w

Re: [PATCH v2 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-14 Thread Peter Zijlstra
On Thu, Jun 14, 2018 at 09:29:21AM +0200, Thomas Hellstrom wrote: > +static bool __ww_mutex_wound(struct mutex *lock, > + struct ww_acquire_ctx *ww_ctx, > + struct ww_acquire_ctx *hold_ctx) > +{ > + struct task_struct *owner = __mutex_owner(lock

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-14 Thread Peter Zijlstra
On Thu, Jun 14, 2018 at 01:48:39PM +0200, Thomas Hellstrom wrote: > The literature makes a distinction between "killed" and "wounded". In our > context, "Killed" is when a transaction actually receives an -EDEADLK and > needs to back off. "Wounded" is when someone (typically another transaction) >

Re: [PATCH v2 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-14 Thread Peter Zijlstra
On Thu, Jun 14, 2018 at 03:43:04PM +0200, Thomas Hellstrom wrote: > It's intended to be enforced by storing the algorithm choice in the > WW_MUTEX_CLASS which must be common for an acquire context and the > ww_mutexes it acquires. However, I don't think there is a check that that > holds. I guess w

Re: [PATCH 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-14 Thread Peter Zijlstra
On Thu, Jun 14, 2018 at 06:43:40PM +0200, Thomas Hellstrom wrote: > Overall, I think this looks fine. I'll just fix up the FLAG_WAITERS setting > and affected comments and do some torture testing on it. Thanks! > Are you OK with adding the new feature and the cleanup in the same patch? I suppose

Re: [PATCH] locking: Fix mutex debug call and ww_mutex doc

2018-09-07 Thread Peter Zijlstra
On Mon, Sep 03, 2018 at 04:07:08PM +0200, Thomas Hellstrom wrote: > Commit 08295b3b5bee ("Implement an algorithm choice for Wound-Wait > mutexes") introduced a reference in the documentation to a function > that was removed in an earlier commit. > > It also forgot to remove a call to debug_mutex_a

Re: [PATCH v3 2/2] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-15 Thread Peter Zijlstra
On Fri, Jun 15, 2018 at 02:08:27PM +0200, Thomas Hellstrom wrote: > @@ -772,6 +856,25 @@ __ww_mutex_add_waiter(struct mutex_waiter *waiter, > } > > list_add_tail(&waiter->list, pos); > + if (__mutex_waiter_is_first(lock, waiter)) > + __mutex_set_flag(lock, MUTEX_FLAG_

Re: [PATCH 1/3] locking: WW mutex cleanup

2018-06-19 Thread Peter Zijlstra
linux/ww_mutex.h | 28 ++--- > kernel/locking/mutex.c| 202 > ++ > 3 files changed, 145 insertions(+), 97 deletions(-) Acked-by: Peter Zijlstra (Intel) ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v4 2/3] locking: Implement an algorithm choice for Wound-Wait mutexes

2018-06-19 Thread Peter Zijlstra
edanne > Cc: Greg Kroah-Hartman > Cc: linux-...@vger.kernel.org > Cc: linux-me...@vger.kernel.org > Cc: linaro-mm-...@lists.linaro.org > Co-authored-by: Peter Zijlstra > Signed-off-by: Thomas Hellstrom > > --- > Documentation/locking/ww-mutex-design.txt | 57 +

Re: [PATCH v4 0/4] locking,drm: Fix ww mutex naming / algorithm inconsistency

2018-06-19 Thread Peter Zijlstra
I suspect you want this through the DRM tree? Ingo are you OK with that? ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 1/3] locking: WW mutex cleanup

2018-06-19 Thread Peter Zijlstra
On Tue, Jun 19, 2018 at 12:44:52PM +0200, Thomas Hellstrom wrote: > On 06/19/2018 11:44 AM, Peter Zijlstra wrote: > > On Tue, Jun 19, 2018 at 10:24:43AM +0200, Thomas Hellstrom wrote: > > > From: Peter Ziljstra > > > > > > Make the WW mutex code more reada

Re: [PATCH 11/12] sched: use for_each_if in topology.h

2018-07-09 Thread Peter Zijlstra
On Mon, Jul 09, 2018 at 10:36:49AM +0200, Daniel Vetter wrote: > Avoids complaints from gcc about ambiguous else clauses. Is that a new thing? I'm fairly sure I've never seen it do that, > Signed-off-by: Daniel Vetter > Cc: Andrew Morton > Cc: Peter Zijlstra > --- &g

Re: [PATCH 11/12] sched: use for_each_if in topology.h

2018-07-09 Thread Peter Zijlstra
On Mon, Jul 09, 2018 at 05:00:07PM +0200, Daniel Vetter wrote: > On Mon, Jul 9, 2018 at 12:36 PM, Peter Zijlstra wrote: > > On Mon, Jul 09, 2018 at 10:36:49AM +0200, Daniel Vetter wrote: > >> #define for_each_node_with_cpus(node)\ > >>

Re: [PATCH 11/12] sched: use for_each_if in topology.h

2018-07-09 Thread Peter Zijlstra
On Mon, Jul 09, 2018 at 05:52:04PM +0200, Daniel Vetter wrote: > for_each_something(foo) > if (foo->bla) > call_bla(foo); > else > call_default(foo); > > Totally contrived, but this complains. Liberally sprinkling {} also shuts > up the compiler, but it's a

Re: [PATCH 11/12] sched: use for_each_if in topology.h

2018-07-09 Thread Peter Zijlstra
On Mon, Jul 09, 2018 at 05:52:04PM +0200, Daniel Vetter wrote: > for_each_something(foo) > if (foo->bla) > call_bla(foo); > else > call_default(foo); Note that the kernel coding style 'discourages' this style and would like you to write: for_each_so

Re: [PATCH 2/4] kernel.h: Add non_block_start/end()

2018-12-10 Thread Peter Zijlstra
On Mon, Dec 10, 2018 at 03:13:37PM +0100, Michal Hocko wrote: > I do not see any scheduler guys Cced and it would be really great to get > their opinion here. > > On Mon 10-12-18 11:36:39, Daniel Vetter wrote: > > In some special cases we must not block, but there's not a > > spinlock, preempt-off

Re: [PATCH 2/4] kernel.h: Add non_block_start/end()

2018-12-10 Thread Peter Zijlstra
On Mon, Dec 10, 2018 at 05:20:10PM +0100, Michal Hocko wrote: > > OK, no real objections to the thing. Just so long we're all on the same > > page as to what it does and doesn't do ;-) > > I am not really sure whether there are other potential users besides > this one and whether the check as suc

Re: [PATCH 2/4] kernel.h: Add non_block_start/end()

2018-12-10 Thread Peter Zijlstra
On Mon, Dec 10, 2018 at 04:01:59PM +0100, Michal Hocko wrote: > On Mon 10-12-18 15:47:11, Peter Zijlstra wrote: > > On Mon, Dec 10, 2018 at 03:13:37PM +0100, Michal Hocko wrote: > > > I do not see any scheduler guys Cced and it would be really great to get > > > their op

Re: [PATCH 6/7] drm/i915/pmu: Lazy unregister

2024-07-24 Thread Peter Zijlstra
On Tue, Jul 23, 2024 at 10:30:08AM -0500, Lucas De Marchi wrote: > On Tue, Jul 23, 2024 at 09:03:25AM GMT, Tvrtko Ursulin wrote: > > > > On 22/07/2024 22:06, Lucas De Marchi wrote: > > > Instead of calling perf_pmu_unregister() when unbinding, defer that to > > > the destruction of i915 object. Si

Re: [PATCH 5/5] fs: Convert struct file::f_count to refcount_long_t

2024-05-03 Thread Peter Zijlstra
On Fri, May 03, 2024 at 11:37:25AM +0200, Christian Brauner wrote: > On Thu, May 02, 2024 at 05:41:23PM -0700, Kees Cook wrote: > > On Fri, May 03, 2024 at 01:14:45AM +0100, Al Viro wrote: > > > On Thu, May 02, 2024 at 05:10:18PM -0700, Kees Cook wrote: > > > > > > > But anyway, there needs to be

Re: [PATCH] kthread: finer-grained lockdep/cross-release completion

2018-03-15 Thread Peter Zijlstra
On Thu, Mar 15, 2018 at 11:31:57AM +0100, Daniel Vetter wrote: > Is there any progress on getting cross-release enabled again? Not yet, I'm still fighting the meltdown/spectre induced backlog. We'll get to it eventually. ___ dri-devel mailing list dri-d

Re: [PATCH 1/4] locking/ww_mutex: add ww_mutex_is_owned_by function v3

2018-02-20 Thread Peter Zijlstra
On Tue, Feb 20, 2018 at 01:58:26PM +0100, Christian König wrote: > amdgpu needs to verify if userspace sends us valid addresses and the simplest > way of doing this is to check if the buffer object is locked with the ticket > of the current submission. > > Clean up the access to the ww_mutex inter

Re: [PATCH 1/3] locking/ww_mutex: cleanup lock->ctx usage in amdgpu

2018-02-20 Thread Peter Zijlstra
On Tue, Feb 20, 2018 at 02:08:26PM +0100, Christian König wrote: > Am 20.02.2018 um 13:35 schrieb Peter Zijlstra: > > > +static inline bool ww_mutex_is_owned_by(struct ww_mutex *lock, > > > + struct task_struct *task, > > > +

Re: [PATCH 1/3] locking/ww_mutex: cleanup lock->ctx usage in amdgpu

2018-02-20 Thread Peter Zijlstra
This really should've been Cc'ed to me. On Thu, Feb 15, 2018 at 03:19:42PM +0100, Christian König wrote: > diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h > index 39fda195bf78..dd580db289e8 100644 > --- a/include/linux/ww_mutex.h > +++ b/include/linux/ww_mutex.h > @@ -358,4 +358,

Re: [PATCH 1/4] locking/ww_mutex: add ww_mutex_is_owned_by function v3

2018-02-20 Thread Peter Zijlstra
On Tue, Feb 20, 2018 at 02:26:55PM +0100, Christian König wrote: > > > +static inline bool ww_mutex_is_owned_by(struct ww_mutex *lock, > > > + struct ww_acquire_ctx *ctx) > > > +{ > > > + if (ctx) > > > + return likely(READ_ONCE(lock->ctx) == ctx); > > > + el

Re: [PATCH 1/4] locking/ww_mutex: add ww_mutex_is_owned_by function v3

2018-02-20 Thread Peter Zijlstra
On Tue, Feb 20, 2018 at 03:34:07PM +0100, Christian König wrote: > > OK, but neither case would in fact need the !ctx case right? That's just > > there for completeness sake? > > Unfortunately not. TTM uses trylock to lock BOs which are about to be > evicted to make room for all the BOs locked wit

Re: [PATCH 1/4] locking/ww_mutex: add ww_mutex_is_owned_by function v3

2018-02-20 Thread Peter Zijlstra
On Tue, Feb 20, 2018 at 04:05:49PM +0100, Christian König wrote: > Am 20.02.2018 um 15:54 schrieb Peter Zijlstra: > > On Tue, Feb 20, 2018 at 03:34:07PM +0100, Christian König wrote: > > > > OK, but neither case would in fact need the !ctx case right? That's just >

Re: 4.9-rc1 lockdep warning suggesting a deadlock between nouveau and i915 with prime video outputs active

2017-07-13 Thread Peter Zijlstra
On Thu, Jul 13, 2017 at 03:57:31PM +0200, Jiri Slaby wrote: > Hmm, not that easy: > [ +0.011001] BUG: key 8807573ed758 not in .data! > [ +0.000103] DEBUG_LOCKS_WARN_ON(1) > [ +0.12] [ cut here ] > [ +0.000147] WARNING: CPU: 1 PID: 282 at > ../kernel/locking/lock

Re: [regression drm/noveau] suspend to ram -> BOOM: exception RIP: drm_calc_vbltimestamp_from_scanoutpos+335

2017-07-14 Thread Peter Zijlstra
gs no longer warn, they blow the box out of the water.  I made a > dinky testcase module (attached), and bisected to the real root > > 19d436268dde95389c616bb3819da73f0a8b28a8 is the first bad commit > commit 19d436268dde95389c616bb3819da73f0a8b28a8 > Author: Peter Zijlstra &g

Re: [Nouveau] [regression drm/noveau] suspend to ram -> BOOM: exception RIP: drm_calc_vbltimestamp_from_scanoutpos+335

2017-07-14 Thread Peter Zijlstra
On Fri, Jul 14, 2017 at 11:20:01AM -0400, Ilia Mirkin wrote: > On Fri, Jul 14, 2017 at 11:19 AM, Tobias Klausmann > wrote: > > The conversion is a nice catch, but i'd like to have a bit more context, see > > below! > > > > With a better description: > > > > Tobias Klausmann > > I don't think it

Re: [regression drm/noveau] suspend to ram -> BOOM: exception RIP: drm_calc_vbltimestamp_from_scanoutpos+335

2017-07-14 Thread Peter Zijlstra
On Fri, Jul 14, 2017 at 05:58:18PM +0200, Mike Galbraith wrote: > On Fri, 2017-07-14 at 17:50 +0200, Peter Zijlstra wrote: > > Urgh, is for some mysterious reason the __bug_table section of modules > > ending up in RO memory? > > > > I forever get lost in that link m

Re: [PATCH] drm: Don't complain too much about struct_mutex.

2017-07-17 Thread Peter Zijlstra
On Sat, Jul 15, 2017 at 11:53:28AM +0200, Daniel Vetter wrote: > A more complete solution would be to do the mutex_init in the drm core > only for legacy drivers, plus add it to each modern driver that still > needs it, which would also give each its own lockdep key. Trying to do > that dynamically

Re: [PATCH] drm: Don't complain too much about struct_mutex.

2017-07-17 Thread Peter Zijlstra
On Mon, Jul 17, 2017 at 05:06:42PM +0200, Daniel Vetter wrote: > On Mon, Jul 17, 2017 at 11:35 AM, Peter Zijlstra wrote: > > On Sat, Jul 15, 2017 at 11:53:28AM +0200, Daniel Vetter wrote: > >> A more complete solution would be to do the mutex_init in the drm core > >&

Re: [PATCH] kthread: finer-grained lockdep/cross-release completion

2017-12-07 Thread Peter Zijlstra
On Thu, Dec 07, 2017 at 11:08:49AM +0100, Daniel Vetter wrote: > Since -rc1 we're hitting a bunch of lockdep splats using the new > cross-release stuff around the 2 kthread completions. In all cases > they are because totally independent uses of kthread are mixed up by > lockdep into the same locki

Re: [PATCH] kthread: finer-grained lockdep/cross-release completion

2017-12-07 Thread Peter Zijlstra
On Thu, Dec 07, 2017 at 03:58:28PM +0100, Daniel Vetter wrote: > [ 85.069417] gem_exec_captur/2810 is trying to acquire lock: > [ 85.069419] ((completion)&self->parked){+.+.}, at: [] > kthread_park+0x3d/0x50 > [ 85.069426] >but task is already holding lock: > [ 85.069428

Re: [Intel-gfx] [PATCH] kthread: finer-grained lockdep/cross-release completion

2017-12-08 Thread Peter Zijlstra
On Thu, Dec 07, 2017 at 09:56:57PM +0100, Daniel Vetter wrote: > On Thu, Dec 07, 2017 at 08:57:09PM +0100, Peter Zijlstra wrote: > > Is what it says I suppose. Now I don't know enough about that i915 code > > to say if that breadcrumbs_signal thread can ever trigger a fau

Re: [PATCH] kthread: finer-grained lockdep/cross-release completion

2017-12-08 Thread Peter Zijlstra
ue to the many entry points this is slightly > tedious. > > Cc: Tvrtko Ursulin > Cc: Marta Lofstedt > Cc: Byungchul Park > Cc: Ingo Molnar > Cc: Peter Zijlstra > Cc: Tejun Heo > Cc: Kees Cook > Cc: Thomas Gleixner > Cc: Shaohua Li > Cc: Andrew Morton &

Re: [Intel-gfx] [PATCH] kthread: finer-grained lockdep/cross-release completion

2017-12-08 Thread Peter Zijlstra
On Fri, Dec 08, 2017 at 05:36:28PM +0100, Daniel Vetter wrote: > Aside: Could/should we take some fake lockdep locks around these > callbacks, since not all drivers call them from a hardirq context? Just to > validate that everyone follows the contract. What I typically do is use local_irq_save/r

Re: [PATCH] drm/i915: properly init lockdep class

2017-12-13 Thread Peter Zijlstra
On Wed, Dec 13, 2017 at 06:36:33PM +0100, Sebastian Andrzej Siewior wrote: > +peterz > context: http://www.spinics.net/lists/intel-gfx/msg149011.html > > On 2017-12-13 17:37:21 [+0200], Joonas Lahtinen wrote: > > On Wed, 2017-12-13 at 16:06 +0100, Sebastian Andrzej Siewior wrote: > > > On 2017-12-

Re: [PATCH] fbcon: fix race condition between console lock and cursor timer

2012-08-21 Thread Peter Zijlstra
On Tue, 2012-08-21 at 10:15 +0100, Alan Cox wrote: > > So after much tracing with direct netconsole writes (printks > > under console_lock not so useful), I think I found the race. > > Direct netconsole write would be a useful patch to have mainline I think > 8) could we make that use the earlyp

Re: [PATCH] fbcon: fix race condition between console lock and cursor timer

2012-08-21 Thread Peter Zijlstra
On Tue, 2012-08-21 at 16:40 +1000, Dave Airlie wrote: > So after much tracing with direct netconsole writes (printks > under console_lock not so useful) I always use earlyprintk on serial.. -- Live Security Virtual Conf

Re: [PATCH 2/2] [RESEND] console: implement lockdep support for console_lock

2012-09-24 Thread Peter Zijlstra
On Mon, 2012-09-24 at 14:17 +0200, Peter Zijlstra wrote: > On Tue, 2012-09-18 at 01:03 +0200, Daniel Vetter wrote: > > - In the printk code there's a special trylock, only used to kick off > > the logbuffer printk'ing in console_unlock. But all that happens > >

Re: [PATCH 2/2] [RESEND] console: implement lockdep support for console_lock

2012-09-24 Thread Peter Zijlstra
On Mon, 2012-09-24 at 14:54 +0200, Daniel Vetter wrote: > I've read through the patches and I'm hoping you don't volunteer me to > pick these up ... ;-) Worth a try, right? :-) > But there doesn't seem to be anything that would > get worse through this lockdep annotation patch, right? No indee

Re: [PATCH 2/2] [RESEND] console: implement lockdep support for console_lock

2012-09-24 Thread Peter Zijlstra
On Tue, 2012-09-18 at 01:03 +0200, Daniel Vetter wrote: > - In the printk code there's a special trylock, only used to kick off > the logbuffer printk'ing in console_unlock. But all that happens > while lockdep is disable (since printk does a few other evil > tricks). So no issue there, eithe

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-02 Thread Peter Zijlstra
On Thu, 2013-02-28 at 11:25 +0100, Maarten Lankhorst wrote: > +struct ticket_mutex { > + struct mutex base; > + atomic_long_t reservation_id; > +}; I'm not sure this is a good name, esp. due to the potential confusion vs the ticket spinlocks we have. _

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-02 Thread Peter Zijlstra
On Thu, 2013-02-28 at 11:25 +0100, Maarten Lankhorst wrote: > +Reservation type mutexes > +struct ticket_mutex { > +extern int __must_check _mutex_reserve_lock(struct ticket_mutex *lock, That's two different names and two different forms of one (for a total of 3 variants) for the same scheme. F

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-02 Thread Peter Zijlstra
On Thu, 2013-02-28 at 11:25 +0100, Maarten Lankhorst wrote: > +The algorithm that TTM came up with for dealing with this problem is > +quite simple. For each group of buffers (execbuf) that need to be > +locked, the caller would be assigned a unique reservation_id, from a > +global counter. In ca

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-02 Thread Peter Zijlstra
On Thu, 2013-02-28 at 11:25 +0100, Maarten Lankhorst wrote: > +mutex_reserve_lock_slow and mutex_reserve_lock_intr_slow: > + Similar to mutex_reserve_lock, except it won't backoff with > -EAGAIN. > + This is useful when mutex_reserve_lock failed with -EAGAIN, and you > + unreserved all reservati

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-02 Thread Peter Zijlstra
On Tue, 2013-04-02 at 16:57 +0200, Maarten Lankhorst wrote: > Hey, > > Thanks for reviewing. Only partway through so far :-) > Op 02-04-13 13:00, Peter Zijlstra schreef: > > On Thu, 2013-02-28 at 11:25 +0100, Maarten Lankhorst wrote: > >> +Reservation type mutexe

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-04 Thread Peter Zijlstra
I'm sorry, this email ended up quite a bit longer than I had hoped for; please bear with me. On Tue, 2013-04-02 at 18:59 +0200, Peter Zijlstra wrote: > struct ww_mutex; /* wound/wait */ > > int mutex_wound_lock(struct ww_mutex *); /* returns -EDEADLK */ > int mutex

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-04 Thread Peter Zijlstra
On Thu, 2013-04-04 at 15:31 +0200, Daniel Vetter wrote: > Hm, I guess your aim with the TASK_DEADLOCK wakeup is to bound the > wait > times of older task. No, imagine the following: struct ww_mutex A, B; struct mutex C; task-O task-Y task-X A B

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-04 Thread Peter Zijlstra
On Thu, 2013-04-04 at 15:31 +0200, Daniel Vetter wrote: > The trick with the current code is that the oldest task > will never see an -EAGAIN ever and hence is guaranteed to make forward > progress. If the task is really unlucky though it might be forced to > wait > for a younger task for every ww_

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-04 Thread Peter Zijlstra
On Thu, 2013-04-04 at 15:31 +0200, Daniel Vetter wrote: > The thing is now that you're not expected to hold these locks for a > long > time - if you need to synchronously stall while holding a lock > performance > will go down the gutters anyway. And since most current > gpus/co-processors > still

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-04 Thread Peter Zijlstra
On Thu, 2013-04-04 at 15:31 +0200, Daniel Vetter wrote: > Another big reason for having a start/end marker like you've describe > is > lockdep support. Yeah, I saw how you did that.. but there's other ways of making it work too, you could for instance create a new validation state for this type of

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-04 Thread Peter Zijlstra
On Thu, 2013-04-04 at 15:31 +0200, Daniel Vetter wrote: > I'm a bit confused about the different classes you're talking about. > Since > the ticket queue is currently a global counter there's only one class > of > ww_mutexes. Right, so that's not something that's going to fly.. we need to support

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-04 Thread Peter Zijlstra
On Thu, 2013-04-04 at 15:31 +0200, Daniel Vetter wrote: > We've discussed this approach of using (rt-prio, age) instead of just > age > to determine the the "oldness" of a task for deadlock-breaking with > -EAGAIN. The problem is that through PI boosting or normal rt-prio > changes > while tasks ar

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-04 Thread Peter Zijlstra
On Thu, 2013-04-04 at 15:31 +0200, Daniel Vetter wrote: > Well, it was a good read and I'm rather happy that we agree on the > ww_ctx > thing (whatever it's called in the end), even though we have slightly > different reasons for it. Yeah, I tried various weirdness to get out from under it, but th

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-04 Thread Peter Zijlstra
On Thu, 2013-04-04 at 15:31 +0200, Daniel Vetter wrote: > We do add some form of owner tracking by storing the reservation > ticket > of the current holder into every ww_mutex. So when task-Y in your > above > example tries to acquire lock A it notices that it's behind in the > global > queue and i

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-08 Thread Peter Zijlstra
On Thu, 2013-04-04 at 18:56 +0200, Daniel Vetter wrote: > On Thu, Apr 4, 2013 at 3:31 PM, Daniel Vetter wrote: > >> In this case when O blocks Y isn't actually blocked, so our > >> TASK_DEADLOCK wakeup doesn't actually achieve anything. > >> > >> This means we also have to track (task) state so th

Re: [PATCH v2 2/3] mutex: add support for reservation style locks, v2

2013-04-10 Thread Peter Zijlstra
On Tue, 2013-04-09 at 18:42 -0400, Steven Rostedt wrote: > What about setting an age as soon as it starts the process > of grabbing one of these locks? And it keeps the age until it > successfully grabs and releases all the locks again. It wont reset if > it > had to drop the locks and start over.

Re: [PATCH v3 2/3] mutex: add support for wound/wait style locks, v3

2013-05-22 Thread Peter Zijlstra
> Are there any issues left? I included the patch you wrote for injecting > -EDEADLK too > in my tree. The overwhelming silence makes me think there are either none, or > nobody cared enough to review it. :( It didn't manage to reach my inbox it seems,.. I can only find a debug patch in this thre

Re: [PATCH v3 2/3] mutex: add support for wound/wait style locks, v3

2013-05-22 Thread Peter Zijlstra
On Wed, May 22, 2013 at 01:47:42PM +0200, Maarten Lankhorst wrote: > Op 22-05-13 13:37, Peter Zijlstra schreef: > >> Are there any issues left? I included the patch you wrote for injecting > >> -EDEADLK too > >> in my tree. The overwhelming silence makes me think t

Re: [PATCH v3 2/3] mutex: add support for wound/wait style locks, v3

2013-05-22 Thread Peter Zijlstra
On Wed, May 22, 2013 at 01:18:14PM +0200, Maarten Lankhorst wrote: Lacking the actual msg atm, I'm going to paste in here... > Subject: [PATCH v3 2/3] mutex: add support for wound/wait style locks, v3 > From: Maarten Lankhorst > > Changes since RFC patch v1: > - Updated to use atomic_l

Re: [PATCH v3 2/3] mutex: add support for wound/wait style locks, v3

2013-05-27 Thread Peter Zijlstra
On Wed, May 22, 2013 at 07:24:38PM +0200, Maarten Lankhorst wrote: > >> +- Functions to only acquire a single w/w mutex, which results in the > >> exact same > >> + semantics as a normal mutex. These functions have the _single postfix. > > This is missing rationale. > trylock_single is useful wh

Re: [PATCH v3 2/3] mutex: add support for wound/wait style locks, v3

2013-05-27 Thread Peter Zijlstra
On Wed, May 22, 2013 at 07:24:38PM +0200, Maarten Lankhorst wrote: > >> +static inline void ww_acquire_init(struct ww_acquire_ctx *ctx, > >> + struct ww_class *ww_class) > >> +{ > >> + ctx->task = current; > >> + do { > >> + ctx->stamp = atomic_long_inc_return

Re: [PATCH v3 2/3] mutex: add support for wound/wait style locks, v3

2013-05-27 Thread Peter Zijlstra
On Wed, May 22, 2013 at 06:49:04PM +0200, Daniel Vetter wrote: > - _slow functions can check whether all acquire locks have been > released and whether the caller is indeed blocking on the contending > lock. Not doing so could either result in needless spinning instead of > blocking (when blocking

Re: [PATCH v3 2/3] mutex: add support for wound/wait style locks, v3

2013-05-27 Thread Peter Zijlstra
On Mon, May 27, 2013 at 10:26:39AM +0200, Maarten Lankhorst wrote: > Op 27-05-13 10:00, Peter Zijlstra schreef: > > On Wed, May 22, 2013 at 07:24:38PM +0200, Maarten Lankhorst wrote: > >>>> +- Functions to only acquire a single w/w mutex, which results in the > >>

Re: [PATCH v3 2/3] mutex: add support for wound/wait style locks, v3

2013-05-27 Thread Peter Zijlstra
On Mon, May 27, 2013 at 12:01:50PM +0200, Maarten Lankhorst wrote: > > Again, early.. monday.. would a trylock, even if successful still need > > the ctx? > No ctx for trylock is supported. You can still do a trylock while > holding a context, but the mutex won't be a part of the context. > Normal

<    1   2   3   >