Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1503269pxu; Sat, 5 Dec 2020 20:17:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFykQLl0ZkP4lAChFkt5NRcOEP0WDKvSz4sGTydBsONwkRqEFzBgBcagW+RF9fcxGjGnbo X-Received: by 2002:a50:d1d3:: with SMTP id i19mr14355069edg.72.1607228253264; Sat, 05 Dec 2020 20:17:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607228253; cv=none; d=google.com; s=arc-20160816; b=bdXjRjMcjlL5X6D6FBUJ9hYJ00VMnBpPCTdgFUcrjSypQ0R70uqUWJyxsn6RigmySU Aiu8ha+HmcVghNM9tGjbzlVt9TtdzBaFhz7tNieI+sKBFU/C7fl33LjXfHXl0Vd5Aa70 /Fo26o4M2f7f/RmzqbxJ5iMZqaBRYl+9WLDIhYXs+ev/50lmUJTPlamjhoeIUTjJMUss WOoBZViBIrCfX9jKsY8r8mwtYaPrctK0BVG/4ZH222Mra3D3kHXWx4VudlO/6lyi7VTF IkVcNz5R8ISNpscAqihvOhNUy/ibjLLgRJ48giMPnR62RR/BoVj+7OXl8jkKnAQKRe8/ AQ3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=ao+xFb0yC7DiD3o1YFIVKpIIu1IkYoSj63p4lHpWOH0=; b=k9GXBm3AfWygYDWuuxprm5tuTe2XQRQkpT4REo9HFwNuyyxJYv5vGvnMVeQ6Hot1cJ XF1XSsEl7BTciFiEcOjbZ6WuvRdOHYS0m0crzi4W+wpyrnfcL+v7ZQZYVswNqhCqGA/q FVuUB4fAr6vOiOmaDVOMYICMXyNHx4Hkg+w6p9SZcGl3CyfVSuSkBFK6WxZrD0yVGzsT Uq2x5vwnZCxDYCqgStBMq7EAq6TniqzaTSz8xDGot9bJuOJ1idx3lwiI3ruK4LsebBBN nvdBoTJSVVuH3BUtvCLuhlX99xEwFqmxjmTV7P3aEqqYE/lY7zjklZWMM04bAFPxkOH8 K//A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="VNs/msRI"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si4822288ejd.242.2020.12.05.20.17.10; Sat, 05 Dec 2020 20:17:33 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="VNs/msRI"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727700AbgLFEPk (ORCPT + 99 others); Sat, 5 Dec 2020 23:15:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbgLFEPJ (ORCPT ); Sat, 5 Dec 2020 23:15:09 -0500 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8438CC0613D4; Sat, 5 Dec 2020 20:14:29 -0800 (PST) Received: by mail-qt1-x841.google.com with SMTP id a6so4686644qtw.6; Sat, 05 Dec 2020 20:14:29 -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; bh=ao+xFb0yC7DiD3o1YFIVKpIIu1IkYoSj63p4lHpWOH0=; b=VNs/msRIjF+trubJiGmRCg2tSUbvPM6srfhbduYLLe/3dfmeiRGRMqUGgBtMxgAsAo G1pyrA4UiSy1iAvmciDlr4uwtX1ruKYxlOzHMEQ4h6L3mcIvaZwBq8Z/44Y/u7jZhv/i xGoNNZI12CddIUZ4vYOqIFLst1beD7gBu9MRkPlQabZVWdCtnqaqlu+ONRNnzV/8rZ5i ssOyBW6zxT1piWBqIsGOZuc1VaqL055/Kco9Bjs+xMAIn01+uQSl8z3YklF8KRAuEdlo zcm0cja/R52kSMMEJUuD6vQeNFbFTxQrVkt+M4kWtKaVPhCapmbE4XsEvbo7hd6N70+x Ze3g== 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; bh=ao+xFb0yC7DiD3o1YFIVKpIIu1IkYoSj63p4lHpWOH0=; b=QBa/q88j+wNt1so0PuCs9oGewH5tCFexi9a7ySEeQeT1C1RdUWHurh2Fa2JSwj84u2 INwb+aiBcI8tGqRree4ZPlmirAdkhlA3l3FLX/tdhItT9dszaVgFhKOLaVob3GXEML84 w7R2Kd4wd6F64cfz3WUPXovr4mktO7cw3oHrhbcygQRugelV5If4lJovBDD9e9vN91tb T1jIZSXaKTR4ecfxmLnza6TXL6q6qGj8SD7ua4xm4RU+9DTIwgeCBXr3WRECoNT8yZV5 tBm/SpxGEa+KJCQOSHChnltlhPeTrjk5U5Rvx3hw+KifD4z9JQdfZ2qD37jB1OPKpVu4 aqsQ== X-Gm-Message-State: AOAM532OLdKCz731/dCEn2PogI0MGDJZv1ot1DWLpvQU8/J6XcrNzZ2Y 5st1TJTw7v16zh5T9bR1JV0Ol3sabS3Lig== X-Received: by 2002:ae9:f816:: with SMTP id x22mr17217785qkh.291.1607226252096; Sat, 05 Dec 2020 19:44:12 -0800 (PST) Received: from localhost.localdomain ([198.52.185.246]) by smtp.gmail.com with ESMTPSA id z186sm9364566qke.100.2020.12.05.19.44.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 19:44:11 -0800 (PST) From: Sven Van Asbroeck X-Google-Original-From: Sven Van Asbroeck To: Bryan Whitehead , Microchip Linux Driver Support , David S Miller , Jakub Kicinski Cc: Sven Van Asbroeck , Andrew Lunn , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v1 1/2] lan743x: improve performance: fix rx_napi_poll/interrupt ping-pong Date: Sat, 5 Dec 2020 22:44:07 -0500 Message-Id: <20201206034408.31492-1-TheSven73@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sven Van Asbroeck Even if the rx ring is completely full, and there is more rx data waiting on the chip, the rx napi poll fn will never run more than once - it will always immediately bail out and re-enable interrupts. Which results in ping-pong between napi and interrupt. This defeats the purpose of napi, and is bad for performance. Fix by addressing two separate issues: 1. Ensure the rx napi poll fn always updates the rx ring tail when returning, even when not re-enabling interrupts. 2. Up to half of elements in a full rx ring are extension frames, which do not generate any skbs. Limit the default napi weight to the smallest no. of skbs that can be generated by a full rx ring. Tested-by: Sven Van Asbroeck # lan7430 Signed-off-by: Sven Van Asbroeck --- Tree: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git # 905b2032fa42 To: Bryan Whitehead To: Microchip Linux Driver Support To: "David S. Miller" To: Jakub Kicinski Cc: Andrew Lunn Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org drivers/net/ethernet/microchip/lan743x_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index 87b6c59a1e03..ebb5e0bc516b 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -2260,10 +2260,11 @@ static int lan743x_rx_napi_poll(struct napi_struct *napi, int weight) INT_BIT_DMA_RX_(rx->channel_number)); } +done: /* update RX_TAIL */ lan743x_csr_write(adapter, RX_TAIL(rx->channel_number), rx_tail_flags | rx->last_tail); -done: + return count; } @@ -2405,9 +2406,15 @@ static int lan743x_rx_open(struct lan743x_rx *rx) if (ret) goto return_error; + /* up to half of elements in a full rx ring are + * extension frames. these do not generate skbs. + * to prevent napi/interrupt ping-pong, limit default + * weight to the smallest no. of skbs that can be + * generated by a full rx ring. + */ netif_napi_add(adapter->netdev, &rx->napi, lan743x_rx_napi_poll, - rx->ring_size - 1); + (rx->ring_size - 1) / 2); lan743x_csr_write(adapter, DMAC_CMD, DMAC_CMD_RX_SWR_(rx->channel_number)); -- 2.17.1