From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754989AbcKUWwX (ORCPT ); Mon, 21 Nov 2016 17:52:23 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:58095 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753967AbcKUWwV (ORCPT ); Mon, 21 Nov 2016 17:52:21 -0500 From: Arnd Bergmann To: Linus Torvalds Cc: Binoy Jayan , "linux-rdma@vger.kernel.org" , Mustafa Ismail , Lijun Ou , Nicholas Bellinger , Leon Romanovsky , target-devel , Tatyana E Nikolova , Doug Ledford , Jenny Derzhavetz , Sagi Grimberg , Sean Hefty , Faisal Latif , Hal Rosenstock , Linux Kernel Mailing List , "Wei Hu(Xavier)" , Mark Brown , Mark Bloch , Steve Wise , Ira Weiny , Bart Van Assche , Matan Barak , Sagi Grimberg Subject: Re: [PATCH v5 2/9] IB/core: Replace semaphore sm_sem with an atomic wait Date: Mon, 21 Nov 2016 23:51:36 +0100 Message-ID: <2759800.6ytmLjdbJ3@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <1479708496-9828-1-git-send-email-binoy.jayan@linaro.org> <4374986.OFD8bCgUa1@wuerfel> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:3hlGuIagYle51XvsC0JzJXJPUoQMTilLb5TrdAk1IBBuhBEiju0 PjzLDeRO9/DobpdH3QpHcXCETJcPWe8SuPQWxWiIz5Cwn7GrO18qgQZmSLAg0EMA42sTyBN 3J9oPBTc6HvOCUxcB82uk0ORyLvxKxaEIFvaKUB9WZKmfGxzcUBeJvlg1PIfmSUBN+UWTkg 31liVLE7mOW3Q56QnBB/A== X-UI-Out-Filterresults: notjunk:1;V01:K0:sCzw/WzxXU4=:5SnO31jNpFhTnpVb0gAvne DDYy8W/4tCGgHSWAW2YoLeP0CjKe/sXpTSGyXuBx3BkAu3CA4xC2T+SjQoIvhN9JtvHLT6gvJ EPdMALzWKBFUFSiCoGga5e9M/8/7kvpHK71ZqBrYsYXN/6fR4Zx94NRnkk8JoJwy2fwV2zDl8 eif6ojDRgWgi1X2ybb2+w28ZpG4D19NtqXyIr+GGfGGllHmkTyrnnlxMBuZjP9CpIG4kGfx50 RChv5f0//1LYxdtzGdPNkdYASlO6POLBxByU+j2DJ/RaTw61HfX5ax8KFWqll8oJ6Urni1XVA 3e008TkDoYJyy0cHmTtWCBWe1jz174duKsbwq3M0singy1eZupzQHA/U6bHLgai0MDs6K+Qai IvgEU+4wi9MnU3YPRt71FoUzQ1DDLSheDO09p7mqWn1+EmNaWvkXEbR0lYVlN/b5wX59iAvo6 ey+HIPJod9S7TmyGCN7WuxGPBTMCQ1TkLP05zNnlc8C8ThWzVscLVEX20hx3ywEm41c++5dgM huRx4MvkTL2zks5YUD1T/twQbd3oygMculeXx1B5I+Y9Tki5PzeDSTTsGmlxG6YHzB5gZMhAB LOZJyCvRIsdLkfpVt2HWxihf9tZj8nKy74WULqW0xCWpnmX7+fjAJExriZUQk27/MA0er/YQg xCHOY4ylg2qelC5ejQhQ1z9qTeQGNI8blh+o0TcXs/YlXrn51rhbsdDhNhEAaZ+H4Vu1wpnmr bP8xFbkjbvDdO1yH Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, either use a semaphore or a mutex. If you are doing > mutual exclusion, those are really the only two acceptable sleeping > models. The main problem with semaphores is that they are slowly spreading into areas that really should be mutexes or completions. A couple of years ago, we had only around 30 semaphores left in the kernel and while a lot of those have been removed in the meantime, over 100 new ones have come in, the majority of them in the category that can be trivially converted to a mutex or semaphore. This in turn is not much of a problem, except to a certain degree for preempt-rt users. I suggested to Binoy that he could look into replacing the existing semaphores one subsystem at a time under the assumption that we could find a relatively easy alternative for every one of them and then remove the implementation completely. Christoph's suggestion is probably more productive here: let's remove the ones that are obviously wrong or inferior, and only once they have been taken care of we can look into whether it's worth doing something about the rest or not. Arnd