From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 414A5C56202 for ; Fri, 20 Nov 2020 22:01:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8CD022464 for ; Fri, 20 Nov 2020 22:01:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728430AbgKTWBl (ORCPT ); Fri, 20 Nov 2020 17:01:41 -0500 Received: from mx2.suse.de ([195.135.220.15]:43510 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727417AbgKTWBk (ORCPT ); Fri, 20 Nov 2020 17:01:40 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8CD39AC23; Fri, 20 Nov 2020 22:01:39 +0000 (UTC) Date: Fri, 20 Nov 2020 13:38:28 -0800 From: Davidlohr Bueso To: David Laight Cc: 'Waiman Long' , Peter Zijlstra , Ingo Molnar , Will Deacon , "linux-kernel@vger.kernel.org" , Phil Auld Subject: Re: [RFC PATCH 5/5] locking/rwsem: Remove reader optimistic spinning Message-ID: <20201120213828.n7f23qy75hduommo@linux-p48b.lan> References: <20201118030429.23017-1-longman@redhat.com> <20201118030429.23017-6-longman@redhat.com> <20201118053556.3fmmtat7upv6dtvd@linux-p48b.lan> <5fe76531782f4a8492b341d5f381147b@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <5fe76531782f4a8492b341d5f381147b@AcuMS.aculab.com> User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 20 Nov 2020, David Laight wrote: >I got massive performance improvements from changing a driver >we have to use mutex instead of the old semaphores (the driver >was written a long time ago). > >While these weren't 'rw' the same issue will apply. > >The problem was that the semaphore/mutex was typically only held over >a few instructions (eg to add an item to a list). >But with semaphore if you got contention the process always slept. >OTOH mutex spin 'for a while' before sleeping so the code rarely slept. The caveat here is if you are using trylock/unlock from irq, which is the only reason why regular semaphores are still around today. If not, indeed a mutex is better. Thanks, Davidlohr