From patchwork Fri Mar 29 14:55:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13610689 X-Patchwork-Delegate: jgg@ziepe.ca Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F6AE14B07F for ; Fri, 29 Mar 2024 14:55:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724154; cv=none; b=JssmdGDak3vKSkSQXNgBfZE4xKxXoOOVCXBfxLRpFLtZGt9X9zPOBxKtbEDlYgvD4I6mEa+aNyBxCcTBvJfLN/oEgjYP1iqu8bx9+DqfBkGlprtJWMlGogqzrtxe/oGh+kCuTUEZDJxHMILe5m2cwpXxypUb47IZaYFCylmg69Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724154; c=relaxed/simple; bh=hu+sSbFLIXAKlrWao5wVCYP2Ee0hJ4jSnfY4fHwka+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WVm105rLSbqwg3xMzDH8236AnokOileq4sGzQ4v2wfeNx/Qjl2J7lUVqywtCamjz5JRqXc/4q+LfNMaMLnk46tavZJwzRRn4Qjx8LpPLvx51e4YlHnsxUimLcdb3pe5BmF6Xbb8U/2DKK6s9Fii62UH0jMsce3R9rAyuicKm3aQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nePPvcKv; arc=none smtp.client-ip=209.85.161.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nePPvcKv" Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-5a4d3b82e53so1238881eaf.0 for ; Fri, 29 Mar 2024 07:55:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711724152; x=1712328952; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GhL5vLaHOFdZg37ZOMVXMEp5PFqWRWgRRVOZKVIqNG0=; b=nePPvcKvzC5nTlNi113aoIdFVmEA59Dr6sD+Ny18+BWllQUJa/2vJ0cVIQBY3tmEV0 whPbMXktaAkex3HTdoL8JwF9z8Oh248bIvM+jFjsCClfa1j6SDIui5AAnByO+Y7g0GIv T5/6NsflF3p0NyUCttxTOenjZb0wS54Xj2b342RJR2sRzsC2EUyRHSQVklm64RK+6OcA gIUwdA38YEtqYEMw/2cvq799258ILQNRBP96TXQMLjcDhrChZn+QOkBxnzqZtqS0Lq7l 9d2jSTVf8qpRF+Rn8Mcl3jAPtEpTdrnADKixdJp+Ot6KryfMSzzSzUff8WWWZDuP6xsY k8pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711724152; x=1712328952; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GhL5vLaHOFdZg37ZOMVXMEp5PFqWRWgRRVOZKVIqNG0=; b=qX3aNcfRkQBCZ7dIGHBa8x6z5YWk2v2cQuiCrZaeCaGLyfsUdKcSLKWcMdc2rflOIH HeRDshh9RIno80YU7jN4z7rbHy+ErHW6l6liNiZ+9koADGjR3n+oWH7ueB/eXwvy/pHj vKZ/X6YxstjdkvHH6YsBkPitpnms9INoQ9JNv+kMYNDeOAMYd4weGstpd6BDaZl0EO25 Jq/df5VWpCCuHChYknXjfuZF2B6Cb4vPz4SRBtPzglCPEfbSBSziOJ70cCsnd2TjY4be x9XDbhCsOJc3/F+CbuJWgwic5iQ+U+RTVnbH1Ht6Oc4L6rU9z+914T4isnLvnc7MzkHq 8how== X-Forwarded-Encrypted: i=1; AJvYcCXWGy2+vH/TFGveOfmNChPMXU1B/u2bwX3f/snJosjGV3kH2ui/5R38pr15GOTPgHD0LkGXsdE/9wETrd5UXdESIwRJoqdihiRKAg== X-Gm-Message-State: AOJu0YzCBdKeOB9MsaCll2RLNi5YBTMJuYBFZCLw3jLG/UFFNXDr2jpH Fbn8rk1IelE1HuT9buQP/UA2u6ululZoL1IhPIaqpWenQS8aPraH X-Google-Smtp-Source: AGHT+IE8BMUAzXjT6ARkgqrlLaEGbxmDIhG8opFgGVKI8fcoTT/d3hvxKuDGIZG99seaNqyPWDdv3g== X-Received: by 2002:a05:6871:808b:b0:22e:102e:ba26 with SMTP id sl11-20020a056871808b00b0022e102eba26mr67955oab.6.1711724152438; Fri, 29 Mar 2024 07:55:52 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-75b6-1a40-9b4e-0264.res6.spectrum.com. [2603:8081:1405:679b:75b6:1a40:9b4e:264]) by smtp.gmail.com with ESMTPSA id fl9-20020a056870494900b0022a58ffa4a3sm1006249oab.23.2024.03.29.07.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:55:52 -0700 (PDT) From: Bob Pearson To: yanjun.zhu@linux.dev, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-next v3 01/12] RDMA/rxe: Fix seg fault in rxe_comp_queue_pkt Date: Fri, 29 Mar 2024 09:55:04 -0500 Message-ID: <20240329145513.35381-4-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329145513.35381-2-rpearsonhpe@gmail.com> References: <20240329145513.35381-2-rpearsonhpe@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In rxe_comp_queue_pkt() an incoming response packet skb is enqueued to the resp_pkts queue and then a decision is made whether to run the completer task inline or schedule it. Finally the skb is dereferenced to bump a 'hw' performance counter. This is wrong because if the completer task is already running in a separate thread it may have already processed the skb and freed it which can cause a seg fault. This has been observed infrequently in testing at high scale. This patch fixes this by changing the order of enqueuing the packet until after the counter is accessed. Signed-off-by: Bob Pearson Fixes: 0b1e5b99a48b ("IB/rxe: Add port protocol stats") --- drivers/infiniband/sw/rxe/rxe_comp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index b78b8c0856ab..c997b7cbf2a9 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -131,12 +131,12 @@ void rxe_comp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb) { int must_sched; - skb_queue_tail(&qp->resp_pkts, skb); - - must_sched = skb_queue_len(&qp->resp_pkts) > 1; + must_sched = skb_queue_len(&qp->resp_pkts) > 0; if (must_sched != 0) rxe_counter_inc(SKB_TO_PKT(skb)->rxe, RXE_CNT_COMPLETER_SCHED); + skb_queue_tail(&qp->resp_pkts, skb); + if (must_sched) rxe_sched_task(&qp->comp.task); else From patchwork Fri Mar 29 14:55:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13610690 X-Patchwork-Delegate: jgg@ziepe.ca Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75C5D14B07A for ; Fri, 29 Mar 2024 14:55:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724155; cv=none; b=keBUMg3frRPSvEj5JeA3Tzi9V/oGHQ4HSfmhscwABKSrYqd/TRoco2o2kMChhq6PbE2DSA9l02UdSb58O6pcQ9PwhJTyM3q7c1WDjAlrJ1VUOFi9wwFHLeTiu30lcDDAhnLD1s0l7RB8/tViMIeZtgdcLYy6kxF5NsMG7CDZt5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724155; c=relaxed/simple; bh=OgClSkZM6eL+vERrw/+EJ7tK7V2p4YmhFAD6CV9gxPA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FX1x88fnN7upIpdgLE2zlMCDx4h7ZAzK/38+tSnBG1lrw2+A9M89BJN+ZZbhqRQKjz6tzK37HS3i80QJBZBgBHXLLUkJg+EFoTBm9ucHb0ekOtyNYGnYXEMHP7/sCtVZ00fMTn6cwit6lB+Jd9BE04jPVKZ/Uv/1Xq7Q1pPyhX4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dCpZLY2X; arc=none smtp.client-ip=209.85.161.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dCpZLY2X" Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-5a4817189c8so1303657eaf.1 for ; Fri, 29 Mar 2024 07:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711724153; x=1712328953; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/w/TqH3HRW65DzoIY9Yp9OycxO2wAP6KUspzBtAQQiA=; b=dCpZLY2X3p4/RAk30oId6DEYJ43POB/tX9LZ5QYqxkmB9ltAc1WmSaiozhSV89gGK8 di5WzX3DbgYTpTyQYUd7jBMEP1kqVeHGXup8dtzYne7KJKerYGXlBRxxXNa6hJk4cgLn aaA7aLmHR0SIlarl8UfcMcVhJyMsZJ0QIcstHDMZM+RTEEMtFI+dAr8eNmLKvcWzge9r m3RdxKmUMjmtDjz/BCjpVgSVf/n0uBfgtmXnrapNTZp43TG93wAsCImZqR79H+TN3e7k L7j/QK+3CjKZXPXA8CmE7RrQYJTj7WL+rRL9JfxTR5F3pcAkWDTIpCFlD1IFIYRC8e9S 50cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711724153; x=1712328953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/w/TqH3HRW65DzoIY9Yp9OycxO2wAP6KUspzBtAQQiA=; b=FP2iZ3xZw1cQNOHBOhMkHKmqzGfSNsme0a/LRjS+v8eebExGTkcg1EcN1JiTm6BOqj 6NmCJWoX4EBfRpfhfwOX4jT45bX9qlnbHhv/j9nc4nIG3Oxc7qLVUtp8YZaiusOeKiXI YrIcJSxlt7Rp6GFjV1e0MEr9VLKMOhICVpCRZil0KozVKn2chZUws0Ybim3trk5C37uB z1OyHQYMwas8iTgzUdtjgKfu3RRM6WHgLD0Knz85qvi3wAbgHlwgItxzBVO0P2YB8mdm +XtmVi/cd1UODzXZO7xDVHQ2KC+BN9L4jpWw5VTsSJemrItE5wLtVxIce+U7IiF1mkQX Ey8Q== X-Forwarded-Encrypted: i=1; AJvYcCURVI4MIiSRRKmIzOYovGWevYH9Jf5MYJIuFlUBxxRYpO8r8fao8dR8I4DmEB2E4P2cItqabC4wZTB0I5Vuyuw9W6VCqPwCxn322w== X-Gm-Message-State: AOJu0YyaFwWP5seKmSgESfFmAruYYUa+d4OfCdOb21V3ifMtWQLwwXOv /+3YaW8MGh3G/BfXPbe/ihBXKY/pfnw2NKT+JE6fphaLg7XX4aZLknq7NPA/+b0= X-Google-Smtp-Source: AGHT+IHxIAI52ySVo9eEz+0Q59IX569s9rSmqgLu0Z3pTUkc2Q2KCeyPzYdWFHdwuNoZsW3Bk+5P4g== X-Received: by 2002:a05:6870:a925:b0:222:69b8:44c6 with SMTP id eq37-20020a056870a92500b0022269b844c6mr2522033oab.9.1711724153590; Fri, 29 Mar 2024 07:55:53 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-75b6-1a40-9b4e-0264.res6.spectrum.com. [2603:8081:1405:679b:75b6:1a40:9b4e:264]) by smtp.gmail.com with ESMTPSA id fl9-20020a056870494900b0022a58ffa4a3sm1006249oab.23.2024.03.29.07.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:55:52 -0700 (PDT) From: Bob Pearson To: yanjun.zhu@linux.dev, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-next v3 02/12] RDMA/rxe: Allow good work requests to be executed Date: Fri, 29 Mar 2024 09:55:05 -0500 Message-ID: <20240329145513.35381-5-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329145513.35381-2-rpearsonhpe@gmail.com> References: <20240329145513.35381-2-rpearsonhpe@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A previous commit incorrectly added an 'if(!err)' before scheduling the requester task in rxe_post_send_kernel(). But if there were send wrs successfully added to the send queue before a bad wr they might never get executed. This commit fixes this by scheduling the requester task if any wqes were successfully posted in rxe_post_send_kernel() in rxe_verbs.c. Signed-off-by: Bob Pearson Fixes: 5bf944f24129 ("RDMA/rxe: Add error messages") --- drivers/infiniband/sw/rxe/rxe_verbs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 614581989b38..a49784e5156c 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -888,6 +888,7 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, { int err = 0; unsigned long flags; + int good = 0; spin_lock_irqsave(&qp->sq.sq_lock, flags); while (ibwr) { @@ -895,12 +896,15 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, if (err) { *bad_wr = ibwr; break; + } else { + good++; } ibwr = ibwr->next; } spin_unlock_irqrestore(&qp->sq.sq_lock, flags); - if (!err) + /* kickoff processing of any posted wqes */ + if (good) rxe_sched_task(&qp->req.task); spin_lock_irqsave(&qp->state_lock, flags); From patchwork Fri Mar 29 14:55:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13610691 X-Patchwork-Delegate: jgg@ziepe.ca Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 955E514B07F for ; Fri, 29 Mar 2024 14:55:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724157; cv=none; b=HsrMUioktee6/HHOvEVV+eUOthff+zvnfExkBQMkXBaPekPb1a8sTM/X62N/S7K25B3xOv95S3DtapZsOIVuO5uTWUF2snJ8qtOHR5NqSfgB6FS8SfpY2Tr5HUTfGsNW7c/em7tPyVr6tQiZfs+Zh60S4DNL5s9v1+NpvLagPE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724157; c=relaxed/simple; bh=8iWHOP99IJh3x4cD8IHColiMPVTQtiJHUSlhmwoFscQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dug90FJ0bvpggwZnNHnB6NSfq5JB7TvmlCtgL/bBqUO8+6knm9fyRbIA+rQSTYC87P3Hpo7ULAbJWBEHaLI8rtt1SpgWGV0JIMbrapA6YBQ6f8mDtFICSXhViD7vs+9CkFaH6iF7ZfmEFBV7P7XfUtEx4MP6pqgre+7lIX933uM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HNctGz2p; arc=none smtp.client-ip=209.85.160.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HNctGz2p" Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-2218a0f55e1so1128861fac.1 for ; Fri, 29 Mar 2024 07:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711724154; x=1712328954; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+5LQvpPsIQNq+n9+JoELgdiMziRukkOmYY3wjmCQ26g=; b=HNctGz2pprwooIdatpxEd472p5xioR7toZFiY1yEf3Wo+45ebCpMTlX5WO7IRfLtoY Y/rI0PKEmOR7JvLgFJz3FmbXPay67Ad4+zh2hYorJ8V9XH8FMCIuw7RCBBEBTb6y2PSu psH+mvJZjwr2syUmp4jlbGxxqFU0pQ03SgRihTd+hRpnDXHJfClIdLfO4k1nnRtH0Arh oHa8DM/Q2NtiYbQ6aimyQNpw35hUf46VS7viVqaHBgX37pLI7ieh9L74cTbso6MSjfxo PmgS2ZofaMxhoCXvXOtC+nmZBfWaPdL/175+7YMFT9Sv3fcREvuS+ckBPKeoNxw70vy0 8k1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711724154; x=1712328954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+5LQvpPsIQNq+n9+JoELgdiMziRukkOmYY3wjmCQ26g=; b=po5Ua7TGE4PsMpGTQERJJrun+MDf3OVu7aMnRf65DtUufaGsxducL6EN581S4irIjW xIl+dMPlhrmMXri/+MMHtR8DsqzbXwL+RLy6FPx1hDAluMylJcVz1+ltjOGf/qvMe2W0 BTjXxqW7aGaEBelKL65mNA1xS99YVZVKdhcUUFB0HcnySsns5u35M4QpyFQ0E337e9AS 90i8M2lye995D18tdrPG6WkLUMjhVtooji0oNsTsbW8Qh135tlX30gEW2p+znbBilWqU TDGxvGTjUFSmWmmQKialeJUGkDv74S7UWydfAxr4kqyimR0dHYuGSGJGhBQN1+5cldK1 hc1A== X-Forwarded-Encrypted: i=1; AJvYcCWW/hqcw3scQ4TA8CP+b+dy6wl71tegrrv5K70SJt8/kdgzoqDGUCcGfEE/MA89l3sXyyGJDpgUMKMTHSfoSExDy/ibp9cPLkhKBg== X-Gm-Message-State: AOJu0YwwZPD8NRJ0scRNpX6q0Diujt/22CGuYPeWmJktKLtmtUtfghZu 3cZ105be22490B39uxYVMwPq7qZGo86xlBLa3Fio69L7hOoq63Vt X-Google-Smtp-Source: AGHT+IHTskVQpSQax87n/XexZvw1OTGC8uZNYb1b+stAsHK4ENA/ueqeMJWAPMZtYGu6jizEc0VNug== X-Received: by 2002:a05:6870:2393:b0:22d:f9e1:dbce with SMTP id e19-20020a056870239300b0022df9e1dbcemr1956243oap.6.1711724154686; Fri, 29 Mar 2024 07:55:54 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-75b6-1a40-9b4e-0264.res6.spectrum.com. [2603:8081:1405:679b:75b6:1a40:9b4e:264]) by smtp.gmail.com with ESMTPSA id fl9-20020a056870494900b0022a58ffa4a3sm1006249oab.23.2024.03.29.07.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:55:53 -0700 (PDT) From: Bob Pearson To: yanjun.zhu@linux.dev, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-next v3 03/12] RDMA/rxe: Remove redundant scheduling of rxe_completer Date: Fri, 29 Mar 2024 09:55:06 -0500 Message-ID: <20240329145513.35381-6-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329145513.35381-2-rpearsonhpe@gmail.com> References: <20240329145513.35381-2-rpearsonhpe@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In rxe_post_send_kernel() if the qp is in the error state after posting the work requests the rxe_completer() task is scheduled. But, the only way to move the qp into the error state is to call rxe_qp_error() which also schedules the rxe_completer() task to drain the queues. Calling it a second time has no effect. This commit removes the redundant call. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_verbs.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index a49784e5156c..71b0f834030f 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -907,11 +907,6 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, if (good) rxe_sched_task(&qp->req.task); - spin_lock_irqsave(&qp->state_lock, flags); - if (qp_state(qp) == IB_QPS_ERR) - rxe_sched_task(&qp->comp.task); - spin_unlock_irqrestore(&qp->state_lock, flags); - return err; } From patchwork Fri Mar 29 14:55:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13610692 X-Patchwork-Delegate: jgg@ziepe.ca Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A31AC14B07A for ; Fri, 29 Mar 2024 14:55:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724158; cv=none; b=hXgBrNNEroHVxT9I9hf077dbq23IpVFVJcruzSPLwDFwdd5q6mKekBw7YuXP8rfR2LIdNFIaoGW86ubQcgTW/VCYnblEVyvl7HFBzF9Z+0QRb1mB5wt++Co3/2sERg1+OYlgsZZLlwXYl4TvUE3h9mf+75POABv7WveZryDAGdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724158; c=relaxed/simple; bh=t50X/6Tszd41e46zl3EW21Kgj0HeSS3Z6HC8xX/f1eY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UVhn9XSpUY1Vg/H4Fq4MRVJ/9oIsXoAPNCTF2AeK6PME/pyX0TGaj5EKl3FoTflDNVrHYSSyxJRvifcmelCx/W6WCVKP6tDBDoUtF6yfaBpSOD4RTccgNFO/vEnR/Glo9j7vLHnNFdUZZIhJnqsJsyT0IlI/Gso1mmoYmHX7i/0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NVzg+61Y; arc=none smtp.client-ip=209.85.167.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NVzg+61Y" Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-3c3f3806d88so339978b6e.3 for ; Fri, 29 Mar 2024 07:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711724156; x=1712328956; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0BiPmDBurHeOCjGjOgWR1zSxn97Z8ryeitoC4oy0wck=; b=NVzg+61YccljpDjjNwklEjdR07fZbVmMcHlAZ2JF7SwFXWVZI5XcSjoc3bCgnglM4Z Q7GHVjDztdg0OLJ/gkXSkn7kzr+5eNnD+u3qxuy/1TKPTtrWFcZDVh4GgI7aahPrpSsR UE6IYq7qHWr1a7LZHbDrVtiM8AtEcvcyXPD3lnmADdVev8Hb5HIq+IA/MZRddY20WsH+ xMe3AuopvyytPe9Y4p0IcJucVxcpe02SQk8zIHKeE8qvvDfmcQTeeMKwBQt1LXrgOkND FxXiM+9jiE41pdT8HjTv9YzZy2v4sX+MPMigz9YdPv1vDtR+WokcVVajtyJlR2U+T4Xs J2cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711724156; x=1712328956; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0BiPmDBurHeOCjGjOgWR1zSxn97Z8ryeitoC4oy0wck=; b=enuzejmwXl4mHZWosdMzVs3GfllrXgiSp1UtQ4tAEPQFhkgcKAwmmgexT8Bf8dRk56 aDQaPWQI5Va46QtBeziC3zuej7mXLRRlprP47JMqq294OaXdOBV7grueilXpB7aaF7TB MQOq6+x957cN1FAz3wAPfQkuurihHVFlZc73E/+G1qM64tRyOi4uQR5G8L2+DYDx39XS F+nCqgP5vbHMa6HMTBjpRU5QVezqck5TyizW2hyRggtCeE+t7XsDIH+9KgFlafGP30QH 6AAt/HgmOOOsmG33BmoPeyXwkPHyZgo/6W0KFNwQj8o44YrzobJdt0kAICeuPw9wTYKu 9GYQ== X-Forwarded-Encrypted: i=1; AJvYcCWGqkOJKjMSe0H2xQem/5tquavDc7JFq/Z2jwS6ieUKifD0OTL/UN+73Rc2XKoJfnldcnGpRHMJFRJIC2bRu+hgHLTh05Il6vrx5Q== X-Gm-Message-State: AOJu0YzbbhEsSVG/1axq8nmaJpssCQPUcgl/TfEOKxe5UvzWFogg+fAw Uui/MR0ky5Y8zfG/eXLuvXlW5K848616V0J7VdxaHJ8FrJmteWxmLleUBPqYyuQ= X-Google-Smtp-Source: AGHT+IGUYby+qtVbpbqECXP9K+A8eF4tVlaG3UUPxs4n7GM/OO9qWEGFeM/MOcD8SAVfpzhY0ouEYw== X-Received: by 2002:a05:6870:41c4:b0:22a:a21e:6d74 with SMTP id z4-20020a05687041c400b0022aa21e6d74mr2507729oac.39.1711724155666; Fri, 29 Mar 2024 07:55:55 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-75b6-1a40-9b4e-0264.res6.spectrum.com. [2603:8081:1405:679b:75b6:1a40:9b4e:264]) by smtp.gmail.com with ESMTPSA id fl9-20020a056870494900b0022a58ffa4a3sm1006249oab.23.2024.03.29.07.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:55:55 -0700 (PDT) From: Bob Pearson To: yanjun.zhu@linux.dev, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-next v3 04/12] RDMA/rxe: Merge request and complete tasks Date: Fri, 29 Mar 2024 09:55:07 -0500 Message-ID: <20240329145513.35381-7-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329145513.35381-2-rpearsonhpe@gmail.com> References: <20240329145513.35381-2-rpearsonhpe@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently the rxe driver has three work queue tasks per qp. These are the req.task, comp.task and resp.task which call rxe_requester(), rxe_completer() and rxe_responder() respectively directly or on work queues. Each of these subroutines checks to see if there is work to be performed on the send queue or on the response packet queue or the request packet queue and will run until there is no work remaining or yield the cpu and reschedule itself until there is no work remaining. This commit combines the req.task and comp.task into a single send.task and renames the resp.task to the recv.task. The combined send.task calls rxe_requester() and rxe_completer() serially and continues until all work on both the send queue and the response packet queue are done. In various benchmarks the performance is either improved or left the same. At high scale there is a significant reduction in the load on the cpu. This is the first step in combining these two tasks. Once they are serialized cross rescheduling of req.task and comp.task can be more efficiently handled by just letting the send.task continue to run. This will be done in the next several patches. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_comp.c | 20 +++++----- drivers/infiniband/sw/rxe/rxe_hw_counters.c | 2 +- drivers/infiniband/sw/rxe/rxe_hw_counters.h | 2 +- drivers/infiniband/sw/rxe/rxe_loc.h | 3 +- drivers/infiniband/sw/rxe/rxe_net.c | 4 +- drivers/infiniband/sw/rxe/rxe_qp.c | 44 ++++++++------------- drivers/infiniband/sw/rxe/rxe_req.c | 25 ++++++++++-- drivers/infiniband/sw/rxe/rxe_resp.c | 6 +-- drivers/infiniband/sw/rxe/rxe_verbs.c | 6 +-- drivers/infiniband/sw/rxe/rxe_verbs.h | 6 +-- 10 files changed, 63 insertions(+), 55 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index c997b7cbf2a9..ea64a25fe876 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -122,7 +122,7 @@ void retransmit_timer(struct timer_list *t) spin_lock_irqsave(&qp->state_lock, flags); if (qp->valid) { qp->comp.timeout = 1; - rxe_sched_task(&qp->comp.task); + rxe_sched_task(&qp->send_task); } spin_unlock_irqrestore(&qp->state_lock, flags); } @@ -133,14 +133,14 @@ void rxe_comp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb) must_sched = skb_queue_len(&qp->resp_pkts) > 0; if (must_sched != 0) - rxe_counter_inc(SKB_TO_PKT(skb)->rxe, RXE_CNT_COMPLETER_SCHED); + rxe_counter_inc(SKB_TO_PKT(skb)->rxe, RXE_CNT_SENDER_SCHED); skb_queue_tail(&qp->resp_pkts, skb); if (must_sched) - rxe_sched_task(&qp->comp.task); + rxe_sched_task(&qp->send_task); else - rxe_run_task(&qp->comp.task); + rxe_run_task(&qp->send_task); } static inline enum comp_state get_wqe(struct rxe_qp *qp, @@ -325,7 +325,7 @@ static inline enum comp_state check_ack(struct rxe_qp *qp, qp->comp.psn = pkt->psn; if (qp->req.wait_psn) { qp->req.wait_psn = 0; - rxe_sched_task(&qp->req.task); + rxe_sched_task(&qp->send_task); } } return COMPST_ERROR_RETRY; @@ -476,7 +476,7 @@ static void do_complete(struct rxe_qp *qp, struct rxe_send_wqe *wqe) */ if (qp->req.wait_fence) { qp->req.wait_fence = 0; - rxe_sched_task(&qp->req.task); + rxe_sched_task(&qp->send_task); } } @@ -515,7 +515,7 @@ static inline enum comp_state complete_ack(struct rxe_qp *qp, if (qp->req.need_rd_atomic) { qp->comp.timeout_retry = 0; qp->req.need_rd_atomic = 0; - rxe_sched_task(&qp->req.task); + rxe_sched_task(&qp->send_task); } } @@ -541,7 +541,7 @@ static inline enum comp_state complete_wqe(struct rxe_qp *qp, if (qp->req.wait_psn) { qp->req.wait_psn = 0; - rxe_sched_task(&qp->req.task); + rxe_sched_task(&qp->send_task); } } @@ -737,7 +737,7 @@ int rxe_completer(struct rxe_qp *qp) if (qp->req.wait_psn) { qp->req.wait_psn = 0; - rxe_sched_task(&qp->req.task); + rxe_sched_task(&qp->send_task); } state = COMPST_DONE; @@ -792,7 +792,7 @@ int rxe_completer(struct rxe_qp *qp) RXE_CNT_COMP_RETRY); qp->req.need_retry = 1; qp->comp.started_retry = 1; - rxe_sched_task(&qp->req.task); + rxe_sched_task(&qp->send_task); } goto done; diff --git a/drivers/infiniband/sw/rxe/rxe_hw_counters.c b/drivers/infiniband/sw/rxe/rxe_hw_counters.c index a012522b577a..437917a7d8f2 100644 --- a/drivers/infiniband/sw/rxe/rxe_hw_counters.c +++ b/drivers/infiniband/sw/rxe/rxe_hw_counters.c @@ -14,7 +14,7 @@ static const struct rdma_stat_desc rxe_counter_descs[] = { [RXE_CNT_RCV_RNR].name = "rcvd_rnr_err", [RXE_CNT_SND_RNR].name = "send_rnr_err", [RXE_CNT_RCV_SEQ_ERR].name = "rcvd_seq_err", - [RXE_CNT_COMPLETER_SCHED].name = "ack_deferred", + [RXE_CNT_SENDER_SCHED].name = "ack_deferred", [RXE_CNT_RETRY_EXCEEDED].name = "retry_exceeded_err", [RXE_CNT_RNR_RETRY_EXCEEDED].name = "retry_rnr_exceeded_err", [RXE_CNT_COMP_RETRY].name = "completer_retry_err", diff --git a/drivers/infiniband/sw/rxe/rxe_hw_counters.h b/drivers/infiniband/sw/rxe/rxe_hw_counters.h index 71f4d4fa9dc8..051f9e1c3852 100644 --- a/drivers/infiniband/sw/rxe/rxe_hw_counters.h +++ b/drivers/infiniband/sw/rxe/rxe_hw_counters.h @@ -18,7 +18,7 @@ enum rxe_counters { RXE_CNT_RCV_RNR, RXE_CNT_SND_RNR, RXE_CNT_RCV_SEQ_ERR, - RXE_CNT_COMPLETER_SCHED, + RXE_CNT_SENDER_SCHED, RXE_CNT_RETRY_EXCEEDED, RXE_CNT_RNR_RETRY_EXCEEDED, RXE_CNT_COMP_RETRY, diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index 746110898a0e..ded46119151b 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -164,7 +164,8 @@ void rxe_dealloc(struct ib_device *ib_dev); int rxe_completer(struct rxe_qp *qp); int rxe_requester(struct rxe_qp *qp); -int rxe_responder(struct rxe_qp *qp); +int rxe_sender(struct rxe_qp *qp); +int rxe_receiver(struct rxe_qp *qp); /* rxe_icrc.c */ int rxe_icrc_init(struct rxe_dev *rxe); diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index cd59666158b1..928508558df4 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -351,7 +351,7 @@ static void rxe_skb_tx_dtor(struct sk_buff *skb) if (unlikely(qp->need_req_skb && skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW)) - rxe_sched_task(&qp->req.task); + rxe_sched_task(&qp->send_task); rxe_put(qp); } @@ -443,7 +443,7 @@ int rxe_xmit_packet(struct rxe_qp *qp, struct rxe_pkt_info *pkt, if ((qp_type(qp) != IB_QPT_RC) && (pkt->mask & RXE_END_MASK)) { pkt->wqe->state = wqe_state_done; - rxe_sched_task(&qp->comp.task); + rxe_sched_task(&qp->send_task); } rxe_counter_inc(rxe, RXE_CNT_SENT_PKTS); diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c index e3589c02013e..c7d99063594b 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -265,8 +265,7 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp, qp->req.opcode = -1; qp->comp.opcode = -1; - rxe_init_task(&qp->req.task, qp, rxe_requester); - rxe_init_task(&qp->comp.task, qp, rxe_completer); + rxe_init_task(&qp->send_task, qp, rxe_sender); qp->qp_timeout_jiffies = 0; /* Can't be set for UD/UC in modify_qp */ if (init->qp_type == IB_QPT_RC) { @@ -337,7 +336,7 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp, return err; } - rxe_init_task(&qp->resp.task, qp, rxe_responder); + rxe_init_task(&qp->recv_task, qp, rxe_receiver); qp->resp.opcode = OPCODE_NONE; qp->resp.msn = 0; @@ -514,14 +513,12 @@ int rxe_qp_chk_attr(struct rxe_dev *rxe, struct rxe_qp *qp, static void rxe_qp_reset(struct rxe_qp *qp) { /* stop tasks from running */ - rxe_disable_task(&qp->resp.task); - rxe_disable_task(&qp->comp.task); - rxe_disable_task(&qp->req.task); + rxe_disable_task(&qp->recv_task); + rxe_disable_task(&qp->send_task); /* drain work and packet queuesc */ - rxe_requester(qp); - rxe_completer(qp); - rxe_responder(qp); + rxe_sender(qp); + rxe_receiver(qp); if (qp->rq.queue) rxe_queue_reset(qp->rq.queue); @@ -548,9 +545,8 @@ static void rxe_qp_reset(struct rxe_qp *qp) cleanup_rd_atomic_resources(qp); /* reenable tasks */ - rxe_enable_task(&qp->resp.task); - rxe_enable_task(&qp->comp.task); - rxe_enable_task(&qp->req.task); + rxe_enable_task(&qp->recv_task); + rxe_enable_task(&qp->send_task); } /* move the qp to the error state */ @@ -562,9 +558,8 @@ void rxe_qp_error(struct rxe_qp *qp) qp->attr.qp_state = IB_QPS_ERR; /* drain work and packet queues */ - rxe_sched_task(&qp->resp.task); - rxe_sched_task(&qp->comp.task); - rxe_sched_task(&qp->req.task); + rxe_sched_task(&qp->recv_task); + rxe_sched_task(&qp->send_task); spin_unlock_irqrestore(&qp->state_lock, flags); } @@ -575,8 +570,7 @@ static void rxe_qp_sqd(struct rxe_qp *qp, struct ib_qp_attr *attr, spin_lock_irqsave(&qp->state_lock, flags); qp->attr.sq_draining = 1; - rxe_sched_task(&qp->comp.task); - rxe_sched_task(&qp->req.task); + rxe_sched_task(&qp->send_task); spin_unlock_irqrestore(&qp->state_lock, flags); } @@ -821,19 +815,15 @@ static void rxe_qp_do_cleanup(struct work_struct *work) del_timer_sync(&qp->rnr_nak_timer); } - if (qp->resp.task.func) - rxe_cleanup_task(&qp->resp.task); + if (qp->recv_task.func) + rxe_cleanup_task(&qp->recv_task); - if (qp->req.task.func) - rxe_cleanup_task(&qp->req.task); - - if (qp->comp.task.func) - rxe_cleanup_task(&qp->comp.task); + if (qp->send_task.func) + rxe_cleanup_task(&qp->send_task); /* flush out any receive wr's or pending requests */ - rxe_requester(qp); - rxe_completer(qp); - rxe_responder(qp); + rxe_sender(qp); + rxe_receiver(qp); if (qp->sq.queue) rxe_queue_cleanup(qp->sq.queue); diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index d8c41fd626a9..31a611ced3c5 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -108,7 +108,7 @@ void rnr_nak_timer(struct timer_list *t) /* request a send queue retry */ qp->req.need_retry = 1; qp->req.wait_for_rnr_timer = 0; - rxe_sched_task(&qp->req.task); + rxe_sched_task(&qp->send_task); } spin_unlock_irqrestore(&qp->state_lock, flags); } @@ -659,7 +659,7 @@ static int rxe_do_local_ops(struct rxe_qp *qp, struct rxe_send_wqe *wqe) * which can lead to a deadlock. So go ahead and complete * it now. */ - rxe_sched_task(&qp->comp.task); + rxe_sched_task(&qp->send_task); return 0; } @@ -786,7 +786,7 @@ int rxe_requester(struct rxe_qp *qp) qp->req.wqe_index); wqe->state = wqe_state_done; wqe->status = IB_WC_SUCCESS; - rxe_sched_task(&qp->comp.task); + rxe_sched_task(&qp->send_task); goto done; } payload = mtu; @@ -855,7 +855,7 @@ int rxe_requester(struct rxe_qp *qp) */ qp->need_req_skb = 1; - rxe_sched_task(&qp->req.task); + rxe_sched_task(&qp->send_task); goto exit; } @@ -878,3 +878,20 @@ int rxe_requester(struct rxe_qp *qp) out: return ret; } + +int rxe_sender(struct rxe_qp *qp) +{ + int req_ret; + int comp_ret; + + /* process the send queue */ + req_ret = rxe_requester(qp); + + /* process the response queue */ + comp_ret = rxe_completer(qp); + + /* exit the task loop if both requester and completer + * are ready + */ + return (req_ret && comp_ret) ? -EAGAIN : 0; +} diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c index 963382f625d7..3ce7a32b5dcf 100644 --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -58,9 +58,9 @@ void rxe_resp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb) (skb_queue_len(&qp->req_pkts) > 1); if (must_sched) - rxe_sched_task(&qp->resp.task); + rxe_sched_task(&qp->recv_task); else - rxe_run_task(&qp->resp.task); + rxe_run_task(&qp->recv_task); } static inline enum resp_states get_req(struct rxe_qp *qp, @@ -1485,7 +1485,7 @@ static void flush_recv_queue(struct rxe_qp *qp, bool notify) qp->resp.wqe = NULL; } -int rxe_responder(struct rxe_qp *qp) +int rxe_receiver(struct rxe_qp *qp) { struct rxe_dev *rxe = to_rdev(qp->ibqp.device); enum resp_states state; diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 71b0f834030f..d07f7bd3b2ae 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -905,7 +905,7 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, /* kickoff processing of any posted wqes */ if (good) - rxe_sched_task(&qp->req.task); + rxe_sched_task(&qp->send_task); return err; } @@ -935,7 +935,7 @@ static int rxe_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr, if (qp->is_user) { /* Utilize process context to do protocol processing */ - rxe_run_task(&qp->req.task); + rxe_run_task(&qp->send_task); } else { err = rxe_post_send_kernel(qp, wr, bad_wr); if (err) @@ -1045,7 +1045,7 @@ static int rxe_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr, spin_lock_irqsave(&qp->state_lock, flags); if (qp_state(qp) == IB_QPS_ERR) - rxe_sched_task(&qp->resp.task); + rxe_sched_task(&qp->recv_task); spin_unlock_irqrestore(&qp->state_lock, flags); return err; diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index ccb9d19ffe8a..af8939b8c7a1 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -113,7 +113,6 @@ struct rxe_req_info { int need_retry; int wait_for_rnr_timer; int noack_pkts; - struct rxe_task task; }; struct rxe_comp_info { @@ -124,7 +123,6 @@ struct rxe_comp_info { int started_retry; u32 retry_cnt; u32 rnr_retry; - struct rxe_task task; }; enum rdatm_res_state { @@ -196,7 +194,6 @@ struct rxe_resp_info { unsigned int res_head; unsigned int res_tail; struct resp_res *res; - struct rxe_task task; }; struct rxe_qp { @@ -229,6 +226,9 @@ struct rxe_qp { struct sk_buff_head req_pkts; struct sk_buff_head resp_pkts; + struct rxe_task send_task; + struct rxe_task recv_task; + struct rxe_req_info req; struct rxe_comp_info comp; struct rxe_resp_info resp; From patchwork Fri Mar 29 14:55:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13610693 X-Patchwork-Delegate: jgg@ziepe.ca Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C68A614B091 for ; Fri, 29 Mar 2024 14:55:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724159; cv=none; b=M25a83I4Qb3qZrZh4S3QAHhbvpbTf+ZGZKZQ7Pn0A/Rdfd0VUJDo/cIH21ExR/vHNBAx1GptqXNVwDPrf5Sv6d0D1Mp4RovMKojZkr2T3M6K7AW82J9xFy1s4o/pMNbTDbg2xeJoAq/cbHtWIy/fQaAllC4IuMS1+TOvlfMpTbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724159; c=relaxed/simple; bh=XIImzMuwSkGxY8LRL32oWi/vfkg7DtdUs916utrYrLI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ka0OT8offggmLQKv2lrSZqDFnbXCvYI/hPSByb1BvJ3DOdvr+fEAduGTyF+7ePvOCUbGlnyRrPlTvDi6tib6Fgb3UG7/mvWnLrEFHmp/IhZ5ajrBF4DLF8tHMgr3D2qJ0mgQ9iwiCOnZ7uWD3grSszmnqIeE4Rj8Cg48AsXPCoY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QD81rSuJ; arc=none smtp.client-ip=209.85.160.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QD81rSuJ" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-221822a7dc7so914232fac.3 for ; Fri, 29 Mar 2024 07:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711724157; x=1712328957; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vs13IV4o1jDjBU3SuR7/cEsZjlsaAJ4yfEzh55jmKHc=; b=QD81rSuJqsVTfMm6X2YSqo6Ua7oQBw4B7qjNKgdDeAQK6WuUJJ/Lq3Q2TY6voP7cxh e2qAOW3g35T6U6niNlH6A9DLAotyInLwqDSDOcGPH0YR0QQXwUHFky2Gzde/5XnRCf9z yfqSrivCPDQlN1ZI0q+QmkZ2Sq35/MEaWNZnwhZK2nLWEJq9xFhRA3bSwLNwU7f+mW4Y tz+DUwp+QeYuUPpChkm+c7arXBQMb89tI0+X2xHUu0gmS47vcaXXeS6kouoI+9TdR/CK wb1IJ0vbO10jm5SMIajFdJOWl+0qyQQSuMYv3hNKMH3/TQujhjXV0Eq/L7bv6kzXzR8p v7nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711724157; x=1712328957; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vs13IV4o1jDjBU3SuR7/cEsZjlsaAJ4yfEzh55jmKHc=; b=I9x47eS3BmaCrZeY5qGqR4GUlxSpfIIYIzaM/Nayr0URIFRH6A1ziaMf0jMGU3OeOM JqtHpngKeu3RHLWyNqIEeX+QlN7IhUBk+TJFnJl6kZpuUjeZIMItUIqn4UuLUgOqGCAg ov3VX3+ZZxHjEbiCyJY4Nb0beehxbVvkhfMwOEzKON0pdNiC0ZqSxRrNqI0lt8XPHpDh 5xseh0/guZAjucwXuu/L6Mx4VkHd0kv1tlIefwA1FtwbJnIluSaqddk3Q4UjzslSt37t dt2ICrTF17/WYsaAtXdHy45Y1PvHQWx45yEeZC8DGT1bp1VvEQhtGNKkYpw13BlZN2LH joNw== X-Forwarded-Encrypted: i=1; AJvYcCUpkFwrB5nJ6QXW3thNDtlUmijCxpb5gAuLazc/2h0t4KviT65eVktyYoz7vtW4Hgo2bQekxUq2//N0MO6+O8xmkxZ56IxLbdsl9Q== X-Gm-Message-State: AOJu0YwCDGcbBi7xJSiikIHo19GFGobyf/4dMjTOm4Mi9iGf1RjV+Ogm PWBJ8OeThV/ASb9Nppdh2X42y+8mGGm9gybJG3tTrlPxCyIs1uwo66wGOaZQLGw= X-Google-Smtp-Source: AGHT+IHhauMxhn55RvcmIkpehXMENQlbJtbC2+Gf+1A6OJYgZKTTefWdpyZy72vAqgHreF/V7HaxfQ== X-Received: by 2002:a05:6870:2f08:b0:222:619f:950f with SMTP id qj8-20020a0568702f0800b00222619f950fmr2346248oab.41.1711724156930; Fri, 29 Mar 2024 07:55:56 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-75b6-1a40-9b4e-0264.res6.spectrum.com. [2603:8081:1405:679b:75b6:1a40:9b4e:264]) by smtp.gmail.com with ESMTPSA id fl9-20020a056870494900b0022a58ffa4a3sm1006249oab.23.2024.03.29.07.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:55:56 -0700 (PDT) From: Bob Pearson To: yanjun.zhu@linux.dev, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-next v3 05/12] RDMA/rxe: Remove save/rollback_state in rxe_requester Date: Fri, 29 Mar 2024 09:55:08 -0500 Message-ID: <20240329145513.35381-8-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329145513.35381-2-rpearsonhpe@gmail.com> References: <20240329145513.35381-2-rpearsonhpe@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that req.task and comp.task are merged it is no longer necessary to call save_state() before calling rxe_xmit_pkt() and rollback_state() if rxe_xmit_pkt() fails. This was done originally to prevent races between rxe_completer() and rxe_requester() which now cannot happen. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_req.c | 40 ++--------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index 31a611ced3c5..e20462c3040d 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -573,30 +573,6 @@ static void update_wqe_psn(struct rxe_qp *qp, qp->req.psn = (qp->req.psn + 1) & BTH_PSN_MASK; } -static void save_state(struct rxe_send_wqe *wqe, - struct rxe_qp *qp, - struct rxe_send_wqe *rollback_wqe, - u32 *rollback_psn) -{ - rollback_wqe->state = wqe->state; - rollback_wqe->first_psn = wqe->first_psn; - rollback_wqe->last_psn = wqe->last_psn; - rollback_wqe->dma = wqe->dma; - *rollback_psn = qp->req.psn; -} - -static void rollback_state(struct rxe_send_wqe *wqe, - struct rxe_qp *qp, - struct rxe_send_wqe *rollback_wqe, - u32 rollback_psn) -{ - wqe->state = rollback_wqe->state; - wqe->first_psn = rollback_wqe->first_psn; - wqe->last_psn = rollback_wqe->last_psn; - wqe->dma = rollback_wqe->dma; - qp->req.psn = rollback_psn; -} - static void update_state(struct rxe_qp *qp, struct rxe_pkt_info *pkt) { qp->req.opcode = pkt->opcode; @@ -676,8 +652,6 @@ int rxe_requester(struct rxe_qp *qp) int opcode; int err; int ret; - struct rxe_send_wqe rollback_wqe; - u32 rollback_psn; struct rxe_queue *q = qp->sq.queue; struct rxe_ah *ah; struct rxe_av *av; @@ -799,9 +773,6 @@ int rxe_requester(struct rxe_qp *qp) pkt.mask = rxe_opcode[opcode].mask; pkt.wqe = wqe; - /* save wqe state before we build and send packet */ - save_state(wqe, qp, &rollback_wqe, &rollback_psn); - av = rxe_get_av(&pkt, &ah); if (unlikely(!av)) { rxe_dbg_qp(qp, "Failed no address vector\n"); @@ -834,10 +805,6 @@ int rxe_requester(struct rxe_qp *qp) if (ah) rxe_put(ah); - /* update wqe state as though we had sent it */ - update_wqe_state(qp, wqe, &pkt); - update_wqe_psn(qp, wqe, &pkt, payload); - err = rxe_xmit_packet(qp, &pkt, skb); if (err) { if (err != -EAGAIN) { @@ -845,11 +812,6 @@ int rxe_requester(struct rxe_qp *qp) goto err; } - /* the packet was dropped so reset wqe to the state - * before we sent it so we can try to resend - */ - rollback_state(wqe, qp, &rollback_wqe, rollback_psn); - /* force a delay until the dropped packet is freed and * the send queue is drained below the low water mark */ @@ -859,6 +821,8 @@ int rxe_requester(struct rxe_qp *qp) goto exit; } + update_wqe_state(qp, wqe, &pkt); + update_wqe_psn(qp, wqe, &pkt, payload); update_state(qp, &pkt); /* A non-zero return value will cause rxe_do_task to From patchwork Fri Mar 29 14:55:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13610694 X-Patchwork-Delegate: jgg@ziepe.ca Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF4AF14B08A for ; Fri, 29 Mar 2024 14:55:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724160; cv=none; b=WQOnRCR21Rru+QZF3PZS6uv1wU9L1ADGmySisnHDkhvGPsNPaUUml7UQrloH5Ts9yMwDO/Bzi0fJEEVWzf7p+M86ko3iT/6Qae+XLhadkwvlqJF5DKyDlYX7ckEEhdAzOJuYXrlyHzYgNI0Ejv70cp5VG0odcxzgLspJ18lepRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724160; c=relaxed/simple; bh=nK/eWvmC9NoeXAd3HPKwxgaAueONSiU99ZwEabcO0kc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WwYImDgyW4W/dY7//aFipGJrd8Ll/AV0Y24OrEh0XnQfNEstEirb1klpNLlVCpnniE5ZxfUaM9/oe6GSAKzXiNEBwlQBg9p1+MTR1ZyeetoRLwEnWZ2gdsFDuqCgEQdpSRsSQm6k6h3TtTjhEDI3qV2ICdnZtrgI8xKiBZVSJRA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KzlRdssF; arc=none smtp.client-ip=209.85.160.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KzlRdssF" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-22215ccbafeso1122882fac.0 for ; Fri, 29 Mar 2024 07:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711724158; x=1712328958; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2nS56B9R0MASjlXMNQV3RCH6VoFkteo8/PCt+i+tEO8=; b=KzlRdssFy0iGn1KukSGELbtSIIzLHADOMHH546MN0VrUV+HuFboxxd68Cp1Rh13ewr OAJ1pdOBHONsqGi/kGFHeqoxfLovlNkCb5EGES9OUY7itFGT6U8T4MrF67jB8fZ7tciC 7JgBl1yh8qa9tR533uYMf9PIKNjR4Xdtyy8BXQg0bYCGvL7wh5jZ29IsqEMWnecUpvbs CAk0aw8zD/glLGjZZwI5ZXJeTgKL21VQ7LKpbh3FlOVKrD1YhY6EQpZLSlaQ/49YIlVy 6nTHLyej5EAYYjuy9Vh6WaZ0/rTLV5aA5q2tSnK9svebPMzD5ve5cVv0OegumACWdr0j /h6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711724158; x=1712328958; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2nS56B9R0MASjlXMNQV3RCH6VoFkteo8/PCt+i+tEO8=; b=v0gKQeo1P0okjrJBIzE0gVdofTOXzh0PPopHhkM4djUg4J5vmy9fZa1PJnKZzvFW8M D416EwpSEPsL9op/dl3QBdbxAUSJcymxLiIbyu99ArCxc7QmfeF1cMW2fW028ZIlUcAA Uni1WUjXWqYYgw+Q+eV0yoQncg+YGFFRHaKejBXe8m9SsA7Mmux+/vHRR2Mejtii35Jl 9b1vM4CLrqKlWBp7D0KB217H/3wbBOZf1BAbs/b73dCI0lnjd7YXifqve21c3es1N0Kg Hzim8crZJ1E04THbKtW4Mnt8IsaN764UyfDVG4MGOkQg4uQXE7sZNqHQ8rs5S9ekYGVe rX/w== X-Forwarded-Encrypted: i=1; AJvYcCX7uPby9YLshBSoExckFkEFPyJlmRRobcl4uLf4qZTust70DEqWqSFIfOcLwVm7MSLW8w6TXcPTrFb3x2HwzZTYdIPYucuPbhZCQg== X-Gm-Message-State: AOJu0YwCRZXnsiwP3/zgM+KnLzSYZUAmxik0vanMgLMDMQmfKxfL0Qct w61qxyFLWiJjUIUQhjcUtS0Cs/VtMfDcM1fF8xmO5uwMuazmfLmo X-Google-Smtp-Source: AGHT+IGu50oy444FxyD3P6hMuI1LF4S5SGlvrdrFk5LYSZubzIASQYUXV1cDd+4VhgxeKAz0TzY4qQ== X-Received: by 2002:a05:6871:1c2:b0:22a:5bae:9cd5 with SMTP id q2-20020a05687101c200b0022a5bae9cd5mr2472866oad.48.1711724157819; Fri, 29 Mar 2024 07:55:57 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-75b6-1a40-9b4e-0264.res6.spectrum.com. [2603:8081:1405:679b:75b6:1a40:9b4e:264]) by smtp.gmail.com with ESMTPSA id fl9-20020a056870494900b0022a58ffa4a3sm1006249oab.23.2024.03.29.07.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:55:57 -0700 (PDT) From: Bob Pearson To: yanjun.zhu@linux.dev, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-next v3 06/12] RDMA/rxe: Don't schedule rxe_completer from rxe_requester Date: Fri, 29 Mar 2024 09:55:09 -0500 Message-ID: <20240329145513.35381-9-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329145513.35381-2-rpearsonhpe@gmail.com> References: <20240329145513.35381-2-rpearsonhpe@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that rxe_completer() is always called serially after rxe_requester() there is no reason to schedule rxe_completer() from rxe_requester(). Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_net.c | 6 ------ drivers/infiniband/sw/rxe/rxe_req.c | 9 ++------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index 928508558df4..a2fc118e7ec1 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -440,12 +440,6 @@ int rxe_xmit_packet(struct rxe_qp *qp, struct rxe_pkt_info *pkt, return err; } - if ((qp_type(qp) != IB_QPT_RC) && - (pkt->mask & RXE_END_MASK)) { - pkt->wqe->state = wqe_state_done; - rxe_sched_task(&qp->send_task); - } - rxe_counter_inc(rxe, RXE_CNT_SENT_PKTS); goto done; diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index e20462c3040d..34c55dee0774 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -545,6 +545,8 @@ static void update_wqe_state(struct rxe_qp *qp, if (pkt->mask & RXE_END_MASK) { if (qp_type(qp) == IB_QPT_RC) wqe->state = wqe_state_pending; + else + wqe->state = wqe_state_done; } else { wqe->state = wqe_state_processing; } @@ -631,12 +633,6 @@ static int rxe_do_local_ops(struct rxe_qp *qp, struct rxe_send_wqe *wqe) wqe->status = IB_WC_SUCCESS; qp->req.wqe_index = queue_next_index(qp->sq.queue, qp->req.wqe_index); - /* There is no ack coming for local work requests - * which can lead to a deadlock. So go ahead and complete - * it now. - */ - rxe_sched_task(&qp->send_task); - return 0; } @@ -760,7 +756,6 @@ int rxe_requester(struct rxe_qp *qp) qp->req.wqe_index); wqe->state = wqe_state_done; wqe->status = IB_WC_SUCCESS; - rxe_sched_task(&qp->send_task); goto done; } payload = mtu; From patchwork Fri Mar 29 14:55:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13610695 X-Patchwork-Delegate: jgg@ziepe.ca Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BA0D14B07F for ; Fri, 29 Mar 2024 14:55:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724161; cv=none; b=WXN1rbkrTlSCm2zsZdYWJfev5IyEB6IkLvmJZhKm3RJ8gEfNfNey4+T7T324kheYrskAgJ9h25rnYKHxZmKnAZBJYVXOxdgzQ24DgM4hON1j/2Y80jqQsLumgnGvizf2dt0OL3MwnFFbVsss1F7lwK14wYH1rwkDa2fVm90zfUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724161; c=relaxed/simple; bh=3Lsdl3bUk1eghZI7pfT2uqcGv1yrMB6KXmFLotShHrA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A8tmPe5nuO2/29hz1lHfrr6Ul/YAD55C8Prbpia7zbBs72/ZCmIFQkN5N64dRYeYmKue/mlFcL69Hq/59UJMlG3Zulb6KroLWCyQt8RXPKY4jFfNPk56KA+Qtnzpn7krOlLnjzeIWRbGLXXpf4SjbsdRd00vx4aVpFneiwwQbfo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=P2gOIIXV; arc=none smtp.client-ip=209.85.210.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P2gOIIXV" Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6e6d0bf038fso971993a34.0 for ; Fri, 29 Mar 2024 07:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711724159; x=1712328959; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XIzk7mNVCul3dJBEzUlME8AqbvH1WAEWuhcv1rlDPV8=; b=P2gOIIXV83HlLqcrI3ZL0n4GiN+FWmv9XqinVkDGMb61VIBcb0aHldClpZsZeFYDE8 rxC8un2i7TsmepJgUSvQmNXI0KT1bucElzXpvd5CwjvL2cyF8RCxKoDlYKrdTgX97dMH 6utU8esIYow6P6UdOwkzY2Ud8gqcTnSC3pv5EE9PBojxp8r6m20nnndpiyzSsjaR6L6l MqVl6j90wI+T5X9VkVNHrQ1K5tTQuHj5cGqlGliX9kdNEW7MjAtQlZa6Yt1rRi+kbnha rLaMfrh7myMh+3dczr5NKkAI8rE9dSsywj/fHj4vX3kMKV2mnXYjEdXx5KoUXCnypjUk jmxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711724159; x=1712328959; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XIzk7mNVCul3dJBEzUlME8AqbvH1WAEWuhcv1rlDPV8=; b=XFDexT3dPSAvyjHvyQBUYuRottsfSnnn6nHdikkGZ08vnODmr8zC6u9vbx6s/2SakW +LCrD2gHUf46Nm1eGf1oGKjTa3KL8LzARXhMUNBLhYmDDKDdXSX+B6l30Yhhn7MTwxoY oB7eb5liXRHp9I4jaYA9Kjm2ETQzHKzzDuqkQ1gKimU9+7EsP5MSRjGiq3w64O079nE9 oUMq4rZmEg3awmg1uUBDqyZ68Uj0KkfWhKDq1fDkAKF7LBhlYze244V1R6ucR29Fnf7D XvmHg2yZv18OHvw9IscKu7sTnfbROAwUmiOCGp1DiR0u1am+PqsYFqYp3ttUfYYBcCRy eEHA== X-Forwarded-Encrypted: i=1; AJvYcCVQMH4mehLB0xT3o6S4YCBaoLg4UcyIv1gWp0f8oUskZRC7tP5aUdpYtlNhEqm4JfRVsr1OL0lA4LLT8k7JRJGV8odsodnc5NSEog== X-Gm-Message-State: AOJu0YyhZOC/kNzG6PhpjOzdBlSESefpFY45o3KIki6M6qjRfk8jnGci HBEHT/rQz3u9uK0iOYjom+Rs2Wnuk4u3p0kPTqul+Cn21Bb200qj X-Google-Smtp-Source: AGHT+IGiuBzf0EutxnDtNlTGzC/2S/B+gz+24rHdO4Bpkh07Y9vGAX2aH0DAXQRrfrNmNP3qq67CYg== X-Received: by 2002:a05:6870:5314:b0:22a:a167:50fe with SMTP id j20-20020a056870531400b0022aa16750femr2682809oan.3.1711724159109; Fri, 29 Mar 2024 07:55:59 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-75b6-1a40-9b4e-0264.res6.spectrum.com. [2603:8081:1405:679b:75b6:1a40:9b4e:264]) by smtp.gmail.com with ESMTPSA id fl9-20020a056870494900b0022a58ffa4a3sm1006249oab.23.2024.03.29.07.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:55:58 -0700 (PDT) From: Bob Pearson To: yanjun.zhu@linux.dev, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-next v3 07/12] RDMA/rxe: Don't call rxe_requester from rxe_completer Date: Fri, 29 Mar 2024 09:55:10 -0500 Message-ID: <20240329145513.35381-10-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329145513.35381-2-rpearsonhpe@gmail.com> References: <20240329145513.35381-2-rpearsonhpe@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of rescheduling rxe_requester from rxe_completer() just extend the duration of rxe_sender() by one pass. Setting run_requester_again forces rxe_completer() to return 0 which will cause rxe_sender() to be called at least one more time. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_comp.c | 17 ++++++++++------- drivers/infiniband/sw/rxe/rxe_verbs.h | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index ea64a25fe876..357c1d516efb 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -325,7 +325,7 @@ static inline enum comp_state check_ack(struct rxe_qp *qp, qp->comp.psn = pkt->psn; if (qp->req.wait_psn) { qp->req.wait_psn = 0; - rxe_sched_task(&qp->send_task); + qp->req.again = 1; } } return COMPST_ERROR_RETRY; @@ -476,7 +476,7 @@ static void do_complete(struct rxe_qp *qp, struct rxe_send_wqe *wqe) */ if (qp->req.wait_fence) { qp->req.wait_fence = 0; - rxe_sched_task(&qp->send_task); + qp->req.again = 1; } } @@ -515,7 +515,7 @@ static inline enum comp_state complete_ack(struct rxe_qp *qp, if (qp->req.need_rd_atomic) { qp->comp.timeout_retry = 0; qp->req.need_rd_atomic = 0; - rxe_sched_task(&qp->send_task); + qp->req.again = 1; } } @@ -541,7 +541,7 @@ static inline enum comp_state complete_wqe(struct rxe_qp *qp, if (qp->req.wait_psn) { qp->req.wait_psn = 0; - rxe_sched_task(&qp->send_task); + qp->req.again = 1; } } @@ -654,6 +654,8 @@ int rxe_completer(struct rxe_qp *qp) int ret; unsigned long flags; + qp->req.again = 0; + spin_lock_irqsave(&qp->state_lock, flags); if (!qp->valid || qp_state(qp) == IB_QPS_ERR || qp_state(qp) == IB_QPS_RESET) { @@ -737,7 +739,7 @@ int rxe_completer(struct rxe_qp *qp) if (qp->req.wait_psn) { qp->req.wait_psn = 0; - rxe_sched_task(&qp->send_task); + qp->req.again = 1; } state = COMPST_DONE; @@ -792,7 +794,7 @@ int rxe_completer(struct rxe_qp *qp) RXE_CNT_COMP_RETRY); qp->req.need_retry = 1; qp->comp.started_retry = 1; - rxe_sched_task(&qp->send_task); + qp->req.again = 1; } goto done; @@ -843,8 +845,9 @@ int rxe_completer(struct rxe_qp *qp) ret = 0; goto out; exit: - ret = -EAGAIN; + ret = (qp->req.again) ? 0 : -EAGAIN; out: + qp->req.again = 0; if (pkt) free_pkt(pkt); return ret; diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index af8939b8c7a1..3c1354f82283 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -113,6 +113,7 @@ struct rxe_req_info { int need_retry; int wait_for_rnr_timer; int noack_pkts; + int again; }; struct rxe_comp_info { From patchwork Fri Mar 29 14:55:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13610696 X-Patchwork-Delegate: jgg@ziepe.ca Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04F2E14B08A for ; Fri, 29 Mar 2024 14:56:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724162; cv=none; b=JvorylgnRchC/c3S2q0xjpnVzEjjtlaNZFAnr2SKSwjVRMepuSWkWjHPTuRSGHtY7+HZjjmLMwRRG1yqpOuYm5j9VMHjjciTToDTTHn/m0FlUSCVtQ+pXPJRrhnGoLhV0Xb2WF+aZYA+NojvMaOLu8/zkI10mNqbkioyP+TDe44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724162; c=relaxed/simple; bh=PT3Hyfl2+cjTVzOKRQDvmFYUsqsoFkkSrYuXVUTmopA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i8xNW7WKZNyfUoLlJ//NyFqQE4oWS3p3fDwOkEyJcGaw6c3lhA1YjPLYcg76ZYi67meYrX1zq3PwII59phAJBQ+F1ETDyYyAEG01pH6Vx602XkYSnYqqpUt+8CTABNxrO4vVtnxJAAPzLjEuGYkVoyM0FOqEXotDTmQmvsaJJ34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RV1RoVkK; arc=none smtp.client-ip=209.85.210.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RV1RoVkK" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6e673ffbd79so1187289a34.2 for ; Fri, 29 Mar 2024 07:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711724160; x=1712328960; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gozE0JJHyUjE/6EGOn8n1lFvwBFFZIhulDryp2rMcl0=; b=RV1RoVkKPFjfDhj46tnnMKfGmAfAK7I3VcDyK2pSq9bpknf4O1lM7LFSgVJPxdSOxN uEei9danvYngfqpl95zth61M/UQnSX7O5/fBPzbUJKN6eKGH40w+0tx4mbTkKgEHrBQ6 koYtWHvUmDRVmmBNrPCYDhbBh89gVfNsmPaA5XcVMdrALFUKpuUFmUot4f6aU2rh5e20 UgeK08U1tF6rQfQsc4WBD22I31LJE74Z/XIHZAwlzC2dCG1ZpLwWQbMseh5qC589Ujir u4mX4XHLcbnywVWfOZY0cmcN4TjYeTgdfq1mXMjLjjfz54pwQq6pfsl+drLoCR4gs6xf JIuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711724160; x=1712328960; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gozE0JJHyUjE/6EGOn8n1lFvwBFFZIhulDryp2rMcl0=; b=Qt6nRQV0Szq1yDpbiN7Ai5glSiW4V7odod1PTq5afJPwt3o/NsVtYa+uCN6JFP+M2T 32AwYm+rTpf2GAuL7D4Go0Abcy7ZtOkeOTVCGIIVKD5kxkGpeep3p+jISfQuX/+F/Vq6 62GlKN6Zxwm/airiZJVL0t5NvpFktvwpn7uBtoPSPWrtt4WXPXo0UkBBX/LiM0P/6TCI m+43VeRPevkznNIHWJ1xu9gfQvOMM0rJO/VxCDXyd3vvcWdwrAkaJCr4yvoodh2/P6Rm IKIxyl+JSwoMUGDgYBB9qtt4yeYQf3Oi0lUZQ5vyBLmN1G2Up8tG5tPMoEvDbF79o0/0 DHuA== X-Forwarded-Encrypted: i=1; AJvYcCWi9FOGhm8rMcWJpZmW2lvCbxYmPyezI/9ajhdVdh0FiT8wG8gTHoAOaQWPkzpVVEvbfM/kyBd19V+lLmpuHK+PIOReSI30gkeA+g== X-Gm-Message-State: AOJu0YwMZF/GQ9dYDBvUMMzTlZ1Ez2cFVsjPZi4SRXazRtg6IlUuRbm/ y+lOMm/tlizUssNHBGXTaI1syz6JDm0UhKpDbp/hbeO0viDDOcR2hBFNCvKPKeE= X-Google-Smtp-Source: AGHT+IEpVm1xPMmRSMNFtP2iitIXjDd93xaV9t14C+VxX2f/q573l7oT8hi+gQ9k8tU1+4wIbtgksQ== X-Received: by 2002:a05:6870:a1a0:b0:22a:a17d:e19 with SMTP id a32-20020a056870a1a000b0022aa17d0e19mr2692331oaf.15.1711724160072; Fri, 29 Mar 2024 07:56:00 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-75b6-1a40-9b4e-0264.res6.spectrum.com. [2603:8081:1405:679b:75b6:1a40:9b4e:264]) by smtp.gmail.com with ESMTPSA id fl9-20020a056870494900b0022a58ffa4a3sm1006249oab.23.2024.03.29.07.55.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:55:59 -0700 (PDT) From: Bob Pearson To: yanjun.zhu@linux.dev, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-next v3 08/12] RDMA/rxe: Don't call direct between tasks Date: Fri, 29 Mar 2024 09:55:11 -0500 Message-ID: <20240329145513.35381-11-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329145513.35381-2-rpearsonhpe@gmail.com> References: <20240329145513.35381-2-rpearsonhpe@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace calls to rxe_run_task() with rxe_sched_task(). This prevents the tasks from all running on the same cpu. This change slightly reduces performance for single qp send and write benchmarks in loopback mode but greatly improves the performance with multiple qps because if run task is used all the work tends to be performed on one cpu. For actual on the wire benchmarks there is no noticeable performance change. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_comp.c | 13 ++----------- drivers/infiniband/sw/rxe/rxe_resp.c | 12 +----------- drivers/infiniband/sw/rxe/rxe_verbs.c | 2 +- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index 357c1d516efb..d48af2180745 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -129,18 +129,9 @@ void retransmit_timer(struct timer_list *t) void rxe_comp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb) { - int must_sched; - - must_sched = skb_queue_len(&qp->resp_pkts) > 0; - if (must_sched != 0) - rxe_counter_inc(SKB_TO_PKT(skb)->rxe, RXE_CNT_SENDER_SCHED); - + rxe_counter_inc(SKB_TO_PKT(skb)->rxe, RXE_CNT_SENDER_SCHED); skb_queue_tail(&qp->resp_pkts, skb); - - if (must_sched) - rxe_sched_task(&qp->send_task); - else - rxe_run_task(&qp->send_task); + rxe_sched_task(&qp->send_task); } static inline enum comp_state get_wqe(struct rxe_qp *qp, diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c index 3ce7a32b5dcf..c6a7fa3054fa 100644 --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -49,18 +49,8 @@ static char *resp_state_name[] = { /* rxe_recv calls here to add a request packet to the input queue */ void rxe_resp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb) { - int must_sched; - struct rxe_pkt_info *pkt = SKB_TO_PKT(skb); - skb_queue_tail(&qp->req_pkts, skb); - - must_sched = (pkt->opcode == IB_OPCODE_RC_RDMA_READ_REQUEST) || - (skb_queue_len(&qp->req_pkts) > 1); - - if (must_sched) - rxe_sched_task(&qp->recv_task); - else - rxe_run_task(&qp->recv_task); + rxe_sched_task(&qp->recv_task); } static inline enum resp_states get_req(struct rxe_qp *qp, diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index d07f7bd3b2ae..c7d4d8ab5a09 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -935,7 +935,7 @@ static int rxe_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr, if (qp->is_user) { /* Utilize process context to do protocol processing */ - rxe_run_task(&qp->send_task); + rxe_sched_task(&qp->send_task); } else { err = rxe_post_send_kernel(qp, wr, bad_wr); if (err) From patchwork Fri Mar 29 14:55:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13610697 X-Patchwork-Delegate: jgg@ziepe.ca Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D311814BF8C for ; Fri, 29 Mar 2024 14:56:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724163; cv=none; b=os50ad3ADte3E45c9vm9ceDzZ2bqYbD2ydFcfe0H5psfYvIomRiF6E/WGZ3v3S6I4Y86nX+EPt628P3+wjfzPhFYuSh+BaTKbDHQtEf2BFTrtgKUVN3oMiyuQMBxSFTQWPf0Oq941Papd6jF+u9LUn9RVgNm1kcAUt8TcBGlmwU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724163; c=relaxed/simple; bh=0Pa2bP02dZ3ETe2IeoQTHbmUTpw9EjmdiMWm3SVmSbQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kF7EQQDmnTUDzimB1CjpMXaf7Qsk0dkKflRcRNZnYfl8xIwDgwuYt/ZdlX3ZJwb/QZjfIezYcC1yTzC6kzVQ65iFwS97fOu6plcN0S8bQcbwOf7p4R5kUs/ZYds3dOYVmlBmSXCUGG+BNDglO6ncQCRNhEU/otfBKzwRhBOvQgI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZXSemJYJ; arc=none smtp.client-ip=209.85.160.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZXSemJYJ" Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-22215ccbafeso1122916fac.0 for ; Fri, 29 Mar 2024 07:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711724161; x=1712328961; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gbUgPeO40G8+rE2YU4GHNiFgO5GLJpSIYCgoppaAmmA=; b=ZXSemJYJ3Qfj9og33SdtJy0gWN1WWX4UtGAchGwiIlGkfJJrt0pxQH6pj7jfp8jjmr J2V8SJu5t7WLuEt5S4JbNUqRUx5pI0BkstnbBuHcYIMjr/NrQwMNYsR4afb50hRD3EGl ZOgTn/+aoWCH0sARJxWCr0qtVXjqnuFm9e/hU9YCUY0k3Y5oTDEwc6EjrBqXZu3rZULO 1ELgqrwNXK5F3zx+UNloN4/ocw6KWKV6Pxl+xUl2ZXCJfF+Qi7vpK6nbIFSubieSBrHj 66mQDYZ/WumDNH7DIvaMxaTe7TJeym6N4Kby1uLOz+DNM/D35y+cU4hGO5L/0z5kkqf6 +KEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711724161; x=1712328961; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gbUgPeO40G8+rE2YU4GHNiFgO5GLJpSIYCgoppaAmmA=; b=q4jEZWgY97x8jTOSOkqI5H72u49+Q2dIeqDX7FEB52+Js4IowQULp/Yij0onOKYelp YLmNWUnL/rQtW87MIF4lAF6bhkCgXxUvpYHvy0yy2PTmWLd9APyZsqzwT2wsmKuxOyDg B9D3S7lduGWjyrRMhKsGMuOZpLQDXkwI6Q/5oNvRYPTn1G9FaLYvg5Mj0WjbatK5S4oq K4tqz9rHYtGc2NhKoPf+VqzMelLk+T2Y/tlqm7xOH61Abv39Tla0KiRrgCDqkK4mJ25J Yi1lHbcs80KWNRUryVN8wKJ5fyUFyz7kSn6TmgqFnz8QNL6/jIYftbcwrcch1QfjdciB XAGA== X-Forwarded-Encrypted: i=1; AJvYcCVlcjLIEcMZ/n/KBpf7y7QKBxdbDfyRrSshuCMl0VwdruZeMIWNhjTyXlhk+XNU7xI77wm62jNR+frdJDhT8DpCEtncUc5lPY4FHA== X-Gm-Message-State: AOJu0YzTcrC/CyXWnp+8/0TzryniiuYoMh2yzoOxNJuVnJUevp270Skw QgOR27Np7AnNxCC1V9Z7ZXYTj3tK4I8OR3+Fo9Fe2cXaeDgojzos X-Google-Smtp-Source: AGHT+IGa4Q9TTSkvmHQ2j5eVYxopkhfURKKtGAC47IaVqLhOIu/axe0aQd5VgU/tCGIgF6RCKMVU2g== X-Received: by 2002:a05:6871:8789:b0:22a:4c05:2efd with SMTP id td9-20020a056871878900b0022a4c052efdmr2593691oab.10.1711724160987; Fri, 29 Mar 2024 07:56:00 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-75b6-1a40-9b4e-0264.res6.spectrum.com. [2603:8081:1405:679b:75b6:1a40:9b4e:264]) by smtp.gmail.com with ESMTPSA id fl9-20020a056870494900b0022a58ffa4a3sm1006249oab.23.2024.03.29.07.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:56:00 -0700 (PDT) From: Bob Pearson To: yanjun.zhu@linux.dev, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-next v3 09/12] RDMA/rxe: Fix incorrect rxe_put in error path Date: Fri, 29 Mar 2024 09:55:12 -0500 Message-ID: <20240329145513.35381-12-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329145513.35381-2-rpearsonhpe@gmail.com> References: <20240329145513.35381-2-rpearsonhpe@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In rxe_send() a ref is taken on the qp to keep it alive until the kfree_skb() has a chance to call the skb destructor rxe_skb_tx_dtor() which drops the reference. If the packet has an incorrect protocol the error path just calls kfree_skb() which will call the destructor which will drop the ref. Currently the driver also calls rxe_put() which is incorrect. Additionally since the packets sent to rxe_send() are under the control of the driver and it only ever produces IPV4 or IPV6 packets the simplest fix is to remove all the code in this block. Signed-off-by: Bob Pearson Fixes: 9eb7f8e44d13 ("IB/rxe: Move refcounting earlier in rxe_send()") --- drivers/infiniband/sw/rxe/rxe_net.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index a2fc118e7ec1..d81440038f91 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -366,18 +366,10 @@ static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt) rxe_get(pkt->qp); atomic_inc(&pkt->qp->skb_out); - if (skb->protocol == htons(ETH_P_IP)) { + if (skb->protocol == htons(ETH_P_IP)) err = ip_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb); - } else if (skb->protocol == htons(ETH_P_IPV6)) { + else err = ip6_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb); - } else { - rxe_dbg_qp(pkt->qp, "Unknown layer 3 protocol: %d\n", - skb->protocol); - atomic_dec(&pkt->qp->skb_out); - rxe_put(pkt->qp); - kfree_skb(skb); - return -EINVAL; - } if (unlikely(net_xmit_eval(err))) { rxe_dbg_qp(pkt->qp, "error sending packet: %d\n", err); From patchwork Fri Mar 29 14:55:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13610698 X-Patchwork-Delegate: jgg@ziepe.ca Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA46D14BF94 for ; Fri, 29 Mar 2024 14:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724164; cv=none; b=GgsOAuaUIo8kCwE80/oySjuV58VxtfEjog2QM338tKpmYMTfO5pdRzfc5EkxovupWpFc/F4EcCb6+woQ2PffhE4U5U5guFgCtM3wXJtNfHAnJ06utFO79V0qQVuIel5mGvvyiPC6KMye8vqjDw0/YKikkMY7j+4agMebWwpUmZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724164; c=relaxed/simple; bh=X2q6wbjrbnUuC0airwdkQF2e6eqr3hWQJS/qlRR1dXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DslGcoPP13m/vDRUPcpFKMTCO9hXj3GpIfMBwxGA2VSKqbrJt6BnLPBIFI0Ut8Q8e1eIWnYGL41TFEDAyc71AjQprwNrywXHtz9yz/KMNagmbi1in40Cyjza8iAkEeNkZzkUPNSpvPLF+zAq/arQxPl9mBmciKJ09Xp8CrwUeW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ckGqu6fQ; arc=none smtp.client-ip=209.85.167.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ckGqu6fQ" Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3c36ecdb8cdso949326b6e.1 for ; Fri, 29 Mar 2024 07:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711724162; x=1712328962; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vWAslbWFX1XOSWwHcgJy6hHbIvWl+oqLgvo/gLbrYpc=; b=ckGqu6fQx3FUN1zvLYFK8t1Fn9L+e7MGxb/qQZRo+ncyaNWWhtF7j/eUY8S4cSuUOE FaTYb2W+ZcJGVJOKdNOWz1n0jIpGMqnhPhmvKf4ESzqvqlovm5Xm0GSUBzsQn3K/Kqb/ /S39RFE3XTJl/4K6hoo8WefbOTGViN/vbWPFnjQXkrAVogLdDEe7G7FnbhT7n14aEkml w1TYXj0qNlmKwMHD4ylJL71zOGAtfzdXHuLpC+xWe7A0Rv5zoSFQTorzeglzVwaG6vos HMGDtXZOt3ta+G/20D5JObxkPPBUVdHSx96Z5xFNMdV7wZq7A919qlbez/xVB0Kd3AzX pyFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711724162; x=1712328962; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vWAslbWFX1XOSWwHcgJy6hHbIvWl+oqLgvo/gLbrYpc=; b=gQ35PKmgHN0NUZAl/MyB77QDXAhjTnoD5/LUViYP6ddJgoKP/AL7QsbOuYkvMQrPFO ZIPF/bXxafHTAMx8KsvDg++HNjN+8lZVfSmirBK49EswTgruSWoMLhQds2U3dRrHHmFx 15a1nQIc9fSNnBzBOsBFsJUtouoTi7x8ji1elXyH2j/pGP9l3lIDlTJcACPooM4KIUak 88a0lUxdNlurf9YmUFEEUU3TaYOcjattLyK9M/9cg03sMUzby7gKjSNqnRDjl+ODz9tT ikTZ/D3IkQ+icY4u2Hk29e4DOexPUeICSROegU2hzpXYZ7lM15lO5tIj6NKK43MMpXU9 7h0w== X-Forwarded-Encrypted: i=1; AJvYcCX+/CJYSMdqlkr2lHTHn8CUV9PAZcwlR6n3hYAprhpo9URGrxFD0hw29ADSWMqb/WXdTbyIoqVmOt3bCo73HpCu3dw5leIf2sxX9w== X-Gm-Message-State: AOJu0YyFANH3NtZCSWdadrS3gYHnMd1Y6qsCSNWlR1VRnG2yh6TsIl+H RxaynkmRQewUGAwyjNUKwYcLVr1T7YLgxYWdgG1hE7j+7rkXgGvRQj9GnJ+a2TE= X-Google-Smtp-Source: AGHT+IH3veVs052UIhJr4dJDUoTEIxFQkrfv/VgLCS6TELAJe1B8dDdjeXwiWLRSKckLG9TPxHy4kQ== X-Received: by 2002:a05:6871:60b:b0:22c:ba27:7a4d with SMTP id w11-20020a056871060b00b0022cba277a4dmr2476249oan.47.1711724162056; Fri, 29 Mar 2024 07:56:02 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-75b6-1a40-9b4e-0264.res6.spectrum.com. [2603:8081:1405:679b:75b6:1a40:9b4e:264]) by smtp.gmail.com with ESMTPSA id fl9-20020a056870494900b0022a58ffa4a3sm1006249oab.23.2024.03.29.07.56.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:56:01 -0700 (PDT) From: Bob Pearson To: yanjun.zhu@linux.dev, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-next v3 10/12] RDMA/rxe: Make rxe_loopback match rxe_send behavior Date: Fri, 29 Mar 2024 09:55:13 -0500 Message-ID: <20240329145513.35381-13-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329145513.35381-2-rpearsonhpe@gmail.com> References: <20240329145513.35381-2-rpearsonhpe@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The rxe send path currently counts the number of skbs outstanding between the rxe driver and the ethernet driver to prevent too many packets to accumulate waiting to send. This patch makes the local loopback path behave the same way. The loopback path forwards the packets to the receive path which will eventually call kfree_skb on all packets and drop the qp references. This makes the loopback path more useful for software testing. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_net.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index d81440038f91..d081409450a4 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -386,6 +386,12 @@ static int rxe_loopback(struct sk_buff *skb, struct rxe_pkt_info *pkt) { memcpy(SKB_TO_PKT(skb), pkt, sizeof(*pkt)); + skb->destructor = rxe_skb_tx_dtor; + skb->sk = pkt->qp->sk->sk; + + rxe_get(pkt->qp); + atomic_inc(&pkt->qp->skb_out); + if (skb->protocol == htons(ETH_P_IP)) skb_pull(skb, sizeof(struct iphdr)); else From patchwork Fri Mar 29 14:55:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13610699 X-Patchwork-Delegate: jgg@ziepe.ca Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 061C914BF8E for ; Fri, 29 Mar 2024 14:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724165; cv=none; b=vBr/fhnGXxhJA2IKuoDKao2SiqOf9mQdKKVGWaBpfzbt712QuiYpIK9ShQ+qp6d66vVgEt8r50j8Oc1n3vr21aPJ1vBKTVqTKXr2zWdzuedz+ujZGX4Ptt0BKP4s1k0xevnZDJ3FFOwuDRr3ENb24O6JcBfNEN0wKSkd41vyXLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724165; c=relaxed/simple; bh=UZ1/DCPLtR3mduOS71FDyDDnkpBv8+SGmdEPh7DHYY4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kWxV5zCaTlMveLruqMj4IAy5GmXOAUo0U8tzTurMg+Oeb/6QZ2qpd+fOtRYaAv4b3ZdOHHXy6o0VbTsnkK0aeHwjHK0ZxJCimWhl43C92i+XCjmh3sUJFU1TuGmxWkNagcVnZ/8icXTD9pb6J+dnjuoBoViqmyIcstqKG+DAyaE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bI/hul7W; arc=none smtp.client-ip=209.85.160.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bI/hul7W" Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-22a353217c3so1051808fac.1 for ; Fri, 29 Mar 2024 07:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711724163; x=1712328963; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8iLVySYmuqx2nSAqtlxR4y9KeR6C9kAhC4jpyCkS8UA=; b=bI/hul7WlnCeMh38IGlEhpktQK45g3NhdBWuPnvn/XnIqFj5po7B52zUIyXMCs4iBM lb/YnnAUv8Iwa92t+jwPfTwcUIoEK8QOgoS0FewaPYSLSYHqHMOp4oBz1E9+W98fGn8T ROep4GKuygFVtnPSWtFLSmcUEscGJc2QqVrc3TabKhZKoo2cAbjAYt52LpQNd0Vrvx7C zqDLFKlIDWvUq+ygvSLlCra9DoIShBDp1oFml2e5zW0PAVQaFl5M6kKYLx+nLABclTzW IFSrCmtSZU0DjTFmSWfx0HaHSCLbU1qbj9EtRDXz+EaLGQD7djWW/ConMIXoD4ANvy1G lJrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711724163; x=1712328963; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8iLVySYmuqx2nSAqtlxR4y9KeR6C9kAhC4jpyCkS8UA=; b=j9ceVq0XIrAE3g/pngfV+Kn7YXZg75Jmc83kRrF+AnSwgqQwV1GhRf4iqhfgBUQPrt jtvsto7BPIfcec/MDRrOHMShxDs8kqJhfb3q4VSxRbgAbWVmcDyiq/K0EqFuIlloqYY3 D/aK/4djbcV45mFY0gnQ9hNgJ3ZqyLsOyenYrCPPB2pPh5Amaxt3qsCwfGSFcmWPpfEZ 99F+fBg2US2ZEqZx4ZhruUD3+jyfgXTRBs01TSF9WbwyqLQH812N4+kg7hhY/b5N4OKZ DGugtF7bo5+xPSct7GS9cAoeFpBxojGeE3TzDuiRmeyd3raL7aTPeKXjQx9BS5r4qnjt Zqbw== X-Forwarded-Encrypted: i=1; AJvYcCWjnDIrQ3uR3s7rVVtrQjt5vI2cw1tN7393ZTMIpduy41tXs9RrCsKCud9DcyAft2H4VAVi90ofiz71rg8FkzMjYeQUzQYJwI8Asw== X-Gm-Message-State: AOJu0YxaS+ewg/7E8heConLyB3CCWsh5K6Dvv05idWzzeYW3DikW+Q7Q ScCRV/922mz9nnJklGVtsgdpbPS+0/WUP7Z5Pq4pi41X62PZjZUB X-Google-Smtp-Source: AGHT+IGskac9aMgj8cz83DlVRuK9sAHuazojSv622gQgjVGhAsOLb8AfqFhFGZZ6VxBM14KHStHo1Q== X-Received: by 2002:a05:6870:e394:b0:229:800f:3ed6 with SMTP id x20-20020a056870e39400b00229800f3ed6mr2699803oad.36.1711724163232; Fri, 29 Mar 2024 07:56:03 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-75b6-1a40-9b4e-0264.res6.spectrum.com. [2603:8081:1405:679b:75b6:1a40:9b4e:264]) by smtp.gmail.com with ESMTPSA id fl9-20020a056870494900b0022a58ffa4a3sm1006249oab.23.2024.03.29.07.56.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:56:02 -0700 (PDT) From: Bob Pearson To: yanjun.zhu@linux.dev, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-next v3 11/12] RDMA/rxe: Get rid of pkt resend on err Date: Fri, 29 Mar 2024 09:55:14 -0500 Message-ID: <20240329145513.35381-14-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329145513.35381-2-rpearsonhpe@gmail.com> References: <20240329145513.35381-2-rpearsonhpe@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently the rxe_driver detects packet drops by ip_local_out() which occur before the packet is sent on the wire and attempts to resend them. This is redundant with the usual retry mechanism which covers packets that get dropped in transit to or from the remote node. The way this is implemented is not robust since it sets need_req_skb and waits for the number of local skbs outstanding for this qp to drop below a low water mark. This is racy since the skb may be sent to the destructor before the requester can set the need_req_skb flag. This will cause a deadlock in the send path for that qp. This patch removes this mechanism since the normal retry path will correct the error and resend the packet and it makes no difference if the packet is dropped locally or later. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_net.c | 7 +------ drivers/infiniband/sw/rxe/rxe_req.c | 14 ++------------ 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index d081409450a4..b58eab75df97 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -371,12 +371,7 @@ static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt) else err = ip6_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb); - if (unlikely(net_xmit_eval(err))) { - rxe_dbg_qp(pkt->qp, "error sending packet: %d\n", err); - return -EAGAIN; - } - - return 0; + return err; } /* fix up a send packet to match the packets diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index 34c55dee0774..cd14c4c2dff9 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -802,18 +802,8 @@ int rxe_requester(struct rxe_qp *qp) err = rxe_xmit_packet(qp, &pkt, skb); if (err) { - if (err != -EAGAIN) { - wqe->status = IB_WC_LOC_QP_OP_ERR; - goto err; - } - - /* force a delay until the dropped packet is freed and - * the send queue is drained below the low water mark - */ - qp->need_req_skb = 1; - - rxe_sched_task(&qp->send_task); - goto exit; + wqe->status = IB_WC_LOC_QP_OP_ERR; + goto err; } update_wqe_state(qp, wqe, &pkt); From patchwork Fri Mar 29 14:55:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13610700 X-Patchwork-Delegate: jgg@ziepe.ca Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 131E014BF9E for ; Fri, 29 Mar 2024 14:56:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724166; cv=none; b=GfWngS/hW7z4GBtKD+pykc919gst099Tx+w/l4MawnLD+TK9eFocsnguvx//Jdy6n2k58Jhp4LwrRme5DDYDb7JJ3JWwLzhBhPx9XYyZtbAqEybmBwV1zOgOlTionlUeqyfgZUq10rumZOoQgAysioFn+1BQdeEFydc7J9cVGOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711724166; c=relaxed/simple; bh=B2gmlDep39f/8aLihVViwFCJdjZs3DgwbdYVLyddLe4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZpffAQnQDTKPZ9xg7+pTnZZ5tGpoL4iQn7B4ecItOsuEzQ5LkM18k1+E9oeJXhTbag8FTiPSEFtmQLrBGudlreNJKz43yq5AcUU+oEuE3LjG8bAqT8fWk2DBJxNuT+Exg0Cf/vz5/gpWZjLw5AgNdVLJtNYSfP95aLUivspqBj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CeLzvi6q; arc=none smtp.client-ip=209.85.167.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CeLzvi6q" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3c3aeef1385so1423950b6e.3 for ; Fri, 29 Mar 2024 07:56:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711724164; x=1712328964; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XF9/VOsT7pCQvNE3+t/XGyOip/FH5VeZPlQno+szpqc=; b=CeLzvi6qUu0BSi/lza0h0T6Hr67bQ0KWyba1Vhu4gjVLw8CdG2iqYbq3hBs+rZENGf uvXn8ZdX224kp0zkfn4mtUyBETa89rpzt5E1etMkB01wsbHQoleObypcyMFsx80Drr4c N93tXfLZ4dDrUFm8DiqDcbzjjD+gMeqqm90SrUPOD3dL1Rgr9ViCZ1ZFOwHRnL59cNfq 83liwAidfvevFNmCTGBf4J4euKZqmZoVAqhLk8mzcZRYWnXCsn7uKV5jMF/BRs2nB+io V6DtEw+uKrtjcV+QzK3MKOzRiY2ucLzwdDSXDt1vzuDqryRWYsc/U4e8JCR/JPRFLJo0 fFkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711724164; x=1712328964; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XF9/VOsT7pCQvNE3+t/XGyOip/FH5VeZPlQno+szpqc=; b=tpE1RCnp6DaDRl/nBysTEFRNggmrjcQUeDZ7EQJ4zpcQ2X7tJEsglZ3W1j3DzF/mlW 60zJoxcwEiCE8MM/GLVJe2LfWQxueOV/0J7TiMkn3qw4S6YtiqALR4WE6CjXPIWdFWN+ mHiMTyr3FscAEN1A4Ya1JoVIl/m8WFtoQI7NuwejLaI0Ji6Gu8I714cYdOr8QWo/1Jgi JDCmOX7ArPdOx183EXZBTTv3ao08GuF4e5SQTDgdNthQ+3WWClLJT9hHjMXRdRSEN7so 1o9brKHeS7Kf4BePmk6O2hnj8jZW5UeT9/vcrXR7s5Ga1ODGsLDHb9uPnD66pyWO8Z9j +dlA== X-Forwarded-Encrypted: i=1; AJvYcCWNPy4s4JN0gjNT0O2RHHtprF/noefgZxQDYf6kWUNTSCbCiSmylmt8mTFI2bNzpmTdTB6F3aJHxb4fMDQxm0F7+3eXwdHEIRaiiw== X-Gm-Message-State: AOJu0Yw5dSAkbqMYihuoiPyYuEKgOcGRBYBQn/vCVrtJF+z3W7K/yaMw kTWOHE/83G/qmcBj56Chd3f9DGF0+lV9lF7OnVvmUgUbGglSBjj7 X-Google-Smtp-Source: AGHT+IExP+Q2VUfssSVBzcoK4DoZdQoBh0Wj4q9Q+8gtyYNthukDJTFVsGEBJN8d2YKAmoZys7kMgA== X-Received: by 2002:a05:6871:7981:b0:22a:7c81:1e2e with SMTP id pb1-20020a056871798100b0022a7c811e2emr2729135oac.16.1711724164118; Fri, 29 Mar 2024 07:56:04 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-75b6-1a40-9b4e-0264.res6.spectrum.com. [2603:8081:1405:679b:75b6:1a40:9b4e:264]) by smtp.gmail.com with ESMTPSA id fl9-20020a056870494900b0022a58ffa4a3sm1006249oab.23.2024.03.29.07.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:56:03 -0700 (PDT) From: Bob Pearson To: yanjun.zhu@linux.dev, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, jhack@hpe.com Cc: Bob Pearson Subject: [PATCH for-next v3 12/12] RDMA/rxe: Let destroy qp succeed with stuck packet Date: Fri, 29 Mar 2024 09:55:15 -0500 Message-ID: <20240329145513.35381-15-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329145513.35381-2-rpearsonhpe@gmail.com> References: <20240329145513.35381-2-rpearsonhpe@gmail.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In some situations a sent packet may get queued in the NIC longer than than timeout of a ULP. Currently if this happens the ULP may try to reset the link by destroying the qp and setting up an alternate connection but will fail because the rxe driver is waiting for the packet to finish getting sent and be returned to the skb destructor function where the qp reference holding things up will be dropped. This patch modifies the way that the qp is passed to the destructor to pass the qp index and not a qp pointer. Then the destructor will attempt to lookup the qp from its index and if it fails exit early. This requires taking a reference on the struct sock rather than the qp allowing the qp to be destroyed while the sk is still around waiting for the packet to finish. Signed-off-by: Bob Pearson --- drivers/infiniband/sw/rxe/rxe_net.c | 42 +++++++++++++++++++++-------- drivers/infiniband/sw/rxe/rxe_qp.c | 2 +- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index b58eab75df97..dc22f3922a59 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -345,25 +345,44 @@ int rxe_prepare(struct rxe_av *av, struct rxe_pkt_info *pkt, static void rxe_skb_tx_dtor(struct sk_buff *skb) { - struct sock *sk = skb->sk; - struct rxe_qp *qp = sk->sk_user_data; - int skb_out = atomic_dec_return(&qp->skb_out); + struct net_device *ndev = skb->dev; + struct rxe_dev *rxe; + unsigned int qp_index; + struct rxe_qp *qp; + int skb_out; + + rxe = rxe_get_dev_from_net(ndev); + if (!rxe && is_vlan_dev(ndev)) + rxe = rxe_get_dev_from_net(vlan_dev_real_dev(ndev)); + if (WARN_ON(!rxe)) + return; - if (unlikely(qp->need_req_skb && - skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW)) + qp_index = (int)(uintptr_t)skb->sk->sk_user_data; + if (!qp_index) + return; + + qp = rxe_pool_get_index(&rxe->qp_pool, qp_index); + if (!qp) + goto put_dev; + + skb_out = atomic_dec_return(&qp->skb_out); + if (qp->need_req_skb && skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW) rxe_sched_task(&qp->send_task); rxe_put(qp); +put_dev: + ib_device_put(&rxe->ib_dev); + sock_put(skb->sk); } static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt) { int err; + struct sock *sk = pkt->qp->sk->sk; + sock_hold(sk); + skb->sk = sk; skb->destructor = rxe_skb_tx_dtor; - skb->sk = pkt->qp->sk->sk; - - rxe_get(pkt->qp); atomic_inc(&pkt->qp->skb_out); if (skb->protocol == htons(ETH_P_IP)) @@ -379,12 +398,13 @@ static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt) */ static int rxe_loopback(struct sk_buff *skb, struct rxe_pkt_info *pkt) { + struct sock *sk = pkt->qp->sk->sk; + memcpy(SKB_TO_PKT(skb), pkt, sizeof(*pkt)); + sock_hold(sk); + skb->sk = sk; skb->destructor = rxe_skb_tx_dtor; - skb->sk = pkt->qp->sk->sk; - - rxe_get(pkt->qp); atomic_inc(&pkt->qp->skb_out); if (skb->protocol == htons(ETH_P_IP)) diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c index c7d99063594b..d2f7b5195c19 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -244,7 +244,7 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp, err = sock_create_kern(&init_net, AF_INET, SOCK_DGRAM, 0, &qp->sk); if (err < 0) return err; - qp->sk->sk->sk_user_data = qp; + qp->sk->sk->sk_user_data = (void *)(uintptr_t)qp->elem.index; /* pick a source UDP port number for this QP based on * the source QPN. this spreads traffic for different QPs