Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4404501imm; Fri, 18 May 2018 04:41:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpruIq7dozLns6r76FpP/ladp/EsErPD4hUScPe3xAYnUzTNAXUS5txC4TZ2ok8FDK6cAXC X-Received: by 2002:a62:5d4a:: with SMTP id r71-v6mr8981031pfb.147.1526643696664; Fri, 18 May 2018 04:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526643696; cv=none; d=google.com; s=arc-20160816; b=u1CjFdufz9+6N+ijmSzRTST2xwUOqbGYGKi7cX3niwP8ufs7oviewxu7RD6Vr9c/jg 8AdVdprT6ihIGDDqFDn1Xk92+eXlbHgX+Un21imj10gDB9F6+qxuUpVdF/ifona/3mcC TI/WYoTKeD7PmA2SonmRuqTdcsF99Zs+0MKci3Wl/MwWgtATKaCsMUptY0sambimHcbn IuHenLMIgS9NW256k9h1e57nBDQL0XjsfF4AWwIxrRocZzqLvZ2osgmBXwB4zvPviOO0 R/01BsvCkAPQfP663wytT9QZYD50fS7oZavlFH0Oq6ICMt+JYp+k7nk5VmdO31eHlAPw Uy9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=74FyZLfaJ0LtW4Kj84F4pg2eThHoOXxrgDOrh0yeMzE=; b=fxA4dIIhpilS3GKClpBfC6ErG65lnlapXpGATleSE67P4mztEpR9FyLFOc0WCGfO2Z iMCrlkYKhA1jFIn0o78eA+RrPjnghVyWvP41Ctsp83KAo+wlpI7ULt9naELR1oxXNcxJ GgLTvHutRjRKY3qMGdspvW76wrIINqhd3+rTr4dHQXMgxeAZFAmXudOi5yVyCJ6w18r0 tasXyyjcwsHiFCChvqlviLcu98rhJNDQpbx/6Sx2xZ/lQYtLuf4AvyQW71fG8gxQluN9 9Hirl5AGo1aB/lRsSvJ/0/rMv9BPTOIZD1YbgflFr93HBeqV4KBM2w9qG0HLX6t57u8D CYVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=K0y0rIid; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f91-v6si7398767plb.510.2018.05.18.04.41.21; Fri, 18 May 2018 04:41:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=K0y0rIid; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752351AbeERLlH (ORCPT + 99 others); Fri, 18 May 2018 07:41:07 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45484 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751413AbeERLlF (ORCPT ); Fri, 18 May 2018 07:41:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=74FyZLfaJ0LtW4Kj84F4pg2eThHoOXxrgDOrh0yeMzE=; b=K0y0rIidNarWnU2k0A1TzKXku cFrScr7A2dvQKc46+2248k7+QWCyY5uWwhzLDZSkNgd/+MZuUg8s14zrwmu/YNfhz+3PlqDBiVlhJ rM8xjNsFqzfyhrFft66XpzhyY4idrVQ79AOmzPKyv0FnEJBYUDjM7WYYipdZ/gedo8K9Ue77IU4w8 o+XQZJuepNR31WRKyhh7cPpMV6kMoy1UT8Bi1QiSqrlrSAZJHaopKK8OvgFEZV4UKPA1782J6scn+ 30qfBBsF/xeTxAMNpJhRnf6CCouyK9VGJIgYWREp7KoNVx7i8Ron++KKFvylO0vx2c2zLYzI/659r Lw//YqdYQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJdkm-0003Ty-Ie; Fri, 18 May 2018 11:40:56 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 95C092029F1C0; Fri, 18 May 2018 13:40:54 +0200 (CEST) Date: Fri, 18 May 2018 13:40:54 +0200 From: Peter Zijlstra To: Kent Overstreet Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Dave Chinner , darrick.wong@oracle.com, tytso@mit.edu, linux-btrfs@vger.kernel.org, clm@fb.com, jbacik@fb.com, viro@zeniv.linux.org.uk, willy@infradead.org Subject: Re: [PATCH 04/10] locking: export osq_lock()/osq_unlock() Message-ID: <20180518114054.GJ12217@hirez.programming.kicks-ass.net> References: <20180518074918.13816-1-kent.overstreet@gmail.com> <20180518074918.13816-9-kent.overstreet@gmail.com> <20180518095204.GF12217@hirez.programming.kicks-ass.net> <20180518101804.GB15403@kmo-pixel> <20180518110808.GH12217@hirez.programming.kicks-ass.net> <20180518113205.GA16943@kmo-pixel> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180518113205.GA16943@kmo-pixel> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 18, 2018 at 07:32:05AM -0400, Kent Overstreet wrote: > It does strike me that the whole optimistic spin algorithm > (mutex_optimistic_spin() and rwsem_optimistic_spin()) are ripe for factoring > out. They've been growing more optimizations I see, and the optimizations mostly > aren't specific to either locks. There's a few unfortunate differences between the two; but yes it would be good if we could reduce some of the duplication found there. One of the distinct differences is that mutex (now) has the lock state and owner in a single atomic word, while rwsem still tracks the owner in a separate word and thus needs to account for 'inconsistent' owner state. And then there's warts such as ww_mutex and rwsem_owner_is_reader and similar.