Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1038287rdh; Fri, 27 Oct 2023 03:01:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0HQlplaNS9+mbr9QZTddKA2Qkbt+u8sMZMUIIjrEmbtdklOD4t43wrq2ySRv01i+z0am8 X-Received: by 2002:a05:6830:25c1:b0:6bc:f6d0:87d9 with SMTP id d1-20020a05683025c100b006bcf6d087d9mr2437474otu.5.1698400872072; Fri, 27 Oct 2023 03:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698400872; cv=none; d=google.com; s=arc-20160816; b=FTI/PEob4gp/4Nkt8ClK1AaQP2Mre5sn1I4RL/YnP4ZBbS0X6Qdsr5mQ95lyqqNgGF iP1Xf1LP4dLeL7152y1x3y8DY+xFcNXwP+XnyCwqm+RSJOX2QX3fW+bHvqyMJ62klARC TS//4fpr+yjqXm7mmCgBgfdRj+h5gf2aJfwhhD3oevWR7IBsOqvhe7Y3YIEqH8TjQBpe W60SMHUxVOIJabUXy1FVZLhd5URpBtOmLixpkyA4K6PXw+FDKo+LgDV7XCwkLqA11CIb Ak0gRPshS0f87pbCjI/lEw32TWkHFEuH6u/2P5APx3oNtC8w7h1cfQizGN4Iw1fC3En2 PczQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=TZ0xtpqTEhLFnw9/Pr4Oy+UYb54uDvsk+Fp9NNzZ9YA=; fh=THy7m3uwk7yj9RKwR9/IQMoJWgHHuuAHi4Fgt2a464U=; b=xld/Ha9JuNP4z1jKc+IDe0SaWCY/tvY3geps34ExmWD3+cw/iNRQyaqMb+1Dm98Vgf Wgr5/k4+EU+gHcVv7ZJnjXd1yuGOGtoKyIHg98tlOucaH8hbHdAQBlfPr5RqL9YVDj1H ikHEXBpMa5hOwIs6+45ylSof426xVuT9BzNblkR67pxQTqDQgA8M/ls+wMv67kG4Mods cbb16jGpRCNIv9IqlsNC8lPpdtkm5r1izh6H6qqv/V4unLOB4+17/Fn92ZiqmaY1Z6xf EjV5FXliCB1XofNbtfROVZZUNVjjcOk7MT9XNYPC8ZH21jegPypYu1JJzQBMav8TyDL6 eGuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NwEs+7qN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id u198-20020a0debcf000000b005a7a8377e1asi1983727ywe.115.2023.10.27.03.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 03:01:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NwEs+7qN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 0458F830F541; Fri, 27 Oct 2023 03:01:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235075AbjJ0KAl (ORCPT + 99 others); Fri, 27 Oct 2023 06:00:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234978AbjJ0KAj (ORCPT ); Fri, 27 Oct 2023 06:00:39 -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 CC4A91B9 for ; Fri, 27 Oct 2023 02:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698400791; 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; bh=TZ0xtpqTEhLFnw9/Pr4Oy+UYb54uDvsk+Fp9NNzZ9YA=; b=NwEs+7qNj/l57lPvn1GVV7achjLaDCjckO/GvWCPzVFHDwPxPZ7yptC2ZS3vKY8AV7XgVn vWKiqBSeUPGIkP3M76pMtz8FqIPN+0wnOnjc7XMZlEWbxIIMOJM+/zfu/n9zJyIvEBxBUL w9sSvQqbqjfENP9EVfuLeyHBXagET+0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-a1feGKiGP7Gl7wRQ1yLo5w-1; Fri, 27 Oct 2023 05:59:46 -0400 X-MC-Unique: a1feGKiGP7Gl7wRQ1yLo5w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 46FD08966A6; Fri, 27 Oct 2023 09:59:46 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.76]) by smtp.corp.redhat.com (Postfix) with SMTP id C5C1F1121319; Fri, 27 Oct 2023 09:59:43 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 27 Oct 2023 11:58:45 +0200 (CEST) Date: Fri, 27 Oct 2023 11:58:42 +0200 From: Oleg Nesterov To: David Howells , Marc Dionne , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Chuck Lever , linux-afs@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rxrpc_find_service_conn_rcu: use read_seqbegin() rather than read_seqbegin_or_lock() Message-ID: <20231027095842.GA30868@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Spam-Status: No, score=-0.9 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Fri, 27 Oct 2023 03:01:09 -0700 (PDT) read_seqbegin_or_lock() makes no sense unless you make "seq" odd after the lockless access failed. See thread_group_cputime() as an example, note that it does nextseq = 1 for the 2nd round. So this code can use read_seqbegin() without changing the current behaviour. Signed-off-by: Oleg Nesterov --- net/rxrpc/conn_service.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/rxrpc/conn_service.c b/net/rxrpc/conn_service.c index 89ac05a711a4..bfafe58681d9 100644 --- a/net/rxrpc/conn_service.c +++ b/net/rxrpc/conn_service.c @@ -25,7 +25,7 @@ struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *peer, struct rxrpc_conn_proto k; struct rxrpc_skb_priv *sp = rxrpc_skb(skb); struct rb_node *p; - unsigned int seq = 0; + unsigned int seq; k.epoch = sp->hdr.epoch; k.cid = sp->hdr.cid & RXRPC_CIDMASK; @@ -35,7 +35,7 @@ struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *peer, * under just the RCU read lock, so we have to check for * changes. */ - read_seqbegin_or_lock(&peer->service_conn_lock, &seq); + seq = read_seqbegin(&peer->service_conn_lock); p = rcu_dereference_raw(peer->service_conns.rb_node); while (p) { @@ -49,9 +49,8 @@ struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *peer, break; conn = NULL; } - } while (need_seqretry(&peer->service_conn_lock, seq)); + } while (read_seqretry(&peer->service_conn_lock, seq)); - done_seqretry(&peer->service_conn_lock, seq); _leave(" = %d", conn ? conn->debug_id : -1); return conn; } -- 2.25.1.362.g51ebf55