From patchwork Wed Nov 30 22:28:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13060535 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C724C4321E for ; Wed, 30 Nov 2022 22:28:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229515AbiK3W2e (ORCPT ); Wed, 30 Nov 2022 17:28:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbiK3W2d (ORCPT ); Wed, 30 Nov 2022 17:28:33 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E97C87CB4 for ; Wed, 30 Nov 2022 14:28:32 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id bx10so17333568wrb.0 for ; Wed, 30 Nov 2022 14:28:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=IGscC1rUWwmTgf/GwAQgW38qphQwkOXIg/FIfZskjKg=; b=bI85drhItddLA/cWnjA3uahNVT2RhEpp184gQT7URXkGtwERm12ABXi0Nkvfd9kOO5 gzHfpT0TDaQV9FsgP5/s0g/DbFg+4mCU+efW4ODFv1IMDnwzKcbkt8ZPP6wfx//CMVde WK+xzyfrWzWShiMk6YX39AcQciAz0OQa6BirTV9b2PoqL4O733QSgDZM5vMOM0BLBeY2 3MDAGkeyq/2yCeolnbSwO4QagnG7MXPFcnSpz5gb2LJSVpQtaC0CBhchjfBayt6UHPB2 NHzVg9DbFvx4Ra5GrqSAyKGmdnFmcbG2vV8S/Q342hlavw0CdOeQRmp0TelYEX9dm3VL dYbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IGscC1rUWwmTgf/GwAQgW38qphQwkOXIg/FIfZskjKg=; b=gsOv1JHypC1Mpi4YVF73i8dWBF1E33rJNbWsA9nRGgfPX2pXyWk19UffgJU1UI1iTB BFO78C1fHBZPBM52B3fUPPnBd9bqPcpIyTc94RfIP8fN2WtQPgTGTJWqW9l82xUP0pAz LxRUKMw+1D80WtzaaumzgAjx/nTdhZTLmxyDM4ZJSf4cKO148o2cBYTWNL6xhjP3tpDb MOkE6yUwraKbvYp5clHjDOWBp4QHNq9Mwxn7axvNt13iJ7XSt3SStBgWrOS7CcbHdujI 8ngoW/aLl0s2caztY4YZjCBhGDxMrP1QhcARUPGDFAE4CaWzvQCUqIu43tc7Gu9DyKu7 htbQ== X-Gm-Message-State: ANoB5pnPr+vQhVLZin2hSNhTIDtnfXuyE1x4jQ9lf83CpFvWf75QhKrM TtB/D82piDcYZpcYiU6W312N8+50J0k= X-Google-Smtp-Source: AA0mqf5qZrp53WjcZeeLi0V11okdCWPA92CIu/frcEok9YvWRFzhMcfrUn6sPXvhz+C6hoUNQgviQw== X-Received: by 2002:a5d:4301:0:b0:242:2572:cd98 with SMTP id h1-20020a5d4301000000b002422572cd98mr5626813wrq.522.1669847310249; Wed, 30 Nov 2022 14:28:30 -0800 (PST) Received: from ?IPV6:2a01:c22:77d6:e700:1465:fbc6:a2a6:9b65? (dynamic-2a01-0c22-77d6-e700-1465-fbc6-a2a6-9b65.c22.pool.telefonica.de. [2a01:c22:77d6:e700:1465:fbc6:a2a6:9b65]) by smtp.googlemail.com with ESMTPSA id y5-20020a056000108500b00241d544c9b1sm3094533wrw.90.2022.11.30.14.28.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Nov 2022 14:28:29 -0800 (PST) Message-ID: <783fca17-450f-c69f-46dc-8ed7394be03d@gmail.com> Date: Wed, 30 Nov 2022 23:28:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: [PATCH net-next 1/2] net: add netdev_sw_irq_coalesce_default_on() Content-Language: en-US From: Heiner Kallweit To: Jakub Kicinski , David Miller , Realtek linux nic maintainers , Eric Dumazet , Paolo Abeni Cc: "netdev@vger.kernel.org" References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add a helper for drivers wanting to set SW IRQ coalescing by default. The related sysfs attributes can be used to override the default values. Follow Jakub's suggestion and put this functionality into net core so that drivers wanting to use software interrupt coalescing per default don't have to open-code it. Note that this function needs to be called before the netdevice is registered. Suggested-by: Jakub Kicinski Signed-off-by: Heiner Kallweit --- include/linux/netdevice.h | 1 + net/core/dev.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 02a2318da..5be4b6a3b 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -78,6 +78,7 @@ struct xdp_buff; void synchronize_net(void); void netdev_set_default_ethtool_ops(struct net_device *dev, const struct ethtool_ops *ops); +void netdev_sw_irq_coalesce_default_on(struct net_device *dev); /* Backlog congestion levels */ #define NET_RX_SUCCESS 0 /* keep 'em coming, baby */ diff --git a/net/core/dev.c b/net/core/dev.c index 117e830ca..cc6bbc0a3 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10537,6 +10537,22 @@ void netdev_set_default_ethtool_ops(struct net_device *dev, } EXPORT_SYMBOL_GPL(netdev_set_default_ethtool_ops); +/** + * netdev_sw_irq_coalesce_default_on() - enable SW IRQ coalescing by default + * @dev: netdev to enable the IRQ coalescing on + * + * Sets a conservative default for SW IRQ coalescing. Users can use + * sysfs attributes to override the default values. + */ +void netdev_sw_irq_coalesce_default_on(struct net_device *dev) +{ + WARN_ON(dev->reg_state == NETREG_REGISTERED); + + dev->gro_flush_timeout = 20000; + dev->napi_defer_hard_irqs = 1; +} +EXPORT_SYMBOL_GPL(netdev_sw_irq_coalesce_default_on); + void netdev_freemem(struct net_device *dev) { char *addr = (char *)dev - dev->padded; From patchwork Wed Nov 30 22:30:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 13060536 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A9A0C352A1 for ; Wed, 30 Nov 2022 22:30:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229534AbiK3WaX (ORCPT ); Wed, 30 Nov 2022 17:30:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbiK3WaV (ORCPT ); Wed, 30 Nov 2022 17:30:21 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 390EF92A06 for ; Wed, 30 Nov 2022 14:30:21 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id w15so16217197wrl.9 for ; Wed, 30 Nov 2022 14:30:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=BDZzkQyiysskVYuTmzk+3p8oEPfSeUMrQN2y4xwT6XA=; b=cFrSjsl8EK1KAIsc+wU2QsmBJVDEeLl2vCCqIzZhGKe+EZ69aHwTwSMcS7CQ5FT8YQ N3gYRqQMi8asM2ntcuO8HrUToowvq56lvPhtOEc1niogreQMTpkAg/JwB7WgkR7/brW/ UwkNAYylStTKndl6p9+RY3Xsujsu2HKcAt5zQ6N8taPCAtQ56sZ9LmX1DroutB+mD4kX cZHtEs5Pglx90ARr2hQuWRepLXuQ64TRqRx1Zt2IQ9qzrBqFR6Td3FtSXKiarIdZsElG 9JneyjXSQvRuZBx4VzwqGkG7A2ByLqVQklkSEr73jq7VJxUkP8iHzJc0HLjAQOGS5VLq 4bwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BDZzkQyiysskVYuTmzk+3p8oEPfSeUMrQN2y4xwT6XA=; b=ecV6lHC2gMcnSar0HUtHolUfSiKTO9yoeC2bRxQB2VwhpVuDG469a42fznoXol2vxw 5x5iNGRSL0+TIpPdNP3Q9EPkAdtI2D9x0F/tcm7ByTJ7Yv0R+OYSk9KbHwXpU41Iod5e b/OHvkIXZwfh7PG59Q7gEGIO090j/AO+y0gwGCAmA50t0+gauVP55kjSxaCpvChspUgi SdLDObeOw2hNAuqw6hpU3dePEGezi3uJT7tOLfL5rwnX+kjhwXtkefjMLnuhXevIbGvO a+Hcmn1Gl3vij8W9inrjFXUZf5DEhVMJyozh9prUROmDshmdV6H2yxyDH54GKUdI0Xju hH7A== X-Gm-Message-State: ANoB5pkjZJyUN0omYaqYB/awoU1tOcCElFjEgP9ZJMbie8ky3+61Bsvd +GIRUBUd25Xrmz6lf9EmkdooqqiGWpQ= X-Google-Smtp-Source: AA0mqf4IxPhbse1MY214EEX+p8gciIeUWMLok7GkftpmhKtcc9Ro9XYh0vy37NksT8fG+G+xAiPZfw== X-Received: by 2002:a05:6000:1811:b0:242:310a:300b with SMTP id m17-20020a056000181100b00242310a300bmr2198520wrh.698.1669847419666; Wed, 30 Nov 2022 14:30:19 -0800 (PST) Received: from ?IPV6:2a01:c22:77d6:e700:1465:fbc6:a2a6:9b65? (dynamic-2a01-0c22-77d6-e700-1465-fbc6-a2a6-9b65.c22.pool.telefonica.de. [2a01:c22:77d6:e700:1465:fbc6:a2a6:9b65]) by smtp.googlemail.com with ESMTPSA id hg6-20020a05600c538600b003a6125562e1sm3177413wmb.46.2022.11.30.14.30.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Nov 2022 14:30:19 -0800 (PST) Message-ID: Date: Wed, 30 Nov 2022 23:30:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: [PATCH net-next 2/2] r8169: enable GRO software interrupt coalescing per default Content-Language: en-US From: Heiner Kallweit To: Jakub Kicinski , David Miller , Realtek linux nic maintainers , Eric Dumazet , Paolo Abeni Cc: "netdev@vger.kernel.org" References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There are reports about r8169 not reaching full line speed on certain systems (e.g. SBC's) with a 2.5Gbps link. There was a time when hardware interrupt coalescing was enabled per default, but this was changed due to ASPM-related issues on few systems. So let's use software interrupt coalescing instead and enable it using new function netdev_sw_irq_coalesce_default_on(). Even with these conservative settings interrupt load on my 1Gbps test system reduced significantly. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 5bc1181f8..f4e160888 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -5282,6 +5282,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev->hw_features |= NETIF_F_RXALL; dev->hw_features |= NETIF_F_RXFCS; + netdev_sw_irq_coalesce_default_on(dev); + /* configure chip for default features */ rtl8169_set_features(dev, dev->features);