Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3269873rdb; Thu, 16 Nov 2023 05:20:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGWMQfOqLgP0OGIYuI4MuWjzV5YMMEaC6cisj3rBoBJ8xwUDB1gAkwew447KSQB5R3RHAV X-Received: by 2002:a05:6a21:a5aa:b0:187:c2be:77f4 with SMTP id gd42-20020a056a21a5aa00b00187c2be77f4mr1456496pzc.44.1700140812189; Thu, 16 Nov 2023 05:20:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700140812; cv=none; d=google.com; s=arc-20160816; b=kbgD8liEWloEkAlo3wu0jHRfKZ88w1XEkpcRN8vg/vxYBiOeIRNa6Tba87SZB4ggY7 a0BmuU2+HVwkLmz8mR4jXBhv6m7cYnp+dEEa51M0Dsz66Wx0XYUCYMZaMEFQI621idYU ws6DyLFf3A9LRnfeNGedUxqBjRRfljWZ9F4asA4uRsdb+uIXs2YPLDSWdgUbpkbhGrYE Ue38czQZ00W524IwnXaxJ2Yia27ya8t+eSwlLw2glJf20pXHqudDYDnQ5lyrqyKo2F/w tC4CIPgaVjTEtvfQ5qaFokEHlin+tg8CSGrMUviprlGPTi0UZxgUwCzrERH7LVhfk5Pw MnwA== 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=GPkDPAa9DjBPZECLFiqpzdyylbq5Vs56hlKHGZVc4Zg=; fh=ZtKhME312CSn54OLABZrOIvtVI5rCFPXBnu5rEkdKJA=; b=NyLlRamirjL1XXon+kt6+Ah6UDXvQU1ab4IY4rbakt9XzpiqIRKfB7pT4TYBQI0FTg fBcPDKZTrNQpnN5Nmo6LiSSEKG9wHUdrGLs7YqhOluqBIU+aWddtEq9wPYnSgTFYXf3H yKuHJQOIpid5bK5zOvw8GTTq2bMQTa5cQn4r0TbAjvlBrssvph3lR8a0V3XdMiISrOka stkmiMyaICpXuLhSZ6CwnXkoOoqmTM5upqTKGPyTbdlJ0z7CWbbEJS0fFA8Y/HLwFb5+ 37w/t+1k0N56kvyclk7hvhuKCnNk7Qd2n1J9d5ufU4pw3Bdfwi/cMXFurjjNZwiVxdl6 Y+jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tmrk87ru; 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=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id w68-20020a636247000000b005bdfda8e04asi371955pgb.733.2023.11.16.05.20.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 05:20:12 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=Tmrk87ru; 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=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B84A881A6E79; Thu, 16 Nov 2023 05:20:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345187AbjKPNUH (ORCPT + 99 others); Thu, 16 Nov 2023 08:20:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbjKPNUF (ORCPT ); Thu, 16 Nov 2023 08:20:05 -0500 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 9828F1A5 for ; Thu, 16 Nov 2023 05:20:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700140801; 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=GPkDPAa9DjBPZECLFiqpzdyylbq5Vs56hlKHGZVc4Zg=; b=Tmrk87ruF11yQKlVjx4W8CyCw5x1v44M04G0Dt6+f2NCY5HQNs9Mf54TvYO5piraup+VQf nm5g1wAc0vjcMByso6MqD7M6SAcmFtc6/buffzTugmZouNVtnmn8maCYs2v5e4r6TPTD2T LH8/C73/WedVuwTuB27fGiPJcXPjO/c= 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-605-7eREEjJ2Md-PE368AY0R1w-1; Thu, 16 Nov 2023 08:19:57 -0500 X-MC-Unique: 7eREEjJ2Md-PE368AY0R1w-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 15356932D2C; Thu, 16 Nov 2023 13:19:57 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.23]) by smtp.corp.redhat.com (Postfix) with SMTP id 629EF1121309; Thu, 16 Nov 2023 13:19:54 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 16 Nov 2023 14:18:53 +0100 (CET) Date: Thu, 16 Nov 2023 14:18:49 +0100 From: Oleg Nesterov To: David Howells , Marc Dionne , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Al Viro Cc: 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: <20231116131849.GA27763@redhat.com> References: <20231027095842.GA30868@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231027095842.GA30868@redhat.com> 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=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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]); Thu, 16 Nov 2023 05:20:10 -0800 (PST) David, Al, So do you agree that - the usage of read_seqbegin_or_lock/need_seqretry in this code makes no sense because read_seqlock_excl() is not possible - this patch doesn't change the current behaviour but simplifies the code and makes it more clear ? On 10/27, Oleg Nesterov wrote: > > 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 >