Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758012AbcJQUIm (ORCPT ); Mon, 17 Oct 2016 16:08:42 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:65377 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758622AbcJQUGg (ORCPT ); Mon, 17 Oct 2016 16:06:36 -0400 From: Arnd Bergmann To: Bart Van Assche Cc: Binoy Jayan , Doug Ledford , Sean Hefty , Hal Rosenstock , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/8] infiniband: Remove semaphores Date: Mon, 17 Oct 2016 22:06:16 +0200 Message-ID: <6244597.a6XMUIxjP0@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <216461f1-3070-c93a-a560-7560a727cb8d@sandisk.com> References: <1476721862-7070-1-git-send-email-binoy.jayan@linaro.org> <216461f1-3070-c93a-a560-7560a727cb8d@sandisk.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:CDMunnKQejYXElUj8uM5yhO5LeogTXVvRJ9MImD7Z4+5EzKzwZc xrlCY8yjg25wJvuzVSpVxAblOM0/mUZ4sXcreQmu7IEOwG32aPhlw54pgYtYpdHgh6qhSLg w48IsgFvMfLMdeHpm07E0dOjcem8yfpqkzsh1B87rKnpEuePw93w5Y1T+om/AHbi5fUE4/m jcVy9XuXyOOBKRFqmLL6w== X-UI-Out-Filterresults: notjunk:1;V01:K0:qBqnDsUnag0=:RVmUDoAlsKe2ru/cfEHZei ivZasvXWjQ51cm17DnRgfusivxKlXK64SfxVCZgbJoFC9EllbP6llQdp55wn9b67k81xOtXeE hMnps6WA8Wn4wZ4O/fYVTOClQ2zsiCFkX3ukzJxjy+kSj/yRmhV2ad6R9OVNymXHlfbj7qwVc IAyEPvn8rRJPC8CgHrxWtTmCvZ766RBHDPaabguaocQ+K79gE3m5RPR/hETspE9Lxv+Y92Q4b a60jjpcpknhiB0ifuKL5pcsQHwL4Vb9cwCB9wbzjYdsvEzSN2YgaShtCpvzXanzNVIAiIF+gQ THyhYE1frHGYSN3LWuB7gknWDk6hsB+w8HSMtkuG0wM4WXfZrPBtvq9ikEjcF+MmUOdbx03kl udeAyVCd3JbT/nOBstC6OGyttZiLiioHH/vDBZ2ak/h/bjbUdGglG/VKVKL9HDTLWEew+KLQj 2fmeCRn2B1Z6R8jdcK/nzdHVNLOj414DzrID6aB+AWuGITX067f/KFsvHijxvwQlsWw7t5Wc1 irRAN40Dm0cTPl26Xj+Q7vDicL5ltg1kMkNR/AlBSoKn6hVVPFoLBSMK076iLXlsv4ATsB1Kr c8G+DeZ5Y316ihARvRwlI4zjqPLCVG11t5bJV88kTkiF1sWAj2FzZFUA+BGY7GxMnDAd5L5uK IRAjFVkq5S4G1Z8HiM34Pf2pdH+HZM4yqN2vyA411MOIzFO7Nj24+NGmWXPffYSUn1mSl5NL9 PogSgS0uZ25l2tFe Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1848 Lines: 44 On Monday, October 17, 2016 9:57:34 AM CEST Bart Van Assche wrote: > On 10/17/2016 09:30 AM, Binoy Jayan wrote: > > These are a set of patches which removes semaphores from infiniband. > > These are part of a bigger effort to eliminate all semaphores from the > > linux kernel. > > Hello Binoy, > > Why do you think it would be a good idea to eliminate all semaphores > from the Linux kernel? I don't know anyone who doesn't consider > semaphores a useful abstraction. There are a several reasons why the semaphores as defined in the kernel are bad and we should get rid of them: - semaphores cannot be analysed using lockdep, since they don't always fit in the simpler 'mutex' semantics - those that are basically mutexes should be converted to mutexes for efficiency and consistency anyway - the semaphores that are not just used as mutexes are typically used as completions and should just be converted to completions for simplicity - when running a preempt-rt kernel, semaphores suffer from priority inversion problems, while mutexes use use priority inheritance as a countermeasure There are very few remaining semaphores in the kernel and generally speaking we'd be better off removing them all so no new users show up in the future. Most of them are trivial to replace with mutexes or completions. For the ones that are not trivially replaced, we have to look at each one and decide what to do about them, there usually is some solution that actually improves the code. Using an open-coded semaphore as a replacement is probably just the last resort that we can consider once we are down to the last handful of users. I haven't looked at drivers/infiniband/ yet for this, but I believe that drivers/acpi/ is a case for which I see no better alternative (the AML bytecode requires counting semaphore semantics). Arnd