From patchwork Fri Dec 23 12:00:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 36221 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp280693wrn; Fri, 23 Dec 2022 04:04:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXtadZ665H9ebnkCv1td/Z33naUvsGLRwl+2WTnBfogElkn0oNFOlbCAir+Wpo+50Wrzy4+K X-Received: by 2002:a62:7bc4:0:b0:576:8027:a2fc with SMTP id w187-20020a627bc4000000b005768027a2fcmr10765289pfc.12.1671797076045; Fri, 23 Dec 2022 04:04:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671797076; cv=none; d=google.com; s=arc-20160816; b=MsBEjrYWQhUdR5bq1ohVeg3TyLjmDBknA6WWG51x9u4r2g5M7A+GiAang+p2tYx7Tp v1J1L4JLdqXX6ZM0xwJ1NUoypJYjy7Mgcs6d4A0X2ZhgKeULZM+1W4fV6qajiCsXzcFn +2uaVG5DPKqtTV48H4T6iBcD8+smaTLWzmtT21HkmP9oZek+C5URo/6X9vQffRQfavOX ZJWVERz8EkF+FNMRwA6z1eTS459pXlScRYrUSG1RUyZ6Q9VXgIZoYjNuDeheohdhuW7U QY3LvnxZusPofhaHALqXs0pfhWysSG1dT/y/re9+N0UUGkOV1ytHkHKrgqEYw6zQManT k5Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=IBvIYEhqC61vkE5nifbl8b7iyDDJW0GAVBa85A8kwRA=; b=qUjZ2UBoJ2sx2bWshEiBcX1dxcZFRGK/sDTKaH8NTakuXyAZzNYSxZpBp1PHPlKq1o 0E6m35uzcnWC8xHQAD6xDkK8JSbQmJ/8xvs7dJCWKUq/BtGKmu1fZMTUo3i34leUDMcr /VaoZnc7do797UtF2SJJVA2Ee+GjTxv/rvK5DC6buwDkAzVoJdNt6nzWIOR2DP8iq/K0 ddm3FqhilIs0OPHZDwJw5TwEswRQc12WLxjW1lWR9EiXAnG1Ht2fsXh5Iq69vsLVvZnn QLZ/WCHPu8u/DOVSpTzpHVvkOd6pdCEDx9kZHqv89ZAFvvPEBZEdl07lnBvLI/ruYfTN fgxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UMVjG91+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k13-20020a056a00134d00b005808bb470a0si2192963pfu.180.2022.12.23.04.04.09; Fri, 23 Dec 2022 04:04:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UMVjG91+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236282AbiLWMDW (ORCPT + 99 others); Fri, 23 Dec 2022 07:03:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236145AbiLWMCF (ORCPT ); Fri, 23 Dec 2022 07:02: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 2675CB56 for ; Fri, 23 Dec 2022 04:00:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671796844; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IBvIYEhqC61vkE5nifbl8b7iyDDJW0GAVBa85A8kwRA=; b=UMVjG91+Ylr7xvkotCOSJ4MRa7xYu9Ie2ZvZs4tC6Y4xZTb83KH1X73iD+JBzGIuIXZM8E GQGgpwxYQnvLeGqLIyOU9YNfAkf+BDrMQoHfChoKIS3MkmbGqvwUPjcutQv83QjIBU0MM8 wKr06oyJZGyI5s/P0ckt3oJGwWi09o4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-TWDXdZkKPeK0AUiXpW3twA-1; Fri, 23 Dec 2022 07:00:41 -0500 X-MC-Unique: TWDXdZkKPeK0AUiXpW3twA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CDEEF3C0F688; Fri, 23 Dec 2022 12:00:39 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.96]) by smtp.corp.redhat.com (Postfix) with ESMTP id 200E62166B33; Fri, 23 Dec 2022 12:00:39 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH net-next 06/19] rxrpc: Only disconnect calls in the I/O thread From: David Howells To: netdev@vger.kernel.org Cc: Marc Dionne , linux-afs@lists.infradead.org, dhowells@redhat.com, linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Date: Fri, 23 Dec 2022 12:00:38 +0000 Message-ID: <167179683853.2516210.903291442538570624.stgit@warthog.procyon.org.uk> In-Reply-To: <167179679960.2516210.10739247907156079872.stgit@warthog.procyon.org.uk> References: <167179679960.2516210.10739247907156079872.stgit@warthog.procyon.org.uk> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753006291132937129?= X-GMAIL-MSGID: =?utf-8?q?1753006291132937129?= Only perform call disconnection in the I/O thread to reduce the locking requirement. Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- include/trace/events/rxrpc.h | 1 + net/rxrpc/call_event.c | 14 +++++++++++++- net/rxrpc/call_object.c | 9 +-------- net/rxrpc/input.c | 6 ------ net/rxrpc/recvmsg.c | 1 + 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/trace/events/rxrpc.h b/include/trace/events/rxrpc.h index c44cc01de750..eac513668e33 100644 --- a/include/trace/events/rxrpc.h +++ b/include/trace/events/rxrpc.h @@ -18,6 +18,7 @@ */ #define rxrpc_call_poke_traces \ EM(rxrpc_call_poke_abort, "Abort") \ + EM(rxrpc_call_poke_complete, "Compl") \ EM(rxrpc_call_poke_error, "Error") \ EM(rxrpc_call_poke_idle, "Idle") \ EM(rxrpc_call_poke_start, "Start") \ diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c index a8b5dff09999..bf6858e69187 100644 --- a/net/rxrpc/call_event.c +++ b/net/rxrpc/call_event.c @@ -347,6 +347,13 @@ void rxrpc_input_call_event(struct rxrpc_call *call, struct sk_buff *skb) if (call->state == RXRPC_CALL_COMPLETE) goto out; + if (!call->conn) { + printk("\n"); + printk("\n"); + kdebug("no conn %u", call->state); + printk("\n"); + } + abort_code = smp_load_acquire(&call->send_abort); if (abort_code) rxrpc_abort_call(call->send_abort_why, call, 0, call->send_abort, @@ -479,8 +486,13 @@ void rxrpc_input_call_event(struct rxrpc_call *call, struct sk_buff *skb) } out: - if (call->state == RXRPC_CALL_COMPLETE) + if (call->state == RXRPC_CALL_COMPLETE) { del_timer_sync(&call->timer); + if (!test_bit(RXRPC_CALL_DISCONNECTED, &call->flags)) + rxrpc_disconnect_call(call); + if (call->security) + call->security->free_call_crypto(call); + } if (call->acks_hard_ack != call->tx_bottom) rxrpc_shrink_call_tx_buffer(call); _leave(""); diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c index 8d3d2e058827..3db85d09c4b4 100644 --- a/net/rxrpc/call_object.c +++ b/net/rxrpc/call_object.c @@ -50,7 +50,7 @@ void rxrpc_poke_call(struct rxrpc_call *call, enum rxrpc_call_poke_trace what) struct rxrpc_local *local = call->local; bool busy; - if (call->state < RXRPC_CALL_COMPLETE) { + if (!test_bit(RXRPC_CALL_DISCONNECTED, &call->flags)) { spin_lock_bh(&local->lock); busy = !list_empty(&call->attend_link); trace_rxrpc_poke_call(call, busy, what); @@ -531,13 +531,10 @@ void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call) trace_rxrpc_call(call->debug_id, refcount_read(&call->ref), call->flags, rxrpc_call_see_release); - ASSERTCMP(call->state, ==, RXRPC_CALL_COMPLETE); - if (test_and_set_bit(RXRPC_CALL_RELEASED, &call->flags)) BUG(); rxrpc_put_call_slot(call); - del_timer_sync(&call->timer); /* Make sure we don't get any more notifications */ write_lock(&rx->recvmsg_lock); @@ -570,10 +567,6 @@ void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call) _debug("RELEASE CALL %p (%d CONN %p)", call, call->debug_id, conn); - if (conn && !test_bit(RXRPC_CALL_DISCONNECTED, &call->flags)) - rxrpc_disconnect_call(call); - if (call->security) - call->security->free_call_crypto(call); _leave(""); } diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c index 1f03a286620d..bb4beb445325 100644 --- a/net/rxrpc/input.c +++ b/net/rxrpc/input.c @@ -997,8 +997,6 @@ void rxrpc_input_call_packet(struct rxrpc_call *call, struct sk_buff *skb) */ void rxrpc_implicit_end_call(struct rxrpc_call *call, struct sk_buff *skb) { - struct rxrpc_connection *conn = call->conn; - switch (READ_ONCE(call->state)) { case RXRPC_CALL_SERVER_AWAIT_ACK: rxrpc_call_completed(call); @@ -1012,8 +1010,4 @@ void rxrpc_implicit_end_call(struct rxrpc_call *call, struct sk_buff *skb) } rxrpc_input_call_event(call, skb); - - spin_lock(&conn->bundle->channel_lock); - __rxrpc_disconnect_call(conn, call); - spin_unlock(&conn->bundle->channel_lock); } diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c index 3d6ba7e464b4..2b68ac990ed4 100644 --- a/net/rxrpc/recvmsg.c +++ b/net/rxrpc/recvmsg.c @@ -201,6 +201,7 @@ static void rxrpc_end_rx_phase(struct rxrpc_call *call, rxrpc_serial_t serial) case RXRPC_CALL_CLIENT_RECV_REPLY: __rxrpc_call_completed(call); write_unlock(&call->state_lock); + rxrpc_poke_call(call, rxrpc_call_poke_complete); break; case RXRPC_CALL_SERVER_RECV_REQUEST: