Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp42148rdb; Wed, 1 Nov 2023 16:19:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlrX+up4nM/9VROFTWi98VDhXjirTB3U/plbwfuDICnnAQNUjYXQmTVDX2ZK7YhW1Q3FLT X-Received: by 2002:a05:6870:525:b0:1e9:db04:eb51 with SMTP id j37-20020a056870052500b001e9db04eb51mr22341934oao.39.1698880747851; Wed, 01 Nov 2023 16:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698880747; cv=none; d=google.com; s=arc-20160816; b=uIk1tsgFRqH+E6e7pBCXGjhdgx3xQ2IHaqwTlJbhjdmN+U0aDBvJC6uo8BtjlrlOo4 Y2OCOpuuPA4XGqjg4fbbOuYkPlJ5v8lVtOzoRFWPJJdWxAwmU+3rQ6WGwAy98PhWgBKK lTdClSmjwh89SF5ndrtDo62lQYK5dapWv/yy3C2Eos8rFu9pl2euvstlII5cEbOUREJL ClQWYfz9jNK9t5ndl/zpAq6kWOtyceN8Fe6m+dqL4wXE/0dOMpcQRiKkB3HBHRnuQ6Ns ryurYvF9mQRsLA5CYqk/6AK9OGdNsH2aRV4608G3bEycG34lOvOsC9pHAshuO0yuymdh uT8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=K5Z5/0jEKUR78SsGzTEQP0lgV6IDugZghhgxYociaAs=; fh=vJpCe3V0BxrjcHtx4IsKHjIddWG8fJWgy7sVwWOeVbw=; b=La3QoHBAklJ4ql0NkJXYbEWjU42X8DqbCEKgz5vzxXcynPfX7C3L+b4AeK3kgqRxPs Nz9uV/UaB9wCyxHtdHIO/5ybnrA9t62dtXUNtpcXYD2ULcFh9/9ST222Fppontvx+DVu wYvUshkU5YxDrJomKMHFGcX+A4BnMhuHfrAcLFJnZax42mmKU3nFOgE+Pmw9HDuQmOBz OItzd8lxPhonIs1M0Pza+b2mYZpju7fc9XVXLNCYA+hYziHgutlwMe9DQIywDogrwqpd thMrLNm0siyN8Q7BY4M7DpyYukzQKz7JiOKDku1WbuuvmwiMNK0ZYaag1rJ8i6V16bqN MG6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FQY6aLGD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id s67-20020a637746000000b005b87be63da6si840194pgc.488.2023.11.01.16.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 16:19:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FQY6aLGD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 35453802269D; Wed, 1 Nov 2023 16:19:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346218AbjKAXS4 (ORCPT + 99 others); Wed, 1 Nov 2023 19:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232447AbjKAXSz (ORCPT ); Wed, 1 Nov 2023 19:18:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D14A5A6 for ; Wed, 1 Nov 2023 16:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698880689; 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=K5Z5/0jEKUR78SsGzTEQP0lgV6IDugZghhgxYociaAs=; b=FQY6aLGDDR2yPwztk1aQ9xHKRAluSd4ZvqqoxjD12A6zcb+7CUV0OBkzBxfnzTVnURzOxk zsccJ7uG+PBNA481cxFLVDuyx4qTbELoZVgN4hx04WIxV2OJjSJ8FnCOl4TpGfRdf6ZUxh FxMJ64X4qDXGTL3qs7Xh17dIQ8YKpHI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-99-eNuOVGxUOSWptyh3OQndMQ-1; Wed, 01 Nov 2023 19:18:07 -0400 X-MC-Unique: eNuOVGxUOSWptyh3OQndMQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3C494381AE47; Wed, 1 Nov 2023 23:18:07 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.94]) by smtp.corp.redhat.com (Postfix) with SMTP id 8A4F62026D4C; Wed, 1 Nov 2023 23:18:04 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 2 Nov 2023 00:17:05 +0100 (CET) Date: Thu, 2 Nov 2023 00:17:02 +0100 From: Oleg Nesterov To: Al Viro Cc: David Howells , Marc Dionne , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Chuck Lever , linux-afs@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rxrpc_find_service_conn_rcu: use read_seqbegin() rather than read_seqbegin_or_lock() Message-ID: <20231101231701.GH32034@redhat.com> References: <20231027095842.GA30868@redhat.com> <1952182.1698853516@warthog.procyon.org.uk> <20231101202302.GB32034@redhat.com> <20231101205238.GI1957730@ZenIV> <20231101215214.GD32034@redhat.com> <20231101224855.GJ1957730@ZenIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231101224855.GJ1957730@ZenIV> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Wed, 01 Nov 2023 16:19:03 -0700 (PDT) On 11/01, Al Viro wrote: > > On Wed, Nov 01, 2023 at 10:52:15PM +0100, Oleg Nesterov wrote: > > > > Why would you want to force that "switch to locked on the second pass" policy > > > on every possible caller? > > > > Because this is what (I think) read_seqbegin_or_lock() is supposed to do. > > It should take the lock for writing if the lockless access failed. At least > > according to the documentation. > > Not really - it's literally seqbegin or lock, depending upon what the caller > tells it... OK, I won't argue right now. But again, this patch doesn't change the current behaviour. Exactly because the caller does NOT tell read_seqbegin_or_lock() that it wants "or lock" on the 2nd pass. > Take a look at d_walk() and try to shoehorn that into your variant. Especially > the D_WALK_NORETRY handling... I am already sleeping, quite possibly I am wrong. But it seems that if we change done_seqretry() then d_walk() needs something like --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1420,7 +1420,7 @@ static void d_walk(struct dentry *parent, void *data, spin_lock(&this_parent->d_lock); /* might go back up the wrong parent if we have had a rename. */ - if (need_seqretry(&rename_lock, seq)) + if (need_seqretry(&rename_lock, &seq)) goto rename_retry; /* go into the first sibling still alive */ do { @@ -1432,22 +1432,20 @@ static void d_walk(struct dentry *parent, void *data, rcu_read_unlock(); goto resume; } - if (need_seqretry(&rename_lock, seq)) + if (need_seqretry(&rename_lock, &seq)) goto rename_retry; rcu_read_unlock(); out_unlock: spin_unlock(&this_parent->d_lock); - done_seqretry(&rename_lock, seq); + done_seqretry(&rename_lock, &seq); return; rename_retry: spin_unlock(&this_parent->d_lock); rcu_read_unlock(); - BUG_ON(seq & 1); if (!retry) return; - seq = 1; goto again; } But again, again, this is off-topic and needs another discussion. Right now I am just trying to audit the users of read_seqbegin_or_lock/need_seqretry and change those who use them incorrectly. Oleg.