From patchwork Thu Jun 29 22:09:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: longli@linuxonhyperv.com X-Patchwork-Id: 114462 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9949452vqr; Thu, 29 Jun 2023 15:22:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlF8KCFO7QquLBt/BIH2pIJo7uBuBFJyd4vRPBz5/OhyYQjvMG9jKl4nYBVezaN7FT7jRvkd X-Received: by 2002:a05:6a00:1d05:b0:67d:308b:97ef with SMTP id a5-20020a056a001d0500b0067d308b97efmr1233586pfx.2.1688077327599; Thu, 29 Jun 2023 15:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688077327; cv=none; d=google.com; s=arc-20160816; b=WubAKDJ5O5gsJiSsImuxVQw4alwaKvvuzGix2varwBz9AZ4S+Bbh4KaahQcYfdb6mn Ql4q2l9wHyTAiH0igtArOCfPZQ5tL3T/3cd3iITE/8+GsNuioxVQsrAc2ZpLT/Lbxu3r WiCuBhn2li810mHJnH0EZSJ+2Vj0XMQkMmvSN87RVy/dZqwvg6/IavWYJ7hJig9GHpI/ tFJJEZuf2xHghqg7vMVvQeouc/FcVMFDnbEbKDcU/NKI7K0q7/XU4sdTR/UMZj0Vq1vu Srhz07ZS5q6XmnIu7r3M5htx2pTGlWh0HEIyPcK/uGpWdrAz/hw9o85xuH6wHQcD3Tc2 lyIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature:dkim-filter; bh=BKDtaYT+zbLI1TSAymoJ7YKaz9ZHdNfBW0iqigA2SuE=; fh=YiLWLbt9AyPVMVZuk1otT49UqAfek5CAeZ4PLLtfDgc=; b=a5LHLYbQacwJI51x5hrDYqHChg8580ZXbX+Y8u7Z8DLbD1CEsBnrWEHisLBmjTehTF FNGqpJzCwmd1GWOl4HzFF4W6cFbxTqZoMBWkhsx5K4vFg1uqupAa1NpVavueCTdu078e ukqdGyXWPocG/2kdp8m3NmQB1cWiEmMdZqLhz086jR3tgS+XCnuwMBQUnA+iCyjlPMbo 7OhTIr3usCP72x/2sFR++Teq69YXnUoqTnCnS8HyTXVnON769WmuoY48uYhbm7MNlnVu OeCdIiefoioyKAIwhuuG+2Ry8C9CRITS8mZlA7sYKRKsJPbc29RIxIbLZ35LG62jVzxw /D0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=HQloIh6E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w136-20020a627b8e000000b006689f89b186si10581070pfc.208.2023.06.29.15.21.52; Thu, 29 Jun 2023 15:22:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=HQloIh6E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232285AbjF2WKC (ORCPT + 99 others); Thu, 29 Jun 2023 18:10:02 -0400 Received: from linux.microsoft.com ([13.77.154.182]:41668 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232213AbjF2WJ4 (ORCPT ); Thu, 29 Jun 2023 18:09:56 -0400 Received: by linux.microsoft.com (Postfix, from userid 1004) id 5149E208396A; Thu, 29 Jun 2023 15:09:55 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5149E208396A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1688076595; bh=BKDtaYT+zbLI1TSAymoJ7YKaz9ZHdNfBW0iqigA2SuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HQloIh6EgT3FUTVcllOIP2gKT7M5f4+4HRbIFevacgN7I4uhqpwc39c3Sen7pmFKg rQUbY+b+gzQDnvOgsPoyhBKqBrTROXo+howV8WJOHt0pH5lVX1qZ/15GtDCFkhz2dD 6HlL3tzecMbH8/hixVgOhVXrRxH7pQrDCTUF8UnE= From: longli@linuxonhyperv.com To: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Leon Romanovsky , Shradha Gupta , Ajay Sharma , Shachar Raindel , Stephen Hemminger , linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-rdma@vger.kernel.org, Long Li , stable@vger.kernel.org Subject: [PATCH net v4 1/2] net: mana: Batch ringing RX queue doorbell on receiving packets Date: Thu, 29 Jun 2023 15:09:30 -0700 Message-Id: <1688076571-24938-2-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1688076571-24938-1-git-send-email-longli@linuxonhyperv.com> References: <1688076571-24938-1-git-send-email-longli@linuxonhyperv.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770077372040371693?= X-GMAIL-MSGID: =?utf-8?q?1770077372040371693?= From: Long Li It's inefficient to ring the doorbell page every time a WQE is posted to the received queue. Excessive MMIO writes result in CPU spending more time waiting on LOCK instructions (atomic operations), resulting in poor scaling performance. Move the code for ringing doorbell page to where after we have posted all WQEs to the receive queue during a callback from napi_poll(). With this change, tests showed an improvement from 120G/s to 160G/s on a 200G physical link, with 16 or 32 hardware queues. Tests showed no regression in network latency benchmarks on single connection. Cc: stable@vger.kernel.org Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)") Reviewed-by: Haiyang Zhang Reviewed-by: Dexuan Cui Signed-off-by: Long Li --- Change log: v2: Check for comp_read > 0 as it might be negative on completion error. Set rq.wqe_cnt to 0 according to BNIC spec. v3: Add details in the commit on the reason of performance increase and test numbers. Add details in the commit on why rq.wqe_cnt should be set to 0 according to hardware spec. Add "Reviewed-by" from Haiyang and Dexuan. v4: Split the original patch into two: one for batching doorbell, one for setting the correct wqe count drivers/net/ethernet/microsoft/mana/mana_en.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index cd4d5ceb9f2d..1d8abe63fcb8 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -1383,8 +1383,8 @@ static void mana_post_pkt_rxq(struct mana_rxq *rxq) recv_buf_oob = &rxq->rx_oobs[curr_index]; - err = mana_gd_post_and_ring(rxq->gdma_rq, &recv_buf_oob->wqe_req, - &recv_buf_oob->wqe_inf); + err = mana_gd_post_work_request(rxq->gdma_rq, &recv_buf_oob->wqe_req, + &recv_buf_oob->wqe_inf); if (WARN_ON_ONCE(err)) return; @@ -1654,6 +1654,12 @@ static void mana_poll_rx_cq(struct mana_cq *cq) mana_process_rx_cqe(rxq, cq, &comp[i]); } + if (comp_read > 0) { + struct gdma_context *gc = rxq->gdma_rq->gdma_dev->gdma_context; + + mana_gd_wq_ring_doorbell(gc, rxq->gdma_rq); + } + if (rxq->xdp_flush) xdp_do_flush(); } From patchwork Thu Jun 29 22:09:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: longli@linuxonhyperv.com X-Patchwork-Id: 114461 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9947718vqr; Thu, 29 Jun 2023 15:18:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlF76tleXdK3r4L8Bx3O+kD2q2MUhHgA/d7CucNNzVPU7KO0BIghe7EYok7R9n6GjT7obGd6 X-Received: by 2002:a05:6a00:138a:b0:675:8521:ddc7 with SMTP id t10-20020a056a00138a00b006758521ddc7mr1371163pfg.0.1688077098708; Thu, 29 Jun 2023 15:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688077098; cv=none; d=google.com; s=arc-20160816; b=ScScUjFSZFbXomFnulkGj/8V8cTsEMl4DjEt6aedKz8AKv3IhcGs+jQnIw4npQkuci vWScPjkVRqkydbafYExl5m5nOBNXgj5BRKVAZKIUSgNvUhjOjtwzGO+eFqX5HERXFfxe B5VEGfXB4yGOkkQ9mzwtCe+n5TczRL9KyKr3gqI0aB8xtTGWinyi/I4x2qin8pKXEBUo 9mqhD75aMNUlHhTYJPRtpbblJRFjYZATqAucxK6Dua9a+quhDOyoUp1gGnBCbIh43RSb UVXA/6k2rMSWmO2O4u/gq+C0Aig/kLDNM+D3lyAgBHy5QVdJz6x2AA45D4QnCG7hE0cD iT7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature:dkim-filter; bh=sNVCTU5gFBqe2BQjTeFzfJALosLnCbsvG4CoTL1NyEs=; fh=YiLWLbt9AyPVMVZuk1otT49UqAfek5CAeZ4PLLtfDgc=; b=z1JXlv/N+8ipYg6ZdyOvRpcIOULYMegNf/A59ZAkViW3KAVkCvgKgrZBIyeYApRuqE DiBDEpI4PXgMPiBKTzaumDAousql1+010obI0bDflyExkp+FvdyflHfWybSdfa1d3cDw QaLyyb/LU8qYyicEMVweFXqG+1e7KLA84rVp9Xph2BQ7Kpuy1HP31C09gRT1Nk80pYXp KDXxFDoeeC++WYOmpXcSLGFesqDXfSYH59uw7WWJTqdN0bi3pnX5Pzo6ZXpXl8JZUy0X 4vSYjQtYUdFLuGkqPUQnkeaA18wW6cuza3yKxpcgefEqHmoCjdh+GaOrjSkXZ9tu3X0q yxlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=FDaBTtSq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o3-20020a056a0015c300b0067a39a4c12bsi7271094pfu.81.2023.06.29.15.18.04; Thu, 29 Jun 2023 15:18:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=FDaBTtSq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232316AbjF2WKF (ORCPT + 99 others); Thu, 29 Jun 2023 18:10:05 -0400 Received: from linux.microsoft.com ([13.77.154.182]:41696 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230012AbjF2WJ5 (ORCPT ); Thu, 29 Jun 2023 18:09:57 -0400 Received: by linux.microsoft.com (Postfix, from userid 1004) id 20A7220AECAD; Thu, 29 Jun 2023 15:09:56 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 20A7220AECAD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1688076596; bh=sNVCTU5gFBqe2BQjTeFzfJALosLnCbsvG4CoTL1NyEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FDaBTtSqHtUX0HV8fAgs5RDMLHjO7gn4fSzK5XPajhYEnBJnZnjChdh81UVoWPqro DRLG+Vx8mrN3oaM/KcdZMq2puu07wo5Eajn+HxTooK1XuAfynP0YfMvXqQRJ9+2xWv +w/ReMKXpbzZcy6YvSZRQPqWoVvNVBszicCyAvA8= From: longli@linuxonhyperv.com To: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Leon Romanovsky , Shradha Gupta , Ajay Sharma , Shachar Raindel , Stephen Hemminger , linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-rdma@vger.kernel.org, Long Li , stable@vger.kernel.org Subject: [PATCH net v4 2/2] net: mana: Use the correct WQE count for ringing RQ doorbell Date: Thu, 29 Jun 2023 15:09:31 -0700 Message-Id: <1688076571-24938-3-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1688076571-24938-1-git-send-email-longli@linuxonhyperv.com> References: <1688076571-24938-1-git-send-email-longli@linuxonhyperv.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770077131802436382?= X-GMAIL-MSGID: =?utf-8?q?1770077131802436382?= From: Long Li The hardware specification specifies that WQE_COUNT should set to 0 for the Receive Queue. Although currently the hardware doesn't enforce the check, in the future releases it may check on this value. Cc: stable@vger.kernel.org Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)") Reviewed-by: Haiyang Zhang Reviewed-by: Dexuan Cui Signed-off-by: Long Li --- Change log: v4: Split the original patch into two: one for batching doorbell, one for setting the correct wqe count drivers/net/ethernet/microsoft/mana/gdma_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c index 8f3f78b68592..3765d3389a9a 100644 --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c @@ -300,8 +300,11 @@ static void mana_gd_ring_doorbell(struct gdma_context *gc, u32 db_index, void mana_gd_wq_ring_doorbell(struct gdma_context *gc, struct gdma_queue *queue) { + /* Hardware Spec specifies that software client should set 0 for + * wqe_cnt for Receive Queues. This value is not used in Send Queues. + */ mana_gd_ring_doorbell(gc, queue->gdma_dev->doorbell, queue->type, - queue->id, queue->head * GDMA_WQE_BU_SIZE, 1); + queue->id, queue->head * GDMA_WQE_BU_SIZE, 0); } void mana_gd_ring_cq(struct gdma_queue *cq, u8 arm_bit)