Re: [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait

2016-11-21 Thread Arnd Bergmann
On Monday, November 21, 2016 9:57:51 AM CET Linus Torvalds wrote: > > - semaphores are "old-fashioned mutexes". A mutex is better than a > semaphore, but a semaphore is better than just about all the other > alternatives. There's nothing _wrong_ with using a semaphore per se. > > In this case, e

Re: [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait

2016-11-21 Thread Linus Torvalds
On Mon, Nov 21, 2016 at 8:52 AM, Arnd Bergmann wrote: > > Version of the series had replaced the semaphore with a completion > here, which worked correctly, but one reviewer suggested using > the wait_event() instead since it's confusing to have a completion > starting out in 'completed' state. Q

Re: [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait

2016-11-21 Thread Christoph Hellwig
On Mon, Nov 21, 2016 at 05:52:27PM +0100, Arnd Bergmann wrote: > I think a mutex would't work here, since fops->open() and fops->close() > are not called from the same context and lockdep will complain > about that. > > Version of the series had replaced the semaphore with a completion > here, whi

Re: [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait

2016-11-21 Thread Arnd Bergmann
On Monday, November 21, 2016 7:57:53 AM CET Linus Torvalds wrote: > Don't do this. > > Never ever do your own locking primitives. You will get the memory ordering > wrong. And even if you get it right, why do it? > > If you want to get rid of semaphores, and replace them with a mutex, that's > OK

[PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait

2016-11-20 Thread Binoy Jayan
The semaphore 'sm_sem' is used for an exclusive ownership of the device so model the same as an atomic variable with an associated wait_event. Semaphores are going away in the future. Signed-off-by: Binoy Jayan --- drivers/infiniband/core/user_mad.c | 20 ++-- 1 file changed, 14