From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Subject: Re: [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait Date: Mon, 21 Nov 2016 17:52:27 +0100 Message-ID: <4374986.OFD8bCgUa1@wuerfel> References: <1479708496-9828-1-git-send-email-binoy.jayan@linaro.org> <1479708496-9828-3-git-send-email-binoy.jayan@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Linus Torvalds Cc: Binoy Jayan , linux-rdma@vger.kernel.org, Mustafa Ismail , Lijun Ou , Nicholas Bellinger , Leon Romanovsky , target-devel@vger.kernel.org, Tatyana E Nikolova , Doug Ledford , Jenny Derzhavetz , Sagi Grimberg , Sean Hefty , Faisal Latif , Hal Rosenstock , linux-kernel@vger.kernel.org, "Wei Hu(Xavier)" , Mark Brown , Mark Bloch , Steve Wise , Ira Weiny List-Id: linux-rdma@vger.kernel.org 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. But don't replace them with something more complex like an open coded > waiting model. 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, 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. Arnd