Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp517607rdf; Tue, 21 Nov 2023 08:40:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxD/z6tUXAQ4j+gqXf7CtkRDxvKdiUsEIkIrr7etcDF0L105dI34qp8pbcyzo68upImEIO X-Received: by 2002:ae9:c00a:0:b0:77b:ec3a:27c8 with SMTP id u10-20020ae9c00a000000b0077bec3a27c8mr10128302qkk.63.1700584823603; Tue, 21 Nov 2023 08:40:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700584823; cv=none; d=google.com; s=arc-20160816; b=dvwOj0E5Z4eDByn3v/Fz0fqvCrP65dLM+lF/0Z/ViTBPyIq3fE3po20efdmBqTi8kI MRtfSFCwWzLBkzaDaSWvqsYeoh9YcLuOFj+hDIclz+/1Nn9ggslnUL+iITdlP7g1DzHq 63NSDy4VQezrM8elC77ykamVLOdmtzbibNXymVZgnhnWFNzYNztSl52u134mMMmLho7z Q+Q9VAqfNrI04nEUEnu1iALI1jMwi0l7DFhMQGUUQu/WNZNrY5UYPEgQ41UkAsWpNn+x mNduppEfUbrnWvARCf/LgDyiyCRVFyQeguoJvHw3SyeRFnsbH9Id/oAhx9VQNdMMmVye ik6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:date:cc:to:from:subject:dkim-signature; bh=0qRxO+QmMcEXa8h9WQQiMdV7wlnR5MoKZU0dk7Q0Vu0=; fh=ckZOnuavOce67CxFsxbWAkDFDgnVrD8nvvkVrKxmLnw=; b=YbdXsfmARYUMx1LrJr/ykgzVzF48tRlxIAJT5/XZEqLLWFt7SeE51+bI6ZLAjb1nCw bAX2d4EjyAyTIgzj28V6q4bqftK8sX+YxpnO2aYFOKkmWSdTOstT2gOK77XdpJv+Mbnx g8TqJd2bf/oclfvyFrzd2EHE0PFFLQzIQIBOYbGox/gR5qF2g30caO89/kwWI3xqUoYP MabNRgyFyoAD3VpFipO5ai1m86zUa/8mOELN60JLtcHOZ2256XQntEJpX5ZkCfu14ALX q65XQCG8vWkrdId9Lp3JCBKul5bOvoey6RL5qM9pV5UxWdQq8PzTTujhf6UMg+HLcT+p g3uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PvNwwyZP; spf=pass (google.com: domain of linux-nfs+bounces-13-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-13-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q14-20020a05620a0d8e00b007757f6e19bbsi10077429qkl.412.2023.11.21.08.40.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 08:40:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-13-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PvNwwyZP; spf=pass (google.com: domain of linux-nfs+bounces-13-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-13-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 412C01C21CB2 for ; Tue, 21 Nov 2023 16:40:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 745E556749; Tue, 21 Nov 2023 16:40:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PvNwwyZP" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36E944A9A7; Tue, 21 Nov 2023 16:40:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3531EC433C8; Tue, 21 Nov 2023 16:40:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700584821; bh=ZWiLYS5U8SaKvzumKQPMXDyabz+9Snq1UcacUrpx9M4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=PvNwwyZPklIe8HWOnz+Lj6a1B4J+UZR0ipINE38UNTMyl2y87oavCJJgvd267kqw6 9GHBmUGDCCLRs75EwLVUHyhPdHBqaALIw+45y6DfukEN2AWIYrJiYO4KAb3FYJzbQ9 qeuZ5QrDkC6wT1JsbFMILLr6u3QIhcyyPeMupQm116cKIhboj1UURBGPwp+Ao501Ul 7QwLTSz0zYmjGCmW6sa0WhTzlQcVJwGeK4yG3AK3IYw9Ow5S6l8U76rx8nS5yoyEU1 VJEb8u6r6/ZzJlq6epyGKx1u2vCVq9B5NFu0P7WNaUgMhKt1e18L+5vA0B+7fZSDja cOMdU2mn+0jrw== Subject: [PATCH v2 2/6] svcrdma: Pre-allocate svc_rdma_recv_ctxt objects From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Chuck Lever , tom@talpey.com Date: Tue, 21 Nov 2023 11:40:20 -0500 Message-ID: <170058482030.4504.11755101484955896125.stgit@bazille.1015granger.net> In-Reply-To: <170058462629.4504.17663192195815644972.stgit@bazille.1015granger.net> References: <170058462629.4504.17663192195815644972.stgit@bazille.1015granger.net> User-Agent: StGit/1.5 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit From: Chuck Lever The original reason for allocating svc_rdma_recv_ctxt objects during Receive completion was to ensure the objects were allocated on the NUMA node closest to the underlying IB device. Since commit c5d68d25bd6b ("svcrdma: Clean up allocation of svc_rdma_recv_ctxt"), however, the device's favored node is explicitly passed to the memory allocator. To enable switching Receive completion to soft IRQ context, move memory allocation out of completion handling, since it can be costly, and it can sleep. A limited number of objects is now allocated at "accept" time. Signed-off-by: Chuck Lever --- net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 32 ++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c index 3b05f90a3e50..c8c1c534070b 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c @@ -204,18 +204,11 @@ struct svc_rdma_recv_ctxt *svc_rdma_recv_ctxt_get(struct svcxprt_rdma *rdma) node = llist_del_first(&rdma->sc_recv_ctxts); if (!node) - goto out_empty; - ctxt = llist_entry(node, struct svc_rdma_recv_ctxt, rc_node); + return NULL; -out: + ctxt = llist_entry(node, struct svc_rdma_recv_ctxt, rc_node); ctxt->rc_page_count = 0; return ctxt; - -out_empty: - ctxt = svc_rdma_recv_ctxt_alloc(rdma); - if (!ctxt) - return NULL; - goto out; } /** @@ -277,7 +270,7 @@ static bool svc_rdma_refresh_recvs(struct svcxprt_rdma *rdma, rdma->sc_pending_recvs++; } if (!recv_chain) - return false; + return true; ret = ib_post_recv(rdma->sc_qp, recv_chain, &bad_wr); if (ret) @@ -301,10 +294,27 @@ static bool svc_rdma_refresh_recvs(struct svcxprt_rdma *rdma, * svc_rdma_post_recvs - Post initial set of Recv WRs * @rdma: fresh svcxprt_rdma * - * Returns true if successful, otherwise false. + * Return values: + * %true: Receive Queue initialization successful + * %false: memory allocation or DMA error */ bool svc_rdma_post_recvs(struct svcxprt_rdma *rdma) { + unsigned int total; + + /* For each credit, allocate enough recv_ctxts for one + * posted Receive and one RPC in process. + */ + total = (rdma->sc_max_requests * 2) + rdma->sc_recv_batch; + while (total--) { + struct svc_rdma_recv_ctxt *ctxt; + + ctxt = svc_rdma_recv_ctxt_alloc(rdma); + if (!ctxt) + return false; + llist_add(&ctxt->rc_node, &rdma->sc_recv_ctxts); + } + return svc_rdma_refresh_recvs(rdma, rdma->sc_max_requests); }