Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7150200rwb; Wed, 23 Nov 2022 02:56:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf7TaxXF8bOC2Ofbk4iQH2NyYYzHQ87TYfZCh9oao0LdvTnb4Pljb/zVhU2bykBdneAJdt74 X-Received: by 2002:a05:6402:e04:b0:469:e6ef:9164 with SMTP id h4-20020a0564020e0400b00469e6ef9164mr6717740edh.185.1669201016458; Wed, 23 Nov 2022 02:56:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669201016; cv=none; d=google.com; s=arc-20160816; b=yGNFi1B6UolRrJJSSZ7Xbvz6+bXLORf4604LvxEfvyN32s74/V55lWZUB+qXqashuq YVMW2OW0o6LojF+9LzeGXqtMl50Fg8lIDUgsAFRj2dOc5Xh5Q8kLqCBUewIQv0ul3Rw7 a9HrVYnrncqDH7E5QutmVfYbHk4IMkHpsVt7ZzFQQ7Nf5TtrfCr43qUD7H0GjtCkQpgl +3aPQSe2NdT1ohE+EmS9zLPcSjtl+K6dpBSldJIa7sWV++KeDc4sY+JfSzCtzLPzOV9G YBpbTFQE9Nh9KjM8s0DLT5JvaALGJvAAyjAwVMUsACG9nxyLWUmsFWuSGsKUGY8g4Mj2 DlPQ== 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=/JIc7C6bHMr2yR7PRaYpswtXHVf06FOZdXU09PtPw7c=; b=LuFTrE8S65Gex3XOeGM4qGBOyfvQpQyD7RcYM+SYcaYf3burh9A7JrJPcx7hQOWAas LCufJWHxTcfB0tzBPoa1+S+i13Kzgo6eMo32DrlX13oJZm8VBWHUERf0ryI/jBma+cMQ GpP+dy/wSRBDpW6icM3w55v3HtTwjcvBv70ZddNuWoAZL8VaexEhW+80U11nA/UdLC6m FB614ye0cAKsdK69yPBRpcPdjtNqzs9tLR1fL/2yPtBQnZaljRlJmfWZ3HhtT7Kh1CUe YVi/+8M1mzYbKHcVDP0W2r3VfU65PGmArrzEDh+evpvAt85MAqWZeEW8qDpxhMUa7IPF 8KHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P4crEuft; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xj10-20020a170906db0a00b007ad8bc64c89si15066469ejb.701.2022.11.23.02.56.32; Wed, 23 Nov 2022 02:56:56 -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=P4crEuft; 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 S237437AbiKWKdJ (ORCPT + 88 others); Wed, 23 Nov 2022 05:33:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237487AbiKWKcL (ORCPT ); Wed, 23 Nov 2022 05:32:11 -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 9C5E91B9C7 for ; Wed, 23 Nov 2022 02:15:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669198529; 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=/JIc7C6bHMr2yR7PRaYpswtXHVf06FOZdXU09PtPw7c=; b=P4crEuftap6NQEYgXnH9PT8wLgLXKC0Ubaukthck4Df3PRTjhcCoQjGJgenpe3q8ppb2Bv cU3bYCtEOdFDVN9Hc6Bm75bTUxVIVMQZMLS0EbjQWwZMpxfs3gTEdqua+psec77qwiHQ/w DmXpqPgmfVAdfFray5k28m7wImijXvE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-htdbRUTXNpOGrxp20LEFHA-1; Wed, 23 Nov 2022 05:15:25 -0500 X-MC-Unique: htdbRUTXNpOGrxp20LEFHA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F1ED885A588; Wed, 23 Nov 2022 10:15:24 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40E184A9254; Wed, 23 Nov 2022 10:15:24 +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 07/17] rxrpc: Don't take spinlocks in the RCU callback functions 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: Wed, 23 Nov 2022 10:15:21 +0000 Message-ID: <166919852169.1258552.10370784990641295051.stgit@warthog.procyon.org.uk> In-Reply-To: <166919846440.1258552.9618708344491052554.stgit@warthog.procyon.org.uk> References: <166919846440.1258552.9618708344491052554.stgit@warthog.procyon.org.uk> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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 Don't take spinlocks in the RCU callback functions as these are run in softirq context - which then requires all other takers to use _bh-marked locks. Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- net/rxrpc/call_object.c | 30 +++++++----------------------- net/rxrpc/conn_object.c | 18 +++++++++--------- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c index 01ffe99516b8..d77b65bf3273 100644 --- a/net/rxrpc/call_object.c +++ b/net/rxrpc/call_object.c @@ -613,36 +613,16 @@ void rxrpc_put_call(struct rxrpc_call *call, enum rxrpc_call_trace why) /* * Final call destruction - but must be done in process context. */ -static void rxrpc_destroy_call(struct work_struct *work) +static void rxrpc_destroy_call(struct rcu_head *rcu) { - struct rxrpc_call *call = container_of(work, struct rxrpc_call, processor); + struct rxrpc_call *call = container_of(rcu, struct rxrpc_call, rcu); struct rxrpc_net *rxnet = call->rxnet; - rxrpc_delete_call_timer(call); - - rxrpc_put_connection(call->conn, rxrpc_conn_put_call); - rxrpc_put_peer(call->peer, rxrpc_peer_put_call); kmem_cache_free(rxrpc_call_jar, call); if (atomic_dec_and_test(&rxnet->nr_calls)) wake_up_var(&rxnet->nr_calls); } -/* - * Final call destruction under RCU. - */ -static void rxrpc_rcu_destroy_call(struct rcu_head *rcu) -{ - struct rxrpc_call *call = container_of(rcu, struct rxrpc_call, rcu); - - if (rcu_read_lock_held()) { - INIT_WORK(&call->processor, rxrpc_destroy_call); - if (!rxrpc_queue_work(&call->processor)) - BUG(); - } else { - rxrpc_destroy_call(&call->processor); - } -} - /* * clean up a call */ @@ -663,8 +643,12 @@ void rxrpc_cleanup_call(struct rxrpc_call *call) } rxrpc_put_txbuf(call->tx_pending, rxrpc_txbuf_put_cleaned); rxrpc_free_skb(call->acks_soft_tbl, rxrpc_skb_put_ack); + rxrpc_delete_call_timer(call); + + rxrpc_put_connection(call->conn, rxrpc_conn_put_call); + rxrpc_put_peer(call->peer, rxrpc_peer_put_call); - call_rcu(&call->rcu, rxrpc_rcu_destroy_call); + call_rcu(&call->rcu, rxrpc_destroy_call); } /* diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c index f7c271a740ed..54821c2f6d89 100644 --- a/net/rxrpc/conn_object.c +++ b/net/rxrpc/conn_object.c @@ -249,6 +249,15 @@ void rxrpc_kill_connection(struct rxrpc_connection *conn) */ rxrpc_purge_queue(&conn->rx_queue); + del_timer_sync(&conn->timer); + rxrpc_purge_queue(&conn->rx_queue); + + conn->security->clear(conn); + key_put(conn->key); + rxrpc_put_bundle(conn->bundle, rxrpc_bundle_put_conn); + rxrpc_put_peer(conn->peer, rxrpc_peer_put_conn); + rxrpc_put_local(conn->local, rxrpc_local_put_kill_conn); + /* Leave final destruction to RCU. The connection processor work item * must carry a ref on the connection to prevent us getting here whilst * it is queued or running. @@ -358,17 +367,8 @@ static void rxrpc_destroy_connection(struct rcu_head *rcu) ASSERTCMP(refcount_read(&conn->ref), ==, 0); - del_timer_sync(&conn->timer); - rxrpc_purge_queue(&conn->rx_queue); - - conn->security->clear(conn); - key_put(conn->key); - rxrpc_put_bundle(conn->bundle, rxrpc_bundle_put_conn); - rxrpc_put_peer(conn->peer, rxrpc_peer_put_conn); - if (atomic_dec_and_test(&conn->local->rxnet->nr_conns)) wake_up_var(&conn->local->rxnet->nr_conns); - rxrpc_put_local(conn->local, rxrpc_local_put_kill_conn); kfree(conn); _leave("");