Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp4071906rdg; Wed, 18 Oct 2023 14:12:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHchvljZcPd24tCDpSvyiIYoyKkGM8EiqYmX2FrRV1TIonU+FAVbJB81QycUThrg9Xg5tqn X-Received: by 2002:a05:6300:8001:b0:161:28dd:c09d with SMTP id an1-20020a056300800100b0016128ddc09dmr388512pzc.15.1697663542028; Wed, 18 Oct 2023 14:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697663542; cv=none; d=google.com; s=arc-20160816; b=ZggL38T4BzDt7PwC3srzifu1SUzfZGwV26v9fTEbbes+pdC58y73YjazwmSXC4aXh6 Yu75aTMGBehRr1HuowUwhADZP+8m27gdheNol22uZ4bq4OEK6p3yuZPfxJkYcDcgN35l o3fnmV7yoyO2b9tHmfn4om1+z9OpwkCV5H96Z4MH9aWvuCq8hW3l/4wPEwDwjNpiI9oJ HkCt87Z3pQnxA5loPAthYvNnFxQCO92pCCqmnMV8eZd54Meiw9C4WD1/a86BNcSxW4hP d5ZL6xd/uFDBmTHYxo445CjXPNeT2W8v8RR6BC2EOzpEfVotY8fi960f7tZp4k+Hbzoz KPQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=/1ArYLLOZBAUcL76jk5+IqwZHBWHE65QdqzM7Jwfn30=; fh=VQz7gJ2wmttQX4ZStcjop8hBqMvVoTvje7i23yUOVYc=; b=n6l/S3cb9D+Qoks9Iz0r4dmTrXnVAjFv4C9ezxjU50vucpM9wejyXWztJ9h//N3eCv 0aKugepzi4MhLtYpwn8dfbRiYT1hSTcNqzbJAYnOAX+3cpUD/WAsQ3GV84A2SbMfrp2L IbHlixElMuOOPYOziMe4HL7FOm0hxCMoFHI9/jTpug0zNE4MpOmtt7gBP/bqwEPZGf+y xiY3YQ8ULEqISQaSqbTo5IXkiT4dbv6YHmTyLC6X3sjLOIdFu6tFLs/hY7g4aUR7DwFq wsAy1vlt5Csm1qQPqRRI9mNA4kkjxx1jBasASrYr/+VlBkrtF7HgBm6fbBfA7q+lptoD MZxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=PUZ5sZGn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id p17-20020a639511000000b00573fc6de956si1777798pgd.223.2023.10.18.14.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 14:12:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=PUZ5sZGn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D0AC180FC702; Wed, 18 Oct 2023 14:12:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232513AbjJRVMR (ORCPT + 99 others); Wed, 18 Oct 2023 17:12:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235065AbjJRVME (ORCPT ); Wed, 18 Oct 2023 17:12:04 -0400 Received: from out-199.mta0.migadu.com (out-199.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD6E34699 for ; Wed, 18 Oct 2023 14:05:02 -0700 (PDT) Date: Wed, 18 Oct 2023 17:04:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1697663100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/1ArYLLOZBAUcL76jk5+IqwZHBWHE65QdqzM7Jwfn30=; b=PUZ5sZGnRytk4geioVimacEw2cEuvdXKXjA5NiIVXtas9kSdhr6BFkPxNbVKPSrukOW87F F71gKsf1bZPDpHFT6N0KA2B5Fx+VMtGdZDzbT0nStxQme5LPclO6KxT+fTjoo57XsVndUG Shn/ZsqKI1EPv+jv39uCiZhMgQZ+Iow= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Ingo Molnar Cc: Waiman Long , linux-bcachefs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Boqun Feng , Linus Torvalds , Thomas Gleixner , Stephen Rothwell Subject: Re: [NAK] Re: [PATCH 11/20] locking/osq: Export osq_(lock|unlock) Message-ID: <20231018210456.lgdicnuekvmvcgvm@moria.home.lan> References: <20230712211115.2174650-1-kent.overstreet@linux.dev> <20230712211115.2174650-12-kent.overstreet@linux.dev> <20230802204407.lk5mnj7ua6idddbd@moria.home.lan> <11d39248-31fc-c625-7c06-341f0146bd67@redhat.com> <20230802214211.y3x3swic4jbphmtg@moria.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 18 Oct 2023 14:12:21 -0700 (PDT) On Tue, Oct 10, 2023 at 10:09:38AM +0200, Ingo Molnar wrote: > > Waiman, if you think you can add all the features of six locks to rwsem, > > knock yourself out - but right now this is a vaporware idea for you, not > > something I can seriously entertain. I'm looking to merge bcachefs next > > cycle, not sit around and bikeshed for the next six months. > > That's an entirely inappropriate response to valid review feedback. > > Not having two overlapping locking facilities is not 'bikeshedding' at all ... Well, there was already a long off-list discussion about adding six lock features to rwsem. Basically, it looks to me like a total redesign of rwsem in order to do it correctly, and I don't think that would fly. The rwsem code has separate entrypoints for every lock state, and adding a third lock state would at a minimum add a lot of new - nearly duplicate - code. There's also features and optimizations in six locks that rwsem doesn't have, and it's not clear to me that it would be appropriate to add them to rwsem - each of them would need real discussion. The big ones are: - percpu reader mode, used for locks for interior nodes and subvolume keys in bcachefs - exposing of waitlist entries (and this requires nontrivial guarantees to do correctly!), so that bcachefs can do cycle detection deadlock avoidance on top. In short, this would _not_ be a small project, and I think the saner approach if we really did want to condense down to a single locking implementation would be to replace rwsem with six locks. But before even contemplating that we'd want to see six locks getting wider usage and testing first. Hence why we're at leaving six locks in fs/bcachefs/ for now. > > If you start making a serious effort on adding those features to rwsem > > I'll start walking you through everything six locks has, but right now > > this is a major digression on a patch that just exports two symbols. > > In Linux the burden of work is on people submitting new code, not on > reviewers. The rule is that you should not reinvent the wheel in new > features - extend existing locking facilities please. > > Waiman gave you some pointers as to how to extend rwsems. > > Meanwhile, NAK on the export of osq_(lock|unlock): Perhaps we could get some justification for why you want osq locks to be private? My initial pull request had six locks in kernel/locking/, specifically to keep osq locks private, as requested by locking people (some years back). But since Linus shot that down, I need an alternative. If you're really dead set against exporting osq locks (and again, why?), my only alternative will be to either take optimistic spinning out of six locks, or implement optimistic spinning another way (which is something I was already looking at before; the way lock handoff works in six locks now makes that an attractive idea anyways, but of course the devil is in the details with locking code).