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

2018-02-22 Thread Maarten Lankhorst
Op 21-02-18 om 00:56 schreef Daniel Vetter: > On Tue, Feb 20, 2018 at 04:21:58PM +0100, Peter Zijlstra wrote: >> 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:

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

2018-02-21 Thread Emil Velikov
On 20 February 2018 at 13:12, Peter Zijlstra wrote: > 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

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

2018-02-21 Thread Christian König
Am 21.02.2018 um 11:54 schrieb Maarten Lankhorst: Op 21-02-18 om 00:56 schreef Daniel Vetter: On Tue, Feb 20, 2018 at 04:21:58PM +0100, Peter Zijlstra wrote: 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

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

2018-02-20 Thread Daniel Vetter
On Tue, Feb 20, 2018 at 04:21:58PM +0100, Peter Zijlstra wrote: > 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

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 > > > > there for completeness

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

2018-02-20 Thread Christian König
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 there for completeness sake? Unfortunately not. TTM uses trylock to lock BOs which are about to be evicted to

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

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

2018-02-20 Thread Christian König
Am 20.02.2018 um 14:57 schrieb 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

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

2018-02-20 Thread Daniel Vetter
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

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); > > > +

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

2018-02-20 Thread Christian König
Am 20.02.2018 um 14:12 schrieb 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.

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