Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1472185pxf; Fri, 2 Apr 2021 11:22:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIoXRX3d9MdfNbbivLQ1zJ7XmPtwhEbKKP3VlQfv5PLXeOhkYWSdEd7CZ8DCRN2/4dPQpK X-Received: by 2002:aa7:d841:: with SMTP id f1mr16744658eds.286.1617387772584; Fri, 02 Apr 2021 11:22:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617387772; cv=none; d=google.com; s=arc-20160816; b=zSwUM8mwjaP0+hD6PVyXnC76fNRqeQfSwRuG1xIx+N5+3Uji4m1jig5lGuCTgHf+j/ IK52kjKrfV7RF6ZerC45JngaOrly5GRQX0BAwkHSTHyeOeaZ/F7l8clK3XAC+GgDdOFV rRksqiHrs0Sg7+WlXKuUSxdHGbv/AKhnDzlIHT07G+gjtMu+t/ZB5nGZ72tPCjp83U93 D7xnJFedVgR5g7pPLjajjbzSDJo3MYucdpe8+QapxvuCoExqC3LWn/PfxUA3VMgbRHK5 0vCOb4ExpfUptIGJ+lMsUNH54VBvYt1wUIdUbXu38dL2PfKEAWv+SJUa/tRSwn7TIu2z LuXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Er0JvX9LJJW9NGmHRaC1luhAateCi8wCBUT1RypacVs=; b=bEAcbdK5EjtDi1BY9GT5JM7DSgSRZXg6i6B23AM01hMqhq/MMbWXiZV7p2um0AIUuK qp69gZ6bMX+to7/83I2B+xDfmY3J1EeGZeY/caXYt5VqiOr55mW1oS3+ajjTxyPUA6Th 4S1zFrSObT090b7l1om8kssFfBlSEtORtnWH4O+nunCvlAF+zpcTmki6prIq4u7gayE3 4KMcaHZrkdiUrSL9U7nH9YfkRxQUQbXirCuuZeIXIze83x7VnsLW+jOcZA7OF54asLk9 YNkzgHKJeX6n2HOYNjUssxkotjKHnJyJlA6BEzjaOPGvlRCz4TBnZd6rA5cMDJqJY3dY JbjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si6992033ejx.42.2021.04.02.11.22.28; Fri, 02 Apr 2021 11:22:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235286AbhDBSUh (ORCPT + 99 others); Fri, 2 Apr 2021 14:20:37 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:42731 "EHLO mail-wr1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbhDBSUh (ORCPT ); Fri, 2 Apr 2021 14:20:37 -0400 Received: by mail-wr1-f53.google.com with SMTP id x13so5377955wrs.9; Fri, 02 Apr 2021 11:20:35 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=Er0JvX9LJJW9NGmHRaC1luhAateCi8wCBUT1RypacVs=; b=isiNL5Uiunz3gxJ37Y1OVc2NoH7X0YFIW4o8BkhKTu/1x8HNTgrgI/chYntlPKXHwr EeMh3bOsmcahSD4NvozupoKahOA9D/tDX59QQtFi9j2kQ8YvNXFjZBxkjzR3+B3GBbsd vi46dceVagh53FqcafFm6COqB0nAc0FaYVC9SaRI4hXf7gO5X4Ww9yuhiMH1BY5HLPQY vfGoI7oDNPDE7Tx3MyfSpKxGYbES38MoAiUC7ZJaCqVnqawkEvCWSU9Ks6FXGUXnPU+s D3GmmYN5qhwZBA1+0AiTkgcUSdivsTMt0NCIjGFxQcM6JuimdT2WeZVCkBPXPIw9fvUv 8isg== X-Gm-Message-State: AOAM5319YlzgNUbYV2VzaJ/8Jp0UvEQ+wu82EfTNnylTXZQMNpwpr4kT Go7LUakCB6dQLNrsnYYjsByxifRLFdc= X-Received: by 2002:adf:e411:: with SMTP id g17mr16405180wrm.225.1617387634607; Fri, 02 Apr 2021 11:20:34 -0700 (PDT) Received: from msft-t490s.teknoraver.net (net-2-34-63-208.cust.vodafonedsl.it. [2.34.63.208]) by smtp.gmail.com with ESMTPSA id l9sm11472831wmq.2.2021.04.02.11.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Apr 2021 11:20:33 -0700 (PDT) From: Matteo Croce To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jonathan Lemon , "David S. Miller" , Ilias Apalodimas , Jesper Dangaard Brouer , Lorenzo Bianconi , Saeed Mahameed , David Ahern , Saeed Mahameed , Andrew Lunn Subject: [PATCH net-next v2 4/5] mvpp2: recycle buffers Date: Fri, 2 Apr 2021 20:17:32 +0200 Message-Id: <20210402181733.32250-5-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210402181733.32250-1-mcroce@linux.microsoft.com> References: <20210402181733.32250-1-mcroce@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matteo Croce Use the new recycling API for page_pool. In a drop rate test, the packet rate is more than doubled, from 962 Kpps to 2047 Kpps. perf top on a stock system shows: Overhead Shared Object Symbol 30.67% [kernel] [k] page_pool_release_page 8.37% [kernel] [k] get_page_from_freelist 7.34% [kernel] [k] free_unref_page 6.47% [mvpp2] [k] mvpp2_rx 4.69% [kernel] [k] eth_type_trans 4.55% [kernel] [k] __netif_receive_skb_core 4.40% [kernel] [k] build_skb 4.29% [kernel] [k] kmem_cache_free 4.00% [kernel] [k] kmem_cache_alloc 3.81% [kernel] [k] dev_gro_receive With packet rate stable at 962 Kpps: tx: 0 bps 0 pps rx: 477.4 Mbps 962.6 Kpps tx: 0 bps 0 pps rx: 477.6 Mbps 962.8 Kpps tx: 0 bps 0 pps rx: 477.6 Mbps 962.9 Kpps tx: 0 bps 0 pps rx: 477.2 Mbps 962.1 Kpps tx: 0 bps 0 pps rx: 477.5 Mbps 962.7 Kpps And this is the same output with recycling enabled: Overhead Shared Object Symbol 12.75% [mvpp2] [k] mvpp2_rx 9.56% [kernel] [k] __netif_receive_skb_core 9.29% [kernel] [k] build_skb 9.27% [kernel] [k] eth_type_trans 8.39% [kernel] [k] kmem_cache_alloc 7.85% [kernel] [k] kmem_cache_free 7.36% [kernel] [k] page_pool_put_page 6.45% [kernel] [k] dev_gro_receive 4.72% [kernel] [k] __xdp_return 3.06% [kernel] [k] page_pool_refill_alloc_cache With packet rate above 2000 Kpps: tx: 0 bps 0 pps rx: 1015 Mbps 2046 Kpps tx: 0 bps 0 pps rx: 1015 Mbps 2047 Kpps tx: 0 bps 0 pps rx: 1015 Mbps 2047 Kpps tx: 0 bps 0 pps rx: 1015 Mbps 2047 Kpps tx: 0 bps 0 pps rx: 1015 Mbps 2047 Kpps The major performance increase is explained by the fact that the most CPU consuming functions (page_pool_release_page, get_page_from_freelist and free_unref_page) are no longer called on a per packet basis. The test was done by sending to the macchiatobin 64 byte ethernet frames with an invalid ethertype, so the packets are dropped early in the RX path. Signed-off-by: Matteo Croce --- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index ec706d614cac..633b39cfef65 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -3847,6 +3847,7 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi, struct mvpp2_pcpu_stats ps = {}; enum dma_data_direction dma_dir; struct bpf_prog *xdp_prog; + struct xdp_rxq_info *rxqi; struct xdp_buff xdp; int rx_received; int rx_done = 0; @@ -3912,15 +3913,15 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi, else frag_size = bm_pool->frag_size; - if (xdp_prog) { - struct xdp_rxq_info *xdp_rxq; + if (bm_pool->pkt_size == MVPP2_BM_SHORT_PKT_SIZE) + rxqi = &rxq->xdp_rxq_short; + else + rxqi = &rxq->xdp_rxq_long; - if (bm_pool->pkt_size == MVPP2_BM_SHORT_PKT_SIZE) - xdp_rxq = &rxq->xdp_rxq_short; - else - xdp_rxq = &rxq->xdp_rxq_long; + if (xdp_prog) { + xdp.rxq = rxqi; - xdp_init_buff(&xdp, PAGE_SIZE, xdp_rxq); + xdp_init_buff(&xdp, PAGE_SIZE, rxqi); xdp_prepare_buff(&xdp, data, MVPP2_MH_SIZE + MVPP2_SKB_HEADROOM, rx_bytes, false); @@ -3964,7 +3965,7 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi, } if (pp) - page_pool_release_page(pp, virt_to_page(data)); + skb_mark_for_recycle(skb, virt_to_page(data), &rxqi->mem); else dma_unmap_single_attrs(dev->dev.parent, dma_addr, bm_pool->buf_size, DMA_FROM_DEVICE, -- 2.30.2