From patchwork Wed Mar 27 15:51:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13606874 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.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 80F4E12EBD5 for ; Wed, 27 Mar 2024 15:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555061; cv=none; b=l+8emsfwI3WKi9fM2TMb+AMxU2i1o+soYfrHYzmUHo+0RI80b24/UHSfccpAklhLgawrlW37JXKN9ElkFCZO6M2tF+rZZSgWIkn8LmZurPV6zzLdctc7haydxr2NM93GxUKO4qUijqq6CTxmXdVX08hHXn8OSC32JQvPp8olVpU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555061; c=relaxed/simple; bh=hu+sSbFLIXAKlrWao5wVCYP2Ee0hJ4jSnfY4fHwka+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OqZCZUXp37AX4DANBF6Va3e1CCpGMDnB296Vph61xdQ6do3bqQxYfhsnSH9SubkraKQKNG30JQhLfruae7kQw3IMe2cPIpCWfW5WtoEma1duJYsVctzGlBXUaBcvXH4orhE0Gq8R9DJluxe/YcNS3ahX6C1LW52dzIbxoTOZFBQ= 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=NEVXKgSe; arc=none smtp.client-ip=209.85.210.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="NEVXKgSe" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6e67d42422aso4134412a34.0 for ; Wed, 27 Mar 2024 08:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711555059; x=1712159859; 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=NEVXKgSe/EOIjGN0OubCDoA2SgrkKXYHHTRaT3FkDGhO6CIgjXMDdqS2x6IzunxHbV tdLH3JPz75ZhXiq2ysO+iufxmNCOkCuKTNme99ogoit6GjUe/ryKNYA4mJJYDn3fChr6 Rl1Lj6R/QnoVpKEPUYokXRngPbtp/ljLFT84xDdqKja0AZUk/Ktb+AcF49l/oSBF//6V oG23vusj0s59aEY53to56uPKiMMGJPwus2+ZxdczpuJAodpUhiYflI08TdlHzSeq4/80 1pNo48vjceCnN1nfduaF1y+oJYhN0pw+mEHKui1hCMEFwwOgtdrR2HW2eZS8WPo5BgpC T2aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711555059; x=1712159859; 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=ZLSGxyrccgPLU2BrKZ92Ux30yNlt47R/guYKIJtnTlnOtam3arPL4Wc53Qk7KqRPzP xByxOKeXf0Hd3D9zRc5N8MRdDb+zzqGy9giWskU3b5G/pG7jFNQ+Po0FIDdVpgNPnHup X2Jl5tLEfwyFi1tmJGd7sVBlcAXAzO/dCI/mLwxE/pezlZExTEOlKZNe04WyvmHBiWAc 3xeHdllUMauJjIu7Rbe++udgXcasbI3KlUkkdtQ3c9CIEvKgCM00P/buYJJO5uOw3bfd EYwSg1tvGS2vrLILk1s8c3B7TTV+bCWkMcRkkkC5zzsNKRcvoPPrtDYsEAppobQMWLYt izEw== X-Forwarded-Encrypted: i=1; AJvYcCXpHJqg1XrPm7EGm3JSd4C+wtrmEbfLA/r9Bm0XXzohKTX36nySVygDI4wIVARH/zRiTw4Ih8j79zLlqNETP+R8EKp+mWBdxKVdTQ== X-Gm-Message-State: AOJu0YwJu4RGD28sAFW6sHDPXUJWYqusSPRdXy8rzVwYIGT13en9VrYx 8uPgyzK0z9Z+OD8A1aOzVnkXINb9wqmeXveE7gJm1N8KvI/7s3I3 X-Google-Smtp-Source: AGHT+IEbM1PoZiSese6LDqebDqkYPP56mc6WYm8BiDGp2/jLJScVCLNivCFMxYTCyFF1k1Jk7NUnaQ== X-Received: by 2002:a9d:4d8c:0:b0:6e6:c74e:e763 with SMTP id u12-20020a9d4d8c000000b006e6c74ee763mr365721otk.24.1711555059653; Wed, 27 Mar 2024 08:57:39 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-b62e-99ff-fef9-fa2e.res6.spectrum.com. [2603:8081:1405:679b:b62e:99ff:fef9:fa2e]) by smtp.gmail.com with ESMTPSA id f10-20020a9d6c0a000000b006e6e3fdec53sm883487otq.35.2024.03.27.08.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:57:39 -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 v2 01/12] RDMA/rxe: Fix seg fault in rxe_comp_queue_pkt Date: Wed, 27 Mar 2024 10:51:47 -0500 Message-ID: <20240327155157.590886-3-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327155157.590886-2-rpearsonhpe@gmail.com> References: <20240327155157.590886-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 Wed Mar 27 15:51:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13606875 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 64D1A12F380 for ; Wed, 27 Mar 2024 15:57:41 +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=1711555062; cv=none; b=vFqGg6VMi5K5S/TZb6aJ9jkbkehAFbmPe96tfe6cdS4jXydZDttgztZIqBbLgsJrFgVgA4IJo+xrPW1xANxWcG133yqaF2QF1RCPXh7suzFp5+xPB29TxAfHSizAPyi5SgA7iVwwAx9J3GynJI29cNwxZsmj3CEkZKKdNgQdgj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555062; c=relaxed/simple; bh=OgClSkZM6eL+vERrw/+EJ7tK7V2p4YmhFAD6CV9gxPA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KhU4OS0AfPFeyK7jk7ewTdYzF0NhrP+0P5+HMLsTynopeR5+qakgJ0Swpa6rcghoB7xnujTuduRIKBSagW/DpD0ZFitZuFbeDr4BAC4kifgw/VUXaWddB65yFD+liLIbHX5UewHT6y+hjOrmcQbb1SVz+hixVMQ56R2HIPiwgQk= 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=OSikDSGl; 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="OSikDSGl" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6ddca59e336so9596a34.0 for ; Wed, 27 Mar 2024 08:57:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711555060; x=1712159860; 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=OSikDSGlbwb78axzmV3f9SUqjmU743vwGu6mHkGDZb6GS1B5DetzfUONVmaNH0AWO8 fhCjCgSnlLl+hMlIiqFTc/W/jMEaxHmfgjnI3638H+wLt3PbWg/CTDLDD5sDTHB+OFB6 8PPKfOAHUHnPAPMW33KX1+ma3LF9m3zChEHxLH3dSDv7IGwIo1TuebvZRWCSvr9BgM7X KOCnDL4rDstalTf9aKjMr2FLI7kkbqVn/4DGhbbdexgR1vjexrP/0+P7XgMmDE/89iNv yMjp5zF9QVs6GZ9dhEAt5/qzaSezMtNGhVaBahz6DcvVPanzOZANeJOHXemtCg5CLbJj 29vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711555060; x=1712159860; 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=EFdEjFGLrwLc0fxRzRZi6BNQ2NxAanpzJ6GJsegJwKjxpHdFh55sfgJyZGfrGRacfk yqVToyopJBgf8uz9wYoY6k17cSd2V9YqdQfnZo9cAGgDj1inTL8a3Tft6CKNO3GE62F0 6r7WdX7KUJrfnPb63RhooZOssr3eY064M4AhpkpRtVGWnWA4GXe0IQhX6nk1JaicMveU yYVAJjpJInZLxMzK5Of+yFOekRZwyzYg6OKEe4/L+kQYp/KgaBd7z2WrOhIbp0sZWGES 5WGyNWNKHbyTP/yVWSsK/pML2PWvJCHdiqtMsp/IEZq5aZmNxIrUJ5yCh0kKzRjrHL2i asUA== X-Forwarded-Encrypted: i=1; AJvYcCWwydO79bPeMtZoFk7A1NR9JhDezBGccQM6iRlwJmNPdgh7W8Hdez90u4V/OlX5gxYyfhgafragMINbrrmtK+XLKsI80KAoMVq+8A== X-Gm-Message-State: AOJu0Yz982i9qQndefGMuylYl8kz+mR/RgNygGgkZ5d3l9yr30gU35ls GwxMq2PsxZR6VMYSGN3lKG5JZN9yz1JB6mts3MFpNlKaubheRoAf X-Google-Smtp-Source: AGHT+IFHDRbI/z+DyZ0bZ1aA7xNChanEs/ANRHkQkLYiNR6VAHy7Q1wApZuD99Fow2Ec07BJfL8Gtg== X-Received: by 2002:a9d:4b0a:0:b0:6e6:7d3b:50a6 with SMTP id q10-20020a9d4b0a000000b006e67d3b50a6mr2328otf.6.1711555060454; Wed, 27 Mar 2024 08:57:40 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-b62e-99ff-fef9-fa2e.res6.spectrum.com. [2603:8081:1405:679b:b62e:99ff:fef9:fa2e]) by smtp.gmail.com with ESMTPSA id f10-20020a9d6c0a000000b006e6e3fdec53sm883487otq.35.2024.03.27.08.57.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:57:40 -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 v2 02/12] RDMA/rxe: Allow good work requests to be executed Date: Wed, 27 Mar 2024 10:51:48 -0500 Message-ID: <20240327155157.590886-4-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327155157.590886-2-rpearsonhpe@gmail.com> References: <20240327155157.590886-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 Wed Mar 27 15:51:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13606876 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (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 81F3B12EBD5 for ; Wed, 27 Mar 2024 15:57:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555063; cv=none; b=j9iHvm90vxh3ptqDAUn96LQO5oG9aWMtNSJiENdaPO8V3j0JKZVku61f1rscf81a4eTITi2UqtJ06zy6i8wkJ0I4DkX9CimMrQsCblG62lpKyXZ8KNLPOsSeD3xKL2WAyt9vkJ9EmaNuAZjTUGDR2OtF/+6c1+gDRWGgrnGD1fw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555063; c=relaxed/simple; bh=8iWHOP99IJh3x4cD8IHColiMPVTQtiJHUSlhmwoFscQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KgvrjUokU9zcl6bZr6Dawkgoh3YfNUrRoBh5pM4sSmSWXIHv796PHdeJYnN4qThYY1iOXhaPxdMdOp3eEhxclQruFUzGmP6lERKwV591YZ9P7VWkGaBf58cm3rwMmwlPALoKVXQf5ZNRQTZlmv/9CyHLflLXY6KvwqCRzMgcHz0= 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=S6XHF6ev; arc=none smtp.client-ip=209.85.161.42 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="S6XHF6ev" Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-5a470320194so3530117eaf.3 for ; Wed, 27 Mar 2024 08:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711555061; x=1712159861; 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=S6XHF6evpIMFeHSi8fB63qGH0cdpP8I+SAYbwHcJ+zUDbFORWS1qexIpkQiDBaYb1K +xlwfjREFC7bYHU1wWDpIqN/V4RK78Jtl0wG6kXeUqyjICPRtyThdSvu+SiniQAo3br1 MqabZy09RtX22jXvf9dcGg7iu7QZcP8ds8677AFVSn9czJL/34s4fYgozCOTeJKT2juo A7HY/7Xh3fMjJpGXMr44E2v7M8ogAr7dzmmTPqnbFa1r3sBMr67ihAf45hox6XbnXazZ rMNZYHKOo5sjWDZyQ/NHXMVMGPMW1sHw62SrQwMsXddbkTNX7laUnwwJSiJKgo1lfrv1 CVCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711555061; x=1712159861; 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=i3R3qu7wW7JBbockwvNiyEsdcwY97HRkJcOE4xrlz1JOy7gyr5cpMuGQQIRu1ytetr v8gDYCxS994e37y8hL2bC/3t5pzE/vM9jCiCYVAalzJU/X/M1afpS792XMWofRVGy3RH xNWkyybZ2RREIrOIkKvF15jwUkSVfidx1rjAG/v9/stPfjhMwxh0oVtJi1Asu/hGyxB+ 1tltNriFo8eDvwFQ+RPDzSrOvwwm8B7o42K9wibT/1kcN8ZGzix5BqIWl4hXQFn6K2VT DsM18tryn3sPvtS3Rc81mmbj2c0KxiC2RIqXoRKzSRdrDni6hBMB4s9lcH03u8jBhs/T uSsw== X-Forwarded-Encrypted: i=1; AJvYcCWRILaTV4FTRoWVv71n+8BkG0+PezjPLxDTjGJMLFUhdJxCnlWiFVuArnpTNV3mwv5EQqGsBMs4rarGpMYSAV8Zf8yK2pA758l0gg== X-Gm-Message-State: AOJu0YzJAfyH11C8w3aFFf9EvjmjO+Y25wmXqZSz3p2faw3oy6a5A86n 6Cr5hW6VtWMktiygSAZa32QBYH29pgKueeQ2mu3XYymDHj4qEixG X-Google-Smtp-Source: AGHT+IHi/E/9fos7Y0p+tGJEg36cAiYf4QWgvR7kTZ8LllV+jq2sJTqCwT9cfmRcr4T9PzGox8z/VA== X-Received: by 2002:a05:6820:a0d:b0:5a1:c19d:bd39 with SMTP id ch13-20020a0568200a0d00b005a1c19dbd39mr534097oob.3.1711555061749; Wed, 27 Mar 2024 08:57:41 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-b62e-99ff-fef9-fa2e.res6.spectrum.com. [2603:8081:1405:679b:b62e:99ff:fef9:fa2e]) by smtp.gmail.com with ESMTPSA id f10-20020a9d6c0a000000b006e6e3fdec53sm883487otq.35.2024.03.27.08.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:57:40 -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 v2 03/12] RDMA/rxe: Remove redundant scheduling of rxe_completer Date: Wed, 27 Mar 2024 10:51:49 -0500 Message-ID: <20240327155157.590886-5-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327155157.590886-2-rpearsonhpe@gmail.com> References: <20240327155157.590886-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 Wed Mar 27 15:51:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13606877 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) (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 62B9912FB05 for ; Wed, 27 Mar 2024 15:57:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555065; cv=none; b=ZSHKV8C8q0kEG7xwMTMu5BeqAgCT9PbGGygmnkSWooQ+Z+QOvkHV8C8jh007Z0MLDlkoJWfYepyIj//yrKuZuR3WtyyhZoRJSR3ihDC2u0PL91xGQPocVaOZ7dprElZyVzdkXWsuHvoK+SMQAx8unZ6QCOBqkQ50I0rdE/vDJpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555065; c=relaxed/simple; bh=t50X/6Tszd41e46zl3EW21Kgj0HeSS3Z6HC8xX/f1eY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sFjYxHYkFngodDfSpL/RpQLzrn27aJEP1Z76XobebO1tn4V76M15u9EKU1agfR1xypz0jWIpfCxlujqUYEtIfmdGHfcWx3wcOub7v/BTTmROfvqJv6Z+mlkjYEzhGN54YDj9MLIDLvMiAe5vs08396FTf1O0j6p3AJydFe/HzqA= 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=UkJYN4kq; arc=none smtp.client-ip=209.85.161.49 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="UkJYN4kq" Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-5a522ae3747so2150eaf.1 for ; Wed, 27 Mar 2024 08:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711555062; x=1712159862; 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=UkJYN4kqoSuYTQcgtiLhKcHd9Nph1SJHaXKVY6PmJAZhuuf1LKYc9tHHplRZVFdIQA Y81yxs2YBah6wuxFIra3tLD2CzyHUZkG4RoxCPM/aPAxoGHzdpwIJi6pEC7TnIb8kB3j VpTFMgxe/Pb/gJKKMFkrT9Jt5MExILuL3RUU3nMcS9IjOOh8zTztFkMC2w3i9xRotDmV Wa/+DaYIfR1I/3ON3PhrPSsPKQMbXMA77opc/cuTpPLZSqUwFHC/5ZZEyQxb3cenYW6F FUC4FL8QpIQM9g5hFQMNltMcgqAAk2Iru3eqt744vaTgHLV6/IY2rtNUaA9eZzfG+ZmV Wpdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711555062; x=1712159862; 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=mEGDEKRtZi5caM67gPliWxm0BtuEf0xmJMx1cLBxUSNY3YM80gCFMuL3EBl9rdjRAF Zja/AMKrndNiQZTiSJ5tCHpch0DVGi6tOsOxRfmB1Rt/qAP6gQnRZvT2VvfmjDrSDbSG 3QAO9jhKthocccrxRsO95ayOIlTs35iVbambh4QvjutEU0o87HiuZWow1fNTMTJeVNAv Vn/QaTXYTStahhpsdmfMKTQ7+mG7UcB1FKrbgQWmVnh9rwwm1OsBkvDdwG2u1Olv7mEP MPnPFn9hE/IzMUYma+34KxFdi72v+AlECv4Zf8wRdmYFSB688Rx7er5UyuZhpSKKI4S5 SNMg== X-Forwarded-Encrypted: i=1; AJvYcCV2WG5v+C3IV9eRpfumeiBSezG1VK6X86iWoYKnBCMDE9hx9E5UZnh03ZLkYF9MRDTXeY+txG9dS3SQmLOJywdShQR0rHi0eHhRqw== X-Gm-Message-State: AOJu0Yz4XseD1/IarX2aiIuzuUMH4KAnqnezuaQH07M+hu2VPn9vKcIP ZSE4yq3x2t03KfuDc/c6KBRogcwb5iZ+lq+6HZOFfzLEiKW029qpcg432MeRCHQ= X-Google-Smtp-Source: AGHT+IGEAwXoFh7DHt2jr6k0W292j4/mywAi2r6l9hf0ZvPGdBguTEk814t9irvTZBoLBCcjzk8QjA== X-Received: by 2002:a05:6820:210d:b0:5a4:78d3:e8d5 with SMTP id cd13-20020a056820210d00b005a478d3e8d5mr135814oob.4.1711555062553; Wed, 27 Mar 2024 08:57:42 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-b62e-99ff-fef9-fa2e.res6.spectrum.com. [2603:8081:1405:679b:b62e:99ff:fef9:fa2e]) by smtp.gmail.com with ESMTPSA id f10-20020a9d6c0a000000b006e6e3fdec53sm883487otq.35.2024.03.27.08.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:57:42 -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 v2 04/12] RDMA/rxe: Merge request and complete tasks Date: Wed, 27 Mar 2024 10:51:50 -0500 Message-ID: <20240327155157.590886-6-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327155157.590886-2-rpearsonhpe@gmail.com> References: <20240327155157.590886-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 Wed Mar 27 15:51:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13606878 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (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 406D412FB1D for ; Wed, 27 Mar 2024 15:57:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555065; cv=none; b=OwbcRBfzV64clvmzcPPEL/j3gwxMjHcCfhGd+sj2PmON83YI7ToVlP5muGzQYEd21dv1NzPC632qZlBE5oC57mgqe4PtpBIMpeSMSOawNfJBeg9ya1tlbZ6xJnf7qOILFWc6DPR6dDcfnuZ9elYkB23LwYo5/a8vQlw0LfqmjNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555065; c=relaxed/simple; bh=XIImzMuwSkGxY8LRL32oWi/vfkg7DtdUs916utrYrLI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tgrYslu22TuEWXWAf8WAk1OAxMqWAG2geRs+wpWSiXzQ3QgA0qQoN8tTp2n+SAx7ap8pdGEGlyttAhIR/na6qlpbH0ha10TYQT+5YOwW6dBkD8UHi9KLWR7mrafQBWjZh3R1MuImui8DT7x8ICT4yRZrv79vD8eWCpj4a1sJqt0= 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=ZSlCBUhP; arc=none smtp.client-ip=209.85.210.43 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="ZSlCBUhP" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-6e673ffbd79so3920059a34.2 for ; Wed, 27 Mar 2024 08:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711555063; x=1712159863; 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=ZSlCBUhPiySXYLBmDsgKLy8V8pBROPo2EkkLByvQJxfogsFNzpCfKh8W+ClieSL/AC 689a/hS5+FclA7uAqp2fmCynOvXXrf+xtgFBYLZ0Ku6fnxIfr5aU88YwyWKL4LyDOpho Erg8hiCGFj8ELG7iQ3x9e/MUSS+hIq5/qECzO8Hnep7XSX0f4saD9fyD5oTweW0UsgTo 84obOh0rOx4LL112sJLjVexVQR+XtXQhELpEyTA1c4RbhSA6CGCQTAnvgVuldGtfd8NY Y+6EvMdt28CFx7N5DZuDP1qtoBXOJ5B4b2dGQDPawF/YKX4fNsH2Du9NLAjkBzmfza6h SBEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711555063; x=1712159863; 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=ehSmZJmGOzvyop2dYJPfoliM77pnswNXLtuKvV5N49R9PC1j1Yp6avC0O+FN9wUWmJ 0JbJWbAV3WfL2oExcYVk9B2g/GDX7fHUmCKjIEgn6z1db8dY0Q/HlqyMsFxgIBF5u8hB OmckJmFGlzUtXbjpiShNfXwIU6yaATBXRxjNrB5/e/g3W50VTbKeK9V4cG/kqVGYRuAj ITUTsARlDMWk7geu1T0fhbQjlRLSAjNk3ElU1T3ou6m/KlJHguRXPzjG8ojhuJnCXmJn T31hMJKNIqPLf9nLvysA2RJ57RmqN4hLIfja603iDF4gs/q2FV/DSqYdzSuas9AYeUKK SDVQ== X-Forwarded-Encrypted: i=1; AJvYcCWl88zlIIoROiay9q6wEXbWU/aeqKWMSZbUAnaZhLNoHkohXwlNQpp+KuVjtk/mCSbeiBjlngrJwMkFF45DGsdsLGOfnGhPuxHqxA== X-Gm-Message-State: AOJu0Ywukz6kjJBC7cdYjEBQ8jQWRLuZP3WmH3bTGU0xC5wzUee1/7xC ztghoUMYgWXUs14NqM0k3GHhQAKo6o58m4CmfqYDPiBFtag6n/n5 X-Google-Smtp-Source: AGHT+IHitvDh2N5HNCgmVFZ/RWG6yvwvgJ1tnIe0Iee4t1bGWAJwAY2qTobeo+zyOzc/V16LoWYKfw== X-Received: by 2002:a05:6830:204b:b0:6e6:b2c4:3b9d with SMTP id f11-20020a056830204b00b006e6b2c43b9dmr368440otp.30.1711555063474; Wed, 27 Mar 2024 08:57:43 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-b62e-99ff-fef9-fa2e.res6.spectrum.com. [2603:8081:1405:679b:b62e:99ff:fef9:fa2e]) by smtp.gmail.com with ESMTPSA id f10-20020a9d6c0a000000b006e6e3fdec53sm883487otq.35.2024.03.27.08.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:57:43 -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 v2 05/12] RDMA/rxe: Remove save/rollback_state in rxe_requester Date: Wed, 27 Mar 2024 10:51:51 -0500 Message-ID: <20240327155157.590886-7-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327155157.590886-2-rpearsonhpe@gmail.com> References: <20240327155157.590886-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 Wed Mar 27 15:51:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13606879 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.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 2443212FB2F for ; Wed, 27 Mar 2024 15:57:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555066; cv=none; b=Bn3gIFLVFysUEUbw0BQx/ABnJer497xcR0gTrhyFg2KXN5wWlCprxJxjrp9oFM7SgMLd0j0yLYysAoFPagi1IS4xEIsL3NliKSMfstfmBU8OWIwrurULAiiv2wh9iosiCNoeTEpbnJNRJOjKXXZ9POadBCnRBCk8dm4qkB6rz4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555066; c=relaxed/simple; bh=nK/eWvmC9NoeXAd3HPKwxgaAueONSiU99ZwEabcO0kc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i6+lZkSDnnRTOSorE+Zyea/E5pXHZRPy88FT4T6+vi1Mx1AHRY0o8Y/sU9S9VG7Fiq2jcjBtAKz2IVdBq6K//UHjzK+X8HkqQkRskdLovrBt20ZQHpic2G5o/1fF3zD8s1fD6HBTZJxE3ot05f3zvSdxkHt2BKXywrA8Yh5AGmg= 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=O3kRbMu4; arc=none smtp.client-ip=209.85.161.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="O3kRbMu4" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-5a4716cfbbcso3854689eaf.2 for ; Wed, 27 Mar 2024 08:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711555064; x=1712159864; 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=O3kRbMu46MfEoBvAuPGFY84aJfI6k3nfPZGNE6CUn8xeIx1d/GnssF4KhAd2DrsGYw sunltseByEswO4bkfWWM6m0GsqapZVjG7GHX6BycdNzwoXzPW6jNU/0x5aTqSKsf0nfI FlLCEcJAg5j+hKZuvb4eqBBotcUR98ohqo+sH46BHc/UkvuSFoxYaZG6rheEzs6bz0QK 0TKsU6n8F8IoxxXMTUUAxknuQrZU3hRrGiMzDOQ++bt1op6Rl7mSbDvOuQ/UTukz6b9q asQNs6xV6cq0NlKdH99So3iMgAQzPCRJPVERCPZ2umBlvOW0nNiwWwOP/TXTojo1qEKe aNNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711555064; x=1712159864; 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=jEWj/KBhfxfqT0dkn71iqIiAdYQnBbTFIl5pDLkuA3xVtLusNwBupc/Dp9nolmFKCD Y9psV8DMqcgJ32gEzqGm7nT1gWqiizs3Ad9n+Dwfy5hkibZx5LznRXAwfWCYiJUWU/rV 7WIFiKt4FpN0VSARQKC/fCLXK9rwpy5PCqLjugGW3MfyWKCvonRq7TbZthIfCWh+DSso OlDTvgraQMs/i7Q0XYayPZr6MCl5oDuuiUUh1dsorfvkYnCQbKzfp3q9mf+6LF8QHCVQ REXXOCjdrPUPD9j7IaPf+KL/WusZSMaLt0fZdSUWrq4fkFaq5MQsV7rLlHkWbtz5Bvsj YalQ== X-Forwarded-Encrypted: i=1; AJvYcCVt//c+V/+vZcXoaYe/l66zZ/EHKLtgnNdbCKDURkauCwq91ZicwZ1qSznA4+/4S9VBsllqDZslQwnNhX+HLIsCz0i9hoctae/xEg== X-Gm-Message-State: AOJu0YyERH+ac3Zy7h4hOh9UzyBtfsCDiu6pKNzQkWcg2X4SwNMmxFbO EPID9LOZl4My9Seijiua5YWswAtvXglnXcMhj/B1PULqX9UevvQb X-Google-Smtp-Source: AGHT+IHgA8HBbv6h8JjJSzS5Z6C1DMQ7kRcm0ZumvFNBJaBo8ml6pTtt+5fjaG81AYr86eiIluqkiA== X-Received: by 2002:a4a:e917:0:b0:5a4:71b3:d090 with SMTP id bx23-20020a4ae917000000b005a471b3d090mr637613oob.5.1711555064282; Wed, 27 Mar 2024 08:57:44 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-b62e-99ff-fef9-fa2e.res6.spectrum.com. [2603:8081:1405:679b:b62e:99ff:fef9:fa2e]) by smtp.gmail.com with ESMTPSA id f10-20020a9d6c0a000000b006e6e3fdec53sm883487otq.35.2024.03.27.08.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:57:43 -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 v2 06/12] RDMA/rxe: Don't schedule rxe_completer from rxe_requester Date: Wed, 27 Mar 2024 10:51:52 -0500 Message-ID: <20240327155157.590886-8-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327155157.590886-2-rpearsonhpe@gmail.com> References: <20240327155157.590886-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 Wed Mar 27 15:51:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13606880 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 029DA12FB05 for ; Wed, 27 Mar 2024 15:57:45 +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=1711555067; cv=none; b=rtPxStqSdcFEv7FoeDpwx5FWA1t+S7P+GVjjB4WrtDtkt5inD+PUmHEvJ+N88lKdLSLlKrhu81NuKnszH37ZCKpyY63Dfxf/tk3bi4VfVUPb45C8JvLmJ7avKPmUY2L7NeEapHTcxCQqPFwIovb8uxn5+hXqk3I1S6AMK7Gh4q4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555067; c=relaxed/simple; bh=x5SWuSvv3SMTKBKxaAPrs628VcfWHAdoZKcjlwv9V7g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HZU3j1ycV9lj6UTBvWBheY4bfO5TjufNHxNSuj/szret8aWlcYtEtiktgMk4loPWRq9UNrtfi9MFhOEnfkczL4AI24EEJeHDHyQvi4xgBLrGN1OTMxk8/69G/gldVdF+D6iZF+yjsF/Z7ayxqpFKeQFGGlEoilA4y913sU6Mlr0= 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=O2KpPCQq; 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="O2KpPCQq" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6e675181ceaso3745577a34.2 for ; Wed, 27 Mar 2024 08:57:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711555065; x=1712159865; 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=xCjztQYodtMXHgbrSSmzgM11j2HWm+7GDAVbEYgFieI=; b=O2KpPCQqLx1CVIIAY7TLalZN0y2Lwn7XXiysdrFqUKSloVQhObxdq5vC5PEGuDD9zZ F4KHfPNsg/Hlz+KZk/CpQqGyZ74YXLgRCtjYedNgWnq0k4wmxbSwPpd5AWGF9eph8EZm 6N5UNk28zYXrrCtJ7FpqgBMEjzLPnFQDK9gsi84gwFLgB5YUxLAJtAYF5DNWlcFine+2 HqMAbVk+HI8yr+rr1EGLTHimnTw85mUW2iRqsqdHyNfjwJIbiOGlOO1GW7vy8pwzrOjP PK5PWun0LWg1veI4iVly9lFbOKX3xzzhoYEc+MuEvRDQI5U9gTbgy31O7rSqQk328IYD LoSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711555065; x=1712159865; 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=xCjztQYodtMXHgbrSSmzgM11j2HWm+7GDAVbEYgFieI=; b=ekqFt+uVD1jmTVJ0xHWlyPoPa9cJM7rgAhoCSAoa6Pc+bfK2CdaEbNxZgI/mO1vILN LWjbpXWvc3gswjxiyiilXycbv/Xkk0B01CLbzIZa7Ha+nY9e4TIji9LFexkHZjK9InF4 wpsnKEOcnnHNuZ5CStyw5FgmCAoOtdQBiNZgT5CRxU6PzkFBVPYd2WTZP6qHxz8hETMo Bqm5AwZdzl5xHq/4jKMnD3DY1ZN6h01KdRtxSb4iGhUqTiBGi/FJX2aCkBUA/sR+0PbL Wx7h8Q6M6CojxEUgmSpP32bzRfaH0hfXQVL1hc/uk+LnCMHYliZFxUlvv9yilIonsthF sX7A== X-Forwarded-Encrypted: i=1; AJvYcCVWxccEtAh7HnYsyIhbg1FZneEIv5GTb/4l8OaRUypbEsbdV8Dmqcei74SQTiVwdEgbTzhH79t6aJvFrflnr8MeptsVwxmrZWu/1Q== X-Gm-Message-State: AOJu0YxCn9j1V2YLMaTRPQoY8V94lRW7a6Z4eLRxj9CiDx/8x43JSu4D nBwhCXMAWbm/0VJhnChTbvDbvJeb5PxvJTigAoudugjM+focXWID X-Google-Smtp-Source: AGHT+IGo5BpQclghhkftGqKPvq4zB9T9L4Ksq86ZcoXASYe/9O1CZMgfai7i3zcIZoZF8suw8O26ig== X-Received: by 2002:a05:6830:2085:b0:6e4:253f:c551 with SMTP id y5-20020a056830208500b006e4253fc551mr351428otq.29.1711555065053; Wed, 27 Mar 2024 08:57:45 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-b62e-99ff-fef9-fa2e.res6.spectrum.com. [2603:8081:1405:679b:b62e:99ff:fef9:fa2e]) by smtp.gmail.com with ESMTPSA id f10-20020a9d6c0a000000b006e6e3fdec53sm883487otq.35.2024.03.27.08.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:57:44 -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 v2 07/12] RDMA/rxe: Don't call rxe_requester from rxe_completer Date: Wed, 27 Mar 2024 10:51:53 -0500 Message-ID: <20240327155157.590886-9-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327155157.590886-2-rpearsonhpe@gmail.com> References: <20240327155157.590886-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 | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_comp.c b/drivers/infiniband/sw/rxe/rxe_comp.c index ea64a25fe876..c41743fbd5f1 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -82,6 +82,8 @@ static unsigned long rnrnak_usec[32] = { [IB_RNR_TIMER_491_52] = 491520, }; +static int run_requester_again; + static inline unsigned long rnrnak_jiffies(u8 timeout) { return max_t(unsigned long, @@ -325,7 +327,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); + run_requester_again = 1; } } return COMPST_ERROR_RETRY; @@ -476,7 +478,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); + run_requester_again = 1; } } @@ -515,7 +517,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); + run_requester_again = 1; } } @@ -541,7 +543,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); + run_requester_again = 1; } } @@ -654,6 +656,8 @@ int rxe_completer(struct rxe_qp *qp) int ret; unsigned long flags; + run_requester_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 +741,7 @@ int rxe_completer(struct rxe_qp *qp) if (qp->req.wait_psn) { qp->req.wait_psn = 0; - rxe_sched_task(&qp->send_task); + run_requester_again = 1; } state = COMPST_DONE; @@ -792,7 +796,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); + run_requester_again = 1; } goto done; @@ -843,8 +847,9 @@ int rxe_completer(struct rxe_qp *qp) ret = 0; goto out; exit: - ret = -EAGAIN; + ret = (run_requester_again) ? 0 : -EAGAIN; out: + run_requester_again = 0; if (pkt) free_pkt(pkt); return ret; From patchwork Wed Mar 27 15:51:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13606881 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.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 C060A12F5AD for ; Wed, 27 Mar 2024 15:57:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555068; cv=none; b=tCiLPKifbPDvvjKB28WLxaxeUuhy0V5zlbHTc3Lq6Cx6oJNvSe6On5bY3MJmctBLENxV8zHYGVrrLCgU37d0yfD7seN9NP10Twr1uSksFqIBquz3uZM+gFuLQyBOEAA7pmLY9UEpkBpYpXfmsSxg2Mvn5Zo0i8ONlUmJyY9gUzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555068; c=relaxed/simple; bh=aVaT9oEgjB+t+ktYasHRoGdnbMAnICSWwDtQfMlVfwM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LTuFHzipYON1la1wrAm5GyljTQAMQNYUawPomPUT7hPWJ5vpdMh4pw6/p00r54fLnyU1B+4OZfAZgm14kki/ZfKKUyi+BA/UKcXVd9+QStI/vfyWgpds73AqH52UDIAaSnrkgkISxlOUapU7sr1kR9RaTt8hBivJ/ENkhvGmxfY= 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=MBBJfhQQ; arc=none smtp.client-ip=209.85.210.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="MBBJfhQQ" Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-6e6a00de24aso3249376a34.3 for ; Wed, 27 Mar 2024 08:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711555066; x=1712159866; 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=JzZlBTHvySRsZ3KRMvxE7Z6XgjpPewuA3TvQlMhf1s0=; b=MBBJfhQQM32UMWW7/Pw5JFChIMUWybmA71DRmGwLvCQiqq7H76RtuyQFkYsUPdG1Wc ApxE8ZAhvn2aG7U9RkLdXMLmk7B6O2FICL7EaOXmKZ5InAqjOJT7zEcRZ4W09dlwOris BNC4vQCEe59bNWlgoH2ltFNUWLYNU1qa897ljErm3IfpquObYykLvYFHoZdI9iVzOKWd gzDcWsoG7no+FFPC2VUiARdI14Tgwqj1LMZ6tLbEdJowUrDAWCcUON8Gr3Q0WMpyFGtD 3YNIMX1y1tZS9NQGgbad950pTDyp97CiE+6eS944y8DgzQSla1VlN9Ql/m+iXt3BVrl4 vCSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711555066; x=1712159866; 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=JzZlBTHvySRsZ3KRMvxE7Z6XgjpPewuA3TvQlMhf1s0=; b=XR1jmVvK0wmnxh6jRMt5QALH6i8zaQfx2NPYNyJDnG7Bsd/dr811UkXISVzLWC/J4K 7RkXncJ5Rmis35oQ/0+R1t/GkY0AUZ8MyaYJJDGMqvYea92HQE19XYk9ChnS9n2vBOCJ 5NIQpv7Etrs9seXjad1XFfrvrkOrI98BY/iUZZPCheCNXweO4qAq2GYze2tytKvzE6KI DSgszqIoEoF7lEqVlhlGmxVGnhSHglBzoEwOgHAkw7yuRTZafEk+yQ6LN7j/LAayVezU uobRkJBCxhnMEEWiVNxgk5+DxUJvpNaGjV8rvq1yFpJ8/BrLZZR0Dn1dUScHxBh1+tzF kEXg== X-Forwarded-Encrypted: i=1; AJvYcCU1TUrqTbF10nHUX0dZEsCd1+df2hUoD7wjJMy9LOgSm4B/oOx81KmzfqmrOMDwaxgG4WHYbSKHwG/UYoa0vKBJB2AKoHZLhQf0sg== X-Gm-Message-State: AOJu0YymeMoqcpZrKeCTdSJlvay/M+6kfnuhTOxbEIG5AB1AYORdr3oF QhNXqjxeod4A2YVAM7m2Kxe0Bczt4d7xC15I6O8tYRlbUh+cTFUV X-Google-Smtp-Source: AGHT+IFiBMWZA54T4vv2MRm2GrY2wrOaFMZ8Ao7ORjvVllq5ypsGnjN+t8gz5cxIuKCReFPa2BLeLQ== X-Received: by 2002:a05:6830:1e44:b0:6e5:23d8:a4c5 with SMTP id e4-20020a0568301e4400b006e523d8a4c5mr343661otj.34.1711555065909; Wed, 27 Mar 2024 08:57:45 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-b62e-99ff-fef9-fa2e.res6.spectrum.com. [2603:8081:1405:679b:b62e:99ff:fef9:fa2e]) by smtp.gmail.com with ESMTPSA id f10-20020a9d6c0a000000b006e6e3fdec53sm883487otq.35.2024.03.27.08.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:57:45 -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 v2 08/12] RDMA/rxe: Don't call direct between tasks Date: Wed, 27 Mar 2024 10:51:54 -0500 Message-ID: <20240327155157.590886-10-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327155157.590886-2-rpearsonhpe@gmail.com> References: <20240327155157.590886-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 c41743fbd5f1..26c06f840184 100644 --- a/drivers/infiniband/sw/rxe/rxe_comp.c +++ b/drivers/infiniband/sw/rxe/rxe_comp.c @@ -131,18 +131,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 Wed Mar 27 15:51:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13606882 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.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 A074C12FF93 for ; Wed, 27 Mar 2024 15:57:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555069; cv=none; b=LIsIkyabD+e2Xe5axs7hX+chEReeZGIwJc9y6/vuxMJXi1J07i8vb4i2N6fcvac9uOMz79DleG3pPhHrDeK1dWppQwUywjysbgBM2Vw/5KEhk7BEhqLdtOmBA1XRjnAoDZXewX4/BCxfavesE8fwBBrVqYjnBjtuG546oswa4bk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555069; c=relaxed/simple; bh=0Pa2bP02dZ3ETe2IeoQTHbmUTpw9EjmdiMWm3SVmSbQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DDeA3ZPaWrv5umEhBr3RU+fnrNPy4rDxKsXy3nl8NuQ5MvMT2fSIaHI8LkIvA3StC4SQWr1/J6a+fD+gDJvoYwyga8QxBPA+xlKI/wHsjMxn56PPIOdXpR9coUGxzByGet8BqQjhH5JY6sjLgzx+dvzE4uEHL8n2cdzjgnDcoS8= 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=FX3gWMwa; arc=none smtp.client-ip=209.85.210.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="FX3gWMwa" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6e6a00de24aso3249389a34.3 for ; Wed, 27 Mar 2024 08:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711555067; x=1712159867; 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=FX3gWMwa6R7UVCrqRdEqiBf29uTnDKCYp4A/+pdnFkcrS0Tj8UUrmBKgf7OWrKtDnL UNP1fXqXU/CB3gX38omntDM+npB8xypIGcv6wE/IUHWVNJ8aorlzHOHFG0EmYfyfhnNy hcVMfyEg+0/uWV1uk+bgnMaRyRb3pPXbbSiyZf1leub60FqkTz2xXCQrwzHfHaNI6G3T FTSwVljUbMbXzH/SmXK5jKp3lWsHHzCo+EhkotEnxXlG+/OJaeov0B94vO5teDtaSpVR 3iD0VJkNs+W3d24u3TQ+8/V/NhSwQFr2g8xXGukd1wUa0lTiwaEtBC7U0Dz1Ny77vCvc 0N8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711555067; x=1712159867; 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=YiTeWJYMn3semsjjOfOYjkWmclBVkl6/r/C79xic3wcJB+dEO+/tySuJy9AlIdgB0J pwyyk2tlfBWajT1fAW8sayRm/yM/sBmuGqHlybY1jz59qsW/ugWJtLpW+NtT6euyJ+K7 Kxhz3vqiKZ7chCnm/TpvEmB2xti9EkL8EkgxGV+53tQ9jW1opJCOE4t4uMQpkVeeqN/c lcP6Cppqzfw9PvsLGjF0UW5hhmwowWLbEzoykjiAa4au2yKYA3f78qFrHqnhl+F8KR4Y 0guPqLI8hjJzhFe5jD5KlHWtzbuBS3r28MIx1f1oFnspKP/8uOlnonYiCTYdP+0nCrK4 Pyrg== X-Forwarded-Encrypted: i=1; AJvYcCWqBeuMGq152MxG37Jgx7PiKZ7fcBwNKHwkvKCLbnL/Z7lHH6mLjM0yxN1yeZGWgel3pOm9fAAb5qF+3V1pws8wQgO4Zds+To8Xgg== X-Gm-Message-State: AOJu0YykUPBVGEafBKw7yHLZopwfv0V6cQMI/SjpMHFXca3VHSDxQqlO +AJEwu06+vsi8iaOC2PItrOtOhY8kmJpmhfpZkchKnM9c47kavVG X-Google-Smtp-Source: AGHT+IFOqEvffug+hMzTDBz5+yGruw81TmR6Syco5Nnh0tj8s1ApTBeso/L76T3S0gWH42GQL5u1bA== X-Received: by 2002:a9d:6b03:0:b0:6e5:210c:5e53 with SMTP id g3-20020a9d6b03000000b006e5210c5e53mr353343otp.33.1711555066810; Wed, 27 Mar 2024 08:57:46 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-b62e-99ff-fef9-fa2e.res6.spectrum.com. [2603:8081:1405:679b:b62e:99ff:fef9:fa2e]) by smtp.gmail.com with ESMTPSA id f10-20020a9d6c0a000000b006e6e3fdec53sm883487otq.35.2024.03.27.08.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:57:46 -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 v2 09/12] RDMA/rxe: Fix incorrect rxe_put in error path Date: Wed, 27 Mar 2024 10:51:55 -0500 Message-ID: <20240327155157.590886-11-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327155157.590886-2-rpearsonhpe@gmail.com> References: <20240327155157.590886-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 Wed Mar 27 15:51:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13606883 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.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 C8BCF1304A7 for ; Wed, 27 Mar 2024 15:57:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555070; cv=none; b=VOZVEY+yQWZ8uwdOY8lqJnwTr5n+mVxrqMRi+3zMl5bSFnErhlvYaiWoMMQ2396R2pm9gyI+fvvUhnPx0mCBgz96WX1llX3P2civG0Qg4BHZumaUCUGD2r1xkuVAGCnbrlKfxC5I65zK7p9YCfKbFIIfVPRTghctLvcQk677blE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555070; c=relaxed/simple; bh=X2q6wbjrbnUuC0airwdkQF2e6eqr3hWQJS/qlRR1dXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YCs/c3ajsSc0dzMM1HUDkX25V42wZnaRi6wD5BKl8BqZ2dF+9HlnPGJbkRCFEqTVpyHTgoMkMjNsdmpaWddAN7TpT+CBYolX03zPhcWDPbXNE4yAVBOZzaN8oKWu5UwKqJPnB3P5xcyjyv71ASJD8xNwZ4MMpuh2xEUUvADY8Mw= 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=KWzjYTIY; arc=none smtp.client-ip=209.85.210.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="KWzjYTIY" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6e6b01c3dc3so3936924a34.2 for ; Wed, 27 Mar 2024 08:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711555068; x=1712159868; 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=KWzjYTIYjWssdfG3LmIsHGroLkPaMCOvZqCFvENOBFPgt6h7EfCDyi1fjlPXTr0d+l xoYn71xYf9z/ybc1ElJ1iHThfi44vtIBN8MULPB/wS20IuVpQONyfxf/wX0X8Acqw055 mNA+/GszUIxeJXjs2IW8QWhkJJm8177nMoPTQEnf9qoX4W2EKLaEaYimny7qM2CwVmao rp+gI2GjP2GrvwN2h9uQw+0hBkbDcn7DeDGDHZ6+uG3TA3lEp4NAO5ECd/+7pja48xfD R7nck/JTnRMtsimCax3pw4i/dFjswCAff0gtHvnJea23UBgSmVqzgeDZg3kMFd32wphs GJSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711555068; x=1712159868; 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=o/Ony6hGZPrQBX5FqJTbrIMpBmpbYdxgbODb6JkVeHcEtVI31UW7xxVw0zKeMXkPE6 7oLRuOD/rXVpVIr5p8uYYtbXGe39xKNng5mf3J/3mzooDyOKSNyG76/7EX4naAhSjrDI IPqI2cPP8+kzxo22kK+0ixos46zFA8CnJ2aA12kH+r8xOau73vhnc9wwKcZaX4KoD9GK m7BFTQu/iobBCNDKGk3W2nogKN+OUd1x42f/tVMuXlw2cT4Vo2Kd4w9uUsbU4l/TkNPL QZ9FvccPXkehzVDxrsljRYkftg22ColV3MnhRfMeVwJMmMFwW7BWzVmsHGis4YbRElt4 +AOA== X-Forwarded-Encrypted: i=1; AJvYcCXYGW0XV5bvXoSEgUmo7oxATBiVVrJUAfs9ZXVk9bR7AHsXHgb/RJvGD3+THyEBwAmMb18r8U3aw7zqJQdvnhZpABsefzIMpRkMOQ== X-Gm-Message-State: AOJu0YzZnD/8igvW4C2jYjl8OrAvBgkYDICkOhGU5v/cFJrEnWiymcWq zLnAI2ROJAO1U3s7B6Oo7xrPfQyWVAsEAkytmF9D8hd+kU4HhosX X-Google-Smtp-Source: AGHT+IGF2rwpWvertbZ+ZhZOEBZCVaiqczD0RbkKX/QyoP/eexq9h5UhMnXGSsOTwXQEUA0PiDk4ug== X-Received: by 2002:a9d:66da:0:b0:6e4:b891:c9eb with SMTP id t26-20020a9d66da000000b006e4b891c9ebmr189203otm.30.1711555067960; Wed, 27 Mar 2024 08:57:47 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-b62e-99ff-fef9-fa2e.res6.spectrum.com. [2603:8081:1405:679b:b62e:99ff:fef9:fa2e]) by smtp.gmail.com with ESMTPSA id f10-20020a9d6c0a000000b006e6e3fdec53sm883487otq.35.2024.03.27.08.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:57:47 -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 v2 10/12] RDMA/rxe: Make rxe_loopback match rxe_send behavior Date: Wed, 27 Mar 2024 10:51:56 -0500 Message-ID: <20240327155157.590886-12-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327155157.590886-2-rpearsonhpe@gmail.com> References: <20240327155157.590886-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 Wed Mar 27 15:51:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13606884 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.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 86E431304AF for ; Wed, 27 Mar 2024 15:57:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555071; cv=none; b=cwKOjeJSjTrb8YiaBEuJHUE7ShFxRLx+h7Myg6TJYs2s24OCgR6os7o5VzOjXDzcXlTWImQ1Ag52R1qnGFr/pQG0P/sh2qGo+vebSHjIWz9Abtc3aALyHqY2twboHTsM0LQYWzfbUJXy/Ovf8mrven5aygkpbZ7SU63+n/+Z5Co= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555071; c=relaxed/simple; bh=UZ1/DCPLtR3mduOS71FDyDDnkpBv8+SGmdEPh7DHYY4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uq3V51hCiraus2DEOMOr/m6X+aB6fXKPSwxKdqkhzFy+JtDfczRkwpdc//eTQqutgeHv8K0LXxse+SyUssEOtGpIRmmgC7cfNy7OePASBYBMoKuhgMN1UINuqhXZCN2dmwofsdWZwyA3iifM4BaKniEDk9OBn2vgxq2Fnwilzug= 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=Gs6+HfZM; arc=none smtp.client-ip=209.85.210.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="Gs6+HfZM" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6e68d358974so3267429a34.3 for ; Wed, 27 Mar 2024 08:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711555069; x=1712159869; 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=Gs6+HfZMxZahWPqm4h7P5zZ2aA0RmSiX6GVlMkhm4SkF+Qw4I2vUSUPI0/FMbY67vx 4Yjj+OdDCiuEGhK1wfAfWLgAkUTsoc2HyFVH2B+MazwRnrG+Z3OeM3Lf84fDqdbcAc0C NhlylzXmGmptKtmxOXdeKYp1Lz7Y42BNR3zcXfK1FwYts6s2rwrvZfi6P70cG+3/Wjd9 Cyhzwu5WzAUcXlAoIyLrgTDb6uveImG3MHOuzoWHxP5+asowBSQXSYTvaNpFa/xmKsNb Yi8YMJhLqq8SYsXVPQxsCWUvD90qmNfu+/H14ISjlC4FIcIgg1ObwVkWFenj0D/SXG0w 6ZJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711555069; x=1712159869; 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=xCKfUrYfsLN5xQlOK8doPzcp1a/1dhxvraYyFgYhT8WvmbQj3LgQ6BJ2678unugWP5 a49ybUsjZktdcOE5rfn3M9RMwpBwYQyHXytVgCRy8XsFZFZ+EMD3QcXVwd6PMYZPbeQk BH7QfSr2PxZOqtPUkujogbtMn7amAdpqG27H97hhiFyUhmYXqCGKnCLrotobAoK6WpBx NvbE6GTQ7SafYlzTG3+iYHLCrWbzT7hey2hlJ1D7cOB5CsD/EVKx9itWeqg8wBVsF/vg SHqrZ5qj+5IjvJIzaC1QHqljJ/fjujdM85EkaxBRLg5YA1BOwSGkXepiobPjXlvi81au y5gA== X-Forwarded-Encrypted: i=1; AJvYcCVFkHiVKNmweMge86yvzkD6O5HsNgvbik9Mh+586UYjtphPQdHPj9cnzeuZZwY5NpeNwrk6xLmcUX9GjfHOSTIVWSjASNaUqb5GTA== X-Gm-Message-State: AOJu0YwcrTa1PNPrNB0dB74gWff0hEUjIDTRAkIEeWXzngKd67bJ3yV6 PpLS55adlZFqW4d3q0LIPsGGOqVmaSJv+auePiCOSOKe8XPGoKZtLo93ma4fuWM= X-Google-Smtp-Source: AGHT+IEUUzMgRFd1Loso9emtp0DWE8GcVat4T2Nof4Xd+K/GCPTW+26n1QhWyBk6dPYCr1HPNhKtBQ== X-Received: by 2002:a05:6830:d4:b0:6e6:9547:bce4 with SMTP id x20-20020a05683000d400b006e69547bce4mr225737oto.2.1711555068730; Wed, 27 Mar 2024 08:57:48 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-b62e-99ff-fef9-fa2e.res6.spectrum.com. [2603:8081:1405:679b:b62e:99ff:fef9:fa2e]) by smtp.gmail.com with ESMTPSA id f10-20020a9d6c0a000000b006e6e3fdec53sm883487otq.35.2024.03.27.08.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:57:48 -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 v2 11/12] RDMA/rxe: Get rid of pkt resend on err Date: Wed, 27 Mar 2024 10:51:57 -0500 Message-ID: <20240327155157.590886-13-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327155157.590886-2-rpearsonhpe@gmail.com> References: <20240327155157.590886-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 Wed Mar 27 15:51:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Pearson X-Patchwork-Id: 13606885 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 AA31B1304BF for ; Wed, 27 Mar 2024 15:57:50 +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=1711555072; cv=none; b=NT8h5etsKFFyo6P4WDIa5JHeA6MkxjsMu/4SJNb4q5qb5vAYn/Z/S3m9YmtMMPm9FpsNmk2pe7M/4SslvJGhFTjfAdISTbXaRQLCp6lKy+R6qH91eloBYhLgK90FHa4Y0h0diz4pnEYBz3g2+uoZtR5bqdFfc+riYIFBpZGyEw0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555072; c=relaxed/simple; bh=AilatBEBLSlh107RF2GtLCHpfjH+1ao7MSzuIpuO8RQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IDAbkwr7F5PC1W4qlvX6/Hvme/issT3GSgyeWpVa0UMHlX9i30xUMlGZgDpBho3bixirQHeRg0jsGQLavODgh/XDIhe3Y6yE7OqxDQx2E6hOFyK+ntKGWhXM3zGuiPCAlviQTh4ZCCW+qPJsAyjxCS1WFwa800dyM8s4Zt+T2UY= 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=PFP4taEQ; 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="PFP4taEQ" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6e4f7975121so1624121a34.1 for ; Wed, 27 Mar 2024 08:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711555070; x=1712159870; 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=ZSjXTA0jQyt41K1i3R8cdCOpeg1vn6KbYe9akb1dy5Y=; b=PFP4taEQYIJdHJmBZeDrU5JNbqCmLG9mklZp+MiXnUv0Ss0EemlncwLGs0jpg5uD80 jO23h+A8gH4XS4kbBqJJLmO67k0318QO3X4kftRfddonuJ1O5LVpjL5EbpC234PvZfWN vVkv4U0Id4XmetXo1Bm+rWIhvltWT0iFtGuzvdm3tmDcckET7O+jEVAEPw738vBBdBg+ 7h7yU2dMZtKnqhNLQ/jugyPXF+dAKO6zCaVkkJWNaCqiw43UKmKypPZm6bqEUcve6OuL xh6h+GQyt25TUvZHB+vvFEBNWubCiGOseOmfZW0OQ4E/Q4B6Ow5n6gslygW/K53/XoAz E0Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711555070; x=1712159870; 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=ZSjXTA0jQyt41K1i3R8cdCOpeg1vn6KbYe9akb1dy5Y=; b=HTH3AvIsZ8CKk6+wh3CPSTVb+D93H/nPtKxY8BeGajaZUAC1zuONRVMA8MlNAXn3nK eRtxCSZhLoDORi8H4mtYmE7q7AkPK5wWSFmBDDHTpUrWjJDwPvII6ltHGAG0RdGTyRtg PfjqZR2bSY3rKUl/GrO3jGhI+9jg9YpjUooZzOKv8D7FQ6jHpr+K9g2wTySmBpinfvqJ VbEQiKiEMkAkjkENZvBafWFVBIKWgymq6MU9gSpdRZFIG081H00WLltcCTVThmMI6mjM KJg87/Sc9m3qnjDQyCioUpND+g73jDWvoeTh20PSUSjcTkop39eTe1kR+i08/U9yx9sq VbZQ== X-Forwarded-Encrypted: i=1; AJvYcCXhJTcEEj8/bejuLmQSzK64RGBYwrvSYt6NT92c+OzKqQEbSlJ6yQ82Ad+yT2DldDuiE7sUpIImd7bnL4Wj+Av85ZPC4t5wViXKGQ== X-Gm-Message-State: AOJu0Yyjd0ad1DqoQ5VbQghhK3OGPlRc3obA7MhYZwbsLRk8GrQQiSki vhAPAOuG6/EmZOU72jIr4MKlCkL/g3KiYyKuKI8qGUmeKIFL6C2I X-Google-Smtp-Source: AGHT+IHkHF+TBF0CPf7bLj7iIcWhZ0waduptM9XuoJALZW51EWAlshMCajnfYZTMrakz7NOggg4qBQ== X-Received: by 2002:a9d:6a97:0:b0:6e6:715d:a63f with SMTP id l23-20020a9d6a97000000b006e6715da63fmr389091otq.30.1711555069987; Wed, 27 Mar 2024 08:57:49 -0700 (PDT) Received: from bob-pearson-dev.lan (2603-8081-1405-679b-b62e-99ff-fef9-fa2e.res6.spectrum.com. [2603:8081:1405:679b:b62e:99ff:fef9:fa2e]) by smtp.gmail.com with ESMTPSA id f10-20020a9d6c0a000000b006e6e3fdec53sm883487otq.35.2024.03.27.08.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:57:49 -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 v2 12/12] RDMA/rxe: Let destroy qp succeed with stuck packet Date: Wed, 27 Mar 2024 10:51:58 -0500 Message-ID: <20240327155157.590886-14-rpearsonhpe@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240327155157.590886-2-rpearsonhpe@gmail.com> References: <20240327155157.590886-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 the 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