From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AF572A055A for ; Thu, 27 Feb 2020 10:34:16 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A70891BFD3; Thu, 27 Feb 2020 10:34:16 +0100 (CET) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by dpdk.org (Postfix) with ESMTP id CC2BE1BFD3 for ; Thu, 27 Feb 2020 10:34:14 +0100 (CET) Received: by mail-wm1-f67.google.com with SMTP id m3so2555814wmi.0 for ; Thu, 27 Feb 2020 01:34:14 -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 :mime-version:content-transfer-encoding; bh=fkuEACwR29K1w+gulpsqNOLPdoXMugK8iTUml+1J3Z0=; b=Hem4OuQQLPo1GZUn9o1vvGRlRVpk3AjYs032ntCE335EY77OFSfMnYx+fg1Axrug8o 2Gvjab1ztL5IJpXin/8Pk4284x4LMbzjhIMcJJDu/OBKtqUwlQOD7e/dz8pj18WeZH3+ alXGRyp/r9h3Ig5O7cidsrIZTpeNwPgzNsxNZ6gSl4l2AAqjuYB2gp4yq+23LxrHFG5W tvCZapJiBJMr+W9l93jB2ZkzjSfKe1JoS2JUoA8d35f6M+voE7lJDEhI8h7AuFZynet7 /uTnSeXd3UUSRNK7Zq3Nl+jfhbAKdE+mp+lbyXHxhgLqOrxHYSe3wtBvDRrQ1GK7r0y1 J/aw== 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=fkuEACwR29K1w+gulpsqNOLPdoXMugK8iTUml+1J3Z0=; b=PdW1G0vAHcpN24DJaX9abSxEyAM23BQLymmWPQVUH05vhhPqvws0HPshUbph4SxWjn SnqMIu/1cP9N4rOzOHtWyOp0D4FQC5tPDaAimlMIZTrn03xQMZo/m921AiTSzOGE8uhs U/BOROLUH89KDpFXSW2RnowZYMik8uMLTXOpHXJJVffNZY387D1TskW9zBjoy0pmMk0Z 5s6mh/+j91x8Zg958QXahhvHRt6SvfJVvrJxzDCtQcDHq1IxUUS83lrtEhOvdMQNQOJY WTudVH20den7QESCBx9gyS6MOPURan31aG8BbWIGsFzP+RIh1ZTEAkjHIvrAOXN7IRPF Z8qQ== X-Gm-Message-State: APjAAAWac958fzgkBVeFeWwcDFaBGTbJD7WG4d4+kEQcVo0QSt8/HlD4 UGEBpTps7rs4sXECKMdAPsQ= X-Google-Smtp-Source: APXvYqxNJFLc7sUp1Le0pf4Uo2ShNXh62L+0HRZgnzaK6A8g7WiKo061TNc1Il4CT0U2t9VOk98vhA== X-Received: by 2002:a05:600c:2942:: with SMTP id n2mr3986276wmd.87.1582796054408; Thu, 27 Feb 2020 01:34:14 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id j14sm7605733wrn.32.2020.02.27.01.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 01:34:13 -0800 (PST) From: luca.boccassi@gmail.com To: Tao Zhu Cc: Konstantin Ananyev , dpdk stable Date: Thu, 27 Feb 2020 09:33:24 +0000 Message-Id: <20200227093402.17690-4-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200227093402.17690-1-luca.boccassi@gmail.com> References: <20200217174546.25334-54-luca.boccassi@gmail.com> <20200227093402.17690-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/ixgbe: fix blocking system events' has been queued to stable release 19.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/29/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From b0c7e6d600deb39872ad82080c781aaf1b2ad316 Mon Sep 17 00:00:00 2001 From: Tao Zhu Date: Wed, 15 Jan 2020 19:38:48 +0000 Subject: [PATCH] net/ixgbe: fix blocking system events [ upstream commit 819d0d1d57f17aa40321648e99a50b49adc7bdf6 ] IXGBE link status task uses rte alarm thread in old implementation. Sometime ixgbe link status task takes up to 9 seconds. This will severely affect the rte-alarm-thread dependent tasks in the system, like interrupt or hotplug event. So replace with an independent thread which has the same thread affinity settings as rte interrupt. Fixes: 0408f47ba4d6 ("net/ixgbe: fix busy polling while fiber link update") Signed-off-by: Tao Zhu Acked-by: Konstantin Ananyev --- drivers/net/ixgbe/Makefile | 1 + drivers/net/ixgbe/ixgbe_ethdev.c | 50 +++++++++++++++++++++++++++----- drivers/net/ixgbe/ixgbe_ethdev.h | 2 ++ 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/drivers/net/ixgbe/Makefile b/drivers/net/ixgbe/Makefile index 85762e2f2a..31523025b3 100644 --- a/drivers/net/ixgbe/Makefile +++ b/drivers/net/ixgbe/Makefile @@ -57,6 +57,7 @@ endif LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_hash LDLIBS += -lrte_bus_pci +LDLIBS += -lpthread # # Add extra flags for base driver files (also known as shared code) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 1646b217a1..51fc0ff09f 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -229,7 +229,8 @@ static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev); static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev); static void ixgbe_dev_interrupt_handler(void *param); static void ixgbe_dev_interrupt_delayed_handler(void *param); -static void ixgbe_dev_setup_link_alarm_handler(void *param); +static void *ixgbe_dev_setup_link_thread_handler(void *param); +static void ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev); static int ixgbe_add_rar(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, @@ -1076,6 +1077,7 @@ ixgbe_swfw_lock_reset(struct ixgbe_hw *hw) static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) { + struct ixgbe_adapter *ad = eth_dev->data->dev_private; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; struct ixgbe_hw *hw = @@ -1127,6 +1129,7 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) return 0; } + rte_atomic32_clear(&ad->link_thread_running); rte_eth_copy_pci_info(eth_dev, pci_dev); /* Vendor and Device ID need to be set before init of shared code */ @@ -1565,6 +1568,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev) { int diag; uint32_t tc, tcs; + struct ixgbe_adapter *ad = eth_dev->data->dev_private; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; struct ixgbe_hw *hw = @@ -1605,6 +1609,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev) return 0; } + rte_atomic32_clear(&ad->link_thread_running); ixgbevf_parse_devargs(eth_dev->data->dev_private, pci_dev->device.devargs); @@ -2560,7 +2565,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); /* Stop the link setup handler before resetting the HW. */ - rte_eal_alarm_cancel(ixgbe_dev_setup_link_alarm_handler, dev); + ixgbe_dev_cancel_link_thread(dev); /* disable uio/vfio intr/eventfd mapping */ rte_intr_disable(intr_handle); @@ -2841,7 +2846,7 @@ ixgbe_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); - rte_eal_alarm_cancel(ixgbe_dev_setup_link_alarm_handler, dev); + ixgbe_dev_cancel_link_thread(dev); /* disable interrupts */ ixgbe_disable_intr(hw); @@ -4095,9 +4100,23 @@ out: } static void -ixgbe_dev_setup_link_alarm_handler(void *param) +ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev) +{ + struct ixgbe_adapter *ad = dev->data->dev_private; + void *retval; + + if (rte_atomic32_read(&ad->link_thread_running)) { + pthread_cancel(ad->link_thread_tid); + pthread_join(ad->link_thread_tid, &retval); + rte_atomic32_clear(&ad->link_thread_running); + } +} + +static void * +ixgbe_dev_setup_link_thread_handler(void *param) { struct rte_eth_dev *dev = (struct rte_eth_dev *)param; + struct ixgbe_adapter *ad = dev->data->dev_private; struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct ixgbe_interrupt *intr = IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private); @@ -4111,6 +4130,8 @@ ixgbe_dev_setup_link_alarm_handler(void *param) ixgbe_setup_link(hw, speed, true); intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; + rte_atomic32_clear(&ad->link_thread_running); + return NULL; } /* @@ -4151,6 +4172,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, int wait_to_complete, int vf) { struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct ixgbe_adapter *ad = dev->data->dev_private; struct rte_eth_link link; ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN; struct ixgbe_interrupt *intr = @@ -4196,8 +4218,20 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, if (link_up == 0) { if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) { intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; - rte_eal_alarm_set(10, - ixgbe_dev_setup_link_alarm_handler, dev); + if (rte_atomic32_test_and_set(&ad->link_thread_running)) { + if (rte_ctrl_thread_create(&ad->link_thread_tid, + "ixgbe-link-handler", + NULL, + ixgbe_dev_setup_link_thread_handler, + dev) < 0) { + PMD_DRV_LOG(ERR, + "Create link thread failed!"); + rte_atomic32_clear(&ad->link_thread_running); + } + } else { + PMD_DRV_LOG(ERR, + "Other link thread is running now!"); + } } return rte_eth_linkstatus_set(dev, &link); } @@ -5241,7 +5275,7 @@ ixgbevf_dev_start(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); /* Stop the link setup handler before resetting the HW. */ - rte_eal_alarm_cancel(ixgbe_dev_setup_link_alarm_handler, dev); + ixgbe_dev_cancel_link_thread(dev); err = hw->mac.ops.reset_hw(hw); if (err) { @@ -5339,7 +5373,7 @@ ixgbevf_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); - rte_eal_alarm_cancel(ixgbe_dev_setup_link_alarm_handler, dev); + ixgbe_dev_cancel_link_thread(dev); ixgbevf_intr_disable(dev); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index 76a1b9d184..318fbe6215 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -510,6 +510,8 @@ struct ixgbe_adapter { * mailbox status) link status. */ uint8_t pflink_fullchk; + rte_atomic32_t link_thread_running; + pthread_t link_thread_tid; }; struct ixgbe_vf_representor { -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-02-27 09:31:55.972344880 +0000 +++ 0004-net-ixgbe-fix-blocking-system-events.patch 2020-02-27 09:31:55.643945200 +0000 @@ -1,8 +1,10 @@ -From 819d0d1d57f17aa40321648e99a50b49adc7bdf6 Mon Sep 17 00:00:00 2001 +From b0c7e6d600deb39872ad82080c781aaf1b2ad316 Mon Sep 17 00:00:00 2001 From: Tao Zhu Date: Wed, 15 Jan 2020 19:38:48 +0000 Subject: [PATCH] net/ixgbe: fix blocking system events +[ upstream commit 819d0d1d57f17aa40321648e99a50b49adc7bdf6 ] + IXGBE link status task uses rte alarm thread in old implementation. Sometime ixgbe link status task takes up to 9 seconds. This will severely affect the rte-alarm-thread dependent tasks in the @@ -11,7 +13,6 @@ as rte interrupt. Fixes: 0408f47ba4d6 ("net/ixgbe: fix busy polling while fiber link update") -Cc: stable@dpdk.org Signed-off-by: Tao Zhu Acked-by: Konstantin Ananyev @@ -22,7 +23,7 @@ 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/drivers/net/ixgbe/Makefile b/drivers/net/ixgbe/Makefile -index 8b9d51f753..aec56a6807 100644 +index 85762e2f2a..31523025b3 100644 --- a/drivers/net/ixgbe/Makefile +++ b/drivers/net/ixgbe/Makefile @@ -57,6 +57,7 @@ endif @@ -34,7 +35,7 @@ # # Add extra flags for base driver files (also known as shared code) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c -index 2a248a3f27..0ef84a2861 100644 +index 1646b217a1..51fc0ff09f 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -229,7 +229,8 @@ static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev); @@ -47,7 +48,7 @@ static int ixgbe_add_rar(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, -@@ -1078,6 +1079,7 @@ ixgbe_swfw_lock_reset(struct ixgbe_hw *hw) +@@ -1076,6 +1077,7 @@ ixgbe_swfw_lock_reset(struct ixgbe_hw *hw) static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) { @@ -55,7 +56,7 @@ struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; struct ixgbe_hw *hw = -@@ -1129,6 +1131,7 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) +@@ -1127,6 +1129,7 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) return 0; } @@ -63,7 +64,7 @@ rte_eth_copy_pci_info(eth_dev, pci_dev); /* Vendor and Device ID need to be set before init of shared code */ -@@ -1567,6 +1570,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev) +@@ -1565,6 +1568,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev) { int diag; uint32_t tc, tcs; @@ -71,7 +72,7 @@ struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; struct ixgbe_hw *hw = -@@ -1607,6 +1611,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev) +@@ -1605,6 +1609,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev) return 0; } @@ -79,7 +80,7 @@ ixgbevf_parse_devargs(eth_dev->data->dev_private, pci_dev->device.devargs); -@@ -2563,7 +2568,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev) +@@ -2560,7 +2565,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); /* Stop the link setup handler before resetting the HW. */ @@ -88,7 +89,7 @@ /* disable uio/vfio intr/eventfd mapping */ rte_intr_disable(intr_handle); -@@ -2844,7 +2849,7 @@ ixgbe_dev_stop(struct rte_eth_dev *dev) +@@ -2841,7 +2846,7 @@ ixgbe_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); @@ -97,7 +98,7 @@ /* disable interrupts */ ixgbe_disable_intr(hw); -@@ -4098,9 +4103,23 @@ out: +@@ -4095,9 +4100,23 @@ out: } static void @@ -122,7 +123,7 @@ struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct ixgbe_interrupt *intr = IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private); -@@ -4114,6 +4133,8 @@ ixgbe_dev_setup_link_alarm_handler(void *param) +@@ -4111,6 +4130,8 @@ ixgbe_dev_setup_link_alarm_handler(void *param) ixgbe_setup_link(hw, speed, true); intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; @@ -131,7 +132,7 @@ } /* -@@ -4155,6 +4176,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, +@@ -4151,6 +4172,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, int wait_to_complete, int vf) { struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -139,7 +140,7 @@ struct rte_eth_link link; ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN; struct ixgbe_interrupt *intr = -@@ -4200,8 +4222,20 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, +@@ -4196,8 +4218,20 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, if (link_up == 0) { if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) { intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; @@ -162,7 +163,7 @@ } return rte_eth_linkstatus_set(dev, &link); } -@@ -5245,7 +5279,7 @@ ixgbevf_dev_start(struct rte_eth_dev *dev) +@@ -5241,7 +5275,7 @@ ixgbevf_dev_start(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); /* Stop the link setup handler before resetting the HW. */ @@ -171,7 +172,7 @@ err = hw->mac.ops.reset_hw(hw); if (err) { -@@ -5343,7 +5377,7 @@ ixgbevf_dev_stop(struct rte_eth_dev *dev) +@@ -5339,7 +5373,7 @@ ixgbevf_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); @@ -181,10 +182,10 @@ ixgbevf_intr_disable(dev); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h -index e1cd8fd16c..5089347a7e 100644 +index 76a1b9d184..318fbe6215 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h -@@ -511,6 +511,8 @@ struct ixgbe_adapter { +@@ -510,6 +510,8 @@ struct ixgbe_adapter { * mailbox status) link status. */ uint8_t pflink_fullchk;