From patchwork Mon Nov 16 11:12:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Karlsson X-Patchwork-Id: 325136 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 731BFC64E8A for ; Mon, 16 Nov 2020 12:37:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 30F7F20853 for ; Mon, 16 Nov 2020 12:37:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dm4Vnmqr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729485AbgKPLNq (ORCPT ); Mon, 16 Nov 2020 06:13:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728603AbgKPLNp (ORCPT ); Mon, 16 Nov 2020 06:13:45 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5E98C0613CF; Mon, 16 Nov 2020 03:13:45 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id j19so6107682pgg.5; Mon, 16 Nov 2020 03:13:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+SbxyZahfMfXnU/FChOm2quTfC2gyIuFdUfnHAtZnoI=; b=dm4VnmqrFU23MKn/TKtIS4x/rNBKQpkzivbC6Xa+MPM04MO8nbeTUZY8HTgfvYys1j EOYiVrhB58A2akTYPFjGXf7c2SMKcPDfdAOiRAGjSu+oOvaTYIfJ+Dk+od/gIVIu2D8r cbAXyVwzvuDEhe9GUS0IqSfIbRiAgw61hQ6AMbBpv7o2B07EiT2/VFrTgsIiM9Kj4YMs fMj06Fw8BwmdGHUA0QAA8rCG19HY4PSZu+iB0zY4NfNI9ZV19WWE+YrumAo01AqbuRyQ bNu465+g6EAYR8Rx3rjh4x/Z8Y+Y4BRhvMbr2o7xLXlnZC8QqcDlOa18ogeYc9eqYMMT MikQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+SbxyZahfMfXnU/FChOm2quTfC2gyIuFdUfnHAtZnoI=; b=sDj24V1ySvPnldSVJlt8pftQephcGpQF/gsi4ZIM2tEPeWVkEgx7h1JYSDXQe0vyyo Z3zcWrvxJCszVVAMHhidpgctKZf4s978qk2ZQve8CI0raby1P0bTMApwv7Gh0h87Brf1 oWjYqvu8SvJwdCRJelOfSB8wYA9FLzPzv7iEz6XNWIOpeXcdo988zF3ADNQCHds4h87B DIyE4zqKJ0jjL7Sf16s6KKcZdIJcdZVbjmP67bqW8INMp1u0G4n3+AdaYeF2Z8DJL6Ha 1r7xl/53d5S5Qx9AA/My/wvsG4CaZ7hy0XmFtn4BjT9pcICwkS4/xOKNnn0cIbhBbjTh 9yKw== X-Gm-Message-State: AOAM533VFtaIm/ajeQh+mraYWIouPUBtt0+AHx/QPs6XK43XxUOCbWR+ pjxPwSTdsfWF7+EYAyrumNM= X-Google-Smtp-Source: ABdhPJybPSvfextFY3UUIP4zrPkriv1bO8XhL0wD6bS3IGeBhbnbQ10ErLFdZ26Ko4b4QBOR6o+FWg== X-Received: by 2002:a17:90a:fd0d:: with SMTP id cv13mr15802905pjb.124.1605525225333; Mon, 16 Nov 2020 03:13:45 -0800 (PST) Received: from localhost.localdomain ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id u24sm19486826pfm.81.2020.11.16.03.13.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Nov 2020 03:13:44 -0800 (PST) From: Magnus Karlsson To: magnus.karlsson@intel.com, bjorn.topel@intel.com, ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org, jonathan.lemon@gmail.com, kuba@kernel.org, john.fastabend@gmail.com Cc: bpf@vger.kernel.org, jeffrey.t.kirsher@intel.com, anthony.l.nguyen@intel.com, maciej.fijalkowski@intel.com, maciejromanfijalkowski@gmail.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH bpf-next v3 1/5] samples/bpf: increment Tx stats at sending Date: Mon, 16 Nov 2020 12:12:43 +0100 Message-Id: <1605525167-14450-2-git-send-email-magnus.karlsson@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605525167-14450-1-git-send-email-magnus.karlsson@gmail.com> References: <1605525167-14450-1-git-send-email-magnus.karlsson@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Magnus Karlsson Increment the statistics over how many Tx packets have been sent at the time of sending instead of at the time of completion. This as a completion event means that the buffer has been sent AND returned to user space. The packet always gets sent shortly after sendto() is called. The kernel might, for performance reasons, decide to not return every single buffer to user space immediately after sending, for example, only after a batch of packets have been transmitted. Incrementing the number of packets sent at completion, will in that case be confusing as if you send a single packet, the counter might show zero for a while even though the packet has been transmitted. Signed-off-by: Magnus Karlsson Acked-by: John Fastabend --- samples/bpf/xdpsock_user.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c index 1149e94..2567f0d 100644 --- a/samples/bpf/xdpsock_user.c +++ b/samples/bpf/xdpsock_user.c @@ -1146,7 +1146,6 @@ static inline void complete_tx_l2fwd(struct xsk_socket_info *xsk, xsk_ring_prod__submit(&xsk->umem->fq, rcvd); xsk_ring_cons__release(&xsk->umem->cq, rcvd); xsk->outstanding_tx -= rcvd; - xsk->ring_stats.tx_npkts += rcvd; } } @@ -1168,7 +1167,6 @@ static inline void complete_tx_only(struct xsk_socket_info *xsk, if (rcvd > 0) { xsk_ring_cons__release(&xsk->umem->cq, rcvd); xsk->outstanding_tx -= rcvd; - xsk->ring_stats.tx_npkts += rcvd; } } @@ -1260,6 +1258,7 @@ static void tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, int batch_size) } xsk_ring_prod__submit(&xsk->tx, batch_size); + xsk->ring_stats.tx_npkts += batch_size; xsk->outstanding_tx += batch_size; *frame_nb += batch_size; *frame_nb %= NUM_FRAMES; @@ -1348,6 +1347,7 @@ static void l2fwd(struct xsk_socket_info *xsk, struct pollfd *fds) } return; } + xsk->ring_stats.rx_npkts += rcvd; ret = xsk_ring_prod__reserve(&xsk->tx, rcvd, &idx_tx); while (ret != rcvd) { @@ -1379,7 +1379,7 @@ static void l2fwd(struct xsk_socket_info *xsk, struct pollfd *fds) xsk_ring_prod__submit(&xsk->tx, rcvd); xsk_ring_cons__release(&xsk->rx, rcvd); - xsk->ring_stats.rx_npkts += rcvd; + xsk->ring_stats.tx_npkts += rcvd; xsk->outstanding_tx += rcvd; } From patchwork Mon Nov 16 11:12:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Karlsson X-Patchwork-Id: 325135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C808CC8302B for ; Mon, 16 Nov 2020 12:37:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83A6020853 for ; Mon, 16 Nov 2020 12:37:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TIcuSgUW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729633AbgKPLNv (ORCPT ); Mon, 16 Nov 2020 06:13:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728211AbgKPLNu (ORCPT ); Mon, 16 Nov 2020 06:13:50 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF46C0613CF; Mon, 16 Nov 2020 03:13:50 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id b3so8196887pls.11; Mon, 16 Nov 2020 03:13:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=44RUaPFcwFiB3nkeuTIXUu39UgaMmkBucMAXuU99ZwQ=; b=TIcuSgUWSWuwn2Jjx1KnB6sHrdeMikkoB9olf3FVb3jeqC3BzKywc7h6cKpbHMBeX3 +NEr1FzsgcBQBmtEwqaNPYoOya73w9zL+Q90R2ToYPhHOsPcvJesPpVSyjwmnxm0LpJN 1QXDy+xlDUxI9Nu8Sw+nfSJ5trm8df+m7JZhLzjAQknzTVRjM3byAfcJqtOeDYoHg7+9 HTK20aO3/V2kwQWHCWudepK15mqqNhP/wJwxPayM6HtQGGDZskemvInKngX5aDttsBdP iw8ua714FhhRDHCdNCl3+rbbG7pUQk/XSXEnBP/DjOucqNkTTo0OTG+T7Oj0b1sQUR1p /rmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=44RUaPFcwFiB3nkeuTIXUu39UgaMmkBucMAXuU99ZwQ=; b=hnC4DjkcSCuLH/YToLtSAh3QFkBqC341dPv7XWSZSR26QBYvwhIub7EAkFW7qCOPD5 Xho9Wu2Z3C+F8wWFPNYrXpXhS6ho34WqhYCHpL7xuIi+dzkd1RScnpBmpcSvWSM7pHbZ 11F+d6RMMR6PRnBgSi9GRUUQS8yuM9f7xnbflCOOu/OIuwtyc+8XDx2u9R8Gyn4LFB3z /7igP7cqvD1BAudzz5j6YOozvwtfnVioa7kFjibO1v9Lcy9sDjSiC//48Eu9wtdz1UAK kYkNS3QEheEBrKsAskunY3VrH76SeP3IWiPtalCHGVKcjbiTS3bvUZzy3oyJudKmhTc+ oDpA== X-Gm-Message-State: AOAM533O/AHffv50KY2ZUYqsSL9unQsyHnAXBXWfnllLQGAG6njDSE5v Bb+h2E14duFwe1/vLYHllUY= X-Google-Smtp-Source: ABdhPJyZfCFm7Pec1GQujbx90ewEdjqUNaZF5VJN51QlLDhc5+u0TOr06c1NI6pNZtLBSC/TZGogQQ== X-Received: by 2002:a17:902:361:b029:d7:cd0b:e6f2 with SMTP id 88-20020a1709020361b02900d7cd0be6f2mr12816425pld.77.1605525230298; Mon, 16 Nov 2020 03:13:50 -0800 (PST) Received: from localhost.localdomain ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id u24sm19486826pfm.81.2020.11.16.03.13.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Nov 2020 03:13:49 -0800 (PST) From: Magnus Karlsson To: magnus.karlsson@intel.com, bjorn.topel@intel.com, ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org, jonathan.lemon@gmail.com, kuba@kernel.org, john.fastabend@gmail.com Cc: bpf@vger.kernel.org, jeffrey.t.kirsher@intel.com, anthony.l.nguyen@intel.com, maciej.fijalkowski@intel.com, maciejromanfijalkowski@gmail.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH bpf-next v3 2/5] i40e: remove unnecessary sw_ring access from xsk Tx Date: Mon, 16 Nov 2020 12:12:44 +0100 Message-Id: <1605525167-14450-3-git-send-email-magnus.karlsson@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605525167-14450-1-git-send-email-magnus.karlsson@gmail.com> References: <1605525167-14450-1-git-send-email-magnus.karlsson@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Magnus Karlsson Remove the unnecessary access to the software ring for the AF_XDP zero-copy driver. This was used to record the length of the packet so that the driver Tx completion code could sum this up to produce the total bytes sent. This is now performed during the transmission of the packet, so no need to record this in the software ring. Signed-off-by: Magnus Karlsson Acked-by: John Fastabend --- drivers/net/ethernet/intel/i40e/i40e_xsk.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c index 567fd67..20d2632 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c @@ -392,7 +392,6 @@ static bool i40e_xmit_zc(struct i40e_ring *xdp_ring, unsigned int budget) { unsigned int sent_frames = 0, total_bytes = 0; struct i40e_tx_desc *tx_desc = NULL; - struct i40e_tx_buffer *tx_bi; struct xdp_desc desc; dma_addr_t dma; @@ -404,9 +403,6 @@ static bool i40e_xmit_zc(struct i40e_ring *xdp_ring, unsigned int budget) xsk_buff_raw_dma_sync_for_device(xdp_ring->xsk_pool, dma, desc.len); - tx_bi = &xdp_ring->tx_bi[xdp_ring->next_to_use]; - tx_bi->bytecount = desc.len; - tx_desc = I40E_TX_DESC(xdp_ring, xdp_ring->next_to_use); tx_desc->buffer_addr = cpu_to_le64(dma); tx_desc->cmd_type_offset_bsz = @@ -415,7 +411,7 @@ static bool i40e_xmit_zc(struct i40e_ring *xdp_ring, unsigned int budget) 0, desc.len, 0); sent_frames++; - total_bytes += tx_bi->bytecount; + total_bytes += desc.len; xdp_ring->next_to_use++; if (xdp_ring->next_to_use == xdp_ring->count)