From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id 3B5062C15 for ; Thu, 31 Aug 2017 11:45:10 +0200 (CEST) Received: by mail-wm0-f49.google.com with SMTP id f127so1115673wmf.1 for ; Thu, 31 Aug 2017 02:45:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VU8X5pUgSRptCO6ISNkwSQrXznWMdEMs+vbVSmDuGeY=; b=fk2B0K7Blu9ho3zXqd0QVZH2H3qEKCH87L0SdlgHtLmf1E8PznfbU/EJvOQYn/kxe9 oWFMV+moetMLxOY6ACBrU5bwqav/g9YB9Xa4aN9LLXcI3F8DFF03G7EBJNiMkUULNOf6 KHGR0zvMOcseCXwEPwRAnX7eDAOKStaZIna/czbnwh/eCZw2u0xarLEzRIgx7Q7ZdTbm j4g9tP04Ag8pl3OdE4Kdg2LLPmOWn5MfxEh5yMR9uLtJAOdQt1Z1jH3/P3GHDXnRGo5/ P2zuzTqo16zjh4NROMbkpYVqC4pzNT7En+YALN7ZuNaS/Qv6PKDzzzRiFqUfyiksb/GH /MlA== 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=VU8X5pUgSRptCO6ISNkwSQrXznWMdEMs+vbVSmDuGeY=; b=uQm/OyFbNeZDX3C7JaZQtZrXamcnulSn4Y8yd2o5lAkdZh+ixTEpitaaKnFVTypRVt vTgb7kEqqvrVwNM2DotJXAB4iKZbtmWFAIZoDJR3hmllLeJpUDWx+RJyw0VmpTrzHsML VLAVGR9SaOjLCC4W/fw8G+0rE27rA3nvcBiZVk6X331V5g1q2g3ov7t8ZdwLtz6r9rDo oj9eV7qLof4U1fXPQUWvHFZF7oJmsv5JWPv8f3EZ6lOaIMCMYVE85iDNoAZdcLGbHIDq 6q3Zh5s4lDfgtIXTVh+AMwS334vvrHPoZSvRstNyzw2P8Oh5BFTn1pqTleJIUwUmcQYb /2fA== X-Gm-Message-State: AHYfb5hxNcGAJ5jqZTFIHfeAt1oJbx454hrWjPsmixvBhqhrZrZQmefS tiguANj4JZ/yaPdi X-Google-Smtp-Source: ADKCNb7s8nqWdf4C0X4Bt+EtcrmH5P11fi09Yj06ZXcGirE7lnWs62K07xWpf5lzHpDCt+4vYEs4Tg== X-Received: by 10.28.24.138 with SMTP id 132mr124146wmy.61.1504172710606; Thu, 31 Aug 2017 02:45:10 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id s15sm6819694wrg.84.2017.08.31.02.45.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Aug 2017 02:45:09 -0700 (PDT) From: Adrien Mazarguil To: Yuanhan Liu Cc: stable@dpdk.org Date: Thu, 31 Aug 2017 11:44:53 +0200 Message-Id: <26f22c88d0b7481d6e365ca13cc8a275047454de.1504172212.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: <20170814121817.GR9612@yliu-home> Subject: [dpdk-stable] [PATCH 1/2] net/mlx: remove link update lock 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: , X-List-Received-Date: Thu, 31 Aug 2017 09:45:11 -0000 From: Matthieu Ternisien d'Ouville [ backported from upstream commit 2c960a5116d05cc7c93d00df707655d72d73d230 ] Retrieving link status information through the link update callback should be quick and non-blocking. Mellanox PMDs retrieve this information through ioctl() calls on the related kernel netdevice. This appears to take a long time to complete and may cause significant slowdowns in applications. While these system calls cannot be accelerated, removing the lock on the private structure allows applications to perform other control operations from separate threads in the meantime. This function remains safe without locking as it does not write the private structure, it is only used to retrieve the name of the netdevice. Signed-off-by: Matthieu Ternisien d'Ouville Signed-off-by: Olivier Matz Acked-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4.c | 32 ++++++-------------------------- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 1 - drivers/net/mlx5/mlx5_ethdev.c | 28 +++++----------------------- 4 files changed, 12 insertions(+), 51 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 4a03d34..22af742 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -4836,7 +4836,7 @@ mlx4_allmulticast_disable(struct rte_eth_dev *dev) } /** - * DPDK callback to retrieve physical link information (unlocked version). + * DPDK callback to retrieve physical link information. * * @param dev * Pointer to Ethernet device structure. @@ -4844,9 +4844,9 @@ mlx4_allmulticast_disable(struct rte_eth_dev *dev) * Wait for request completion (ignored). */ static int -mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete) +mlx4_link_update(struct rte_eth_dev *dev, int wait_to_complete) { - struct priv *priv = mlx4_get_priv(dev); + const struct priv *priv = mlx4_get_priv(dev); struct ethtool_cmd edata = { .cmd = ETHTOOL_GSET }; @@ -4854,6 +4854,8 @@ mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete) struct rte_eth_link dev_link; int link_speed = 0; + /* priv_lock() is not taken to allow concurrent calls. */ + if (priv == NULL) return -EINVAL; (void)wait_to_complete; @@ -4889,28 +4891,6 @@ mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete) } /** - * DPDK callback to retrieve physical link information. - * - * @param dev - * Pointer to Ethernet device structure. - * @param wait_to_complete - * Wait for request completion (ignored). - */ -static int -mlx4_link_update(struct rte_eth_dev *dev, int wait_to_complete) -{ - struct priv *priv = mlx4_get_priv(dev); - int ret; - - if (priv == NULL) - return -EINVAL; - priv_lock(priv); - ret = mlx4_link_update_unlocked(dev, wait_to_complete); - priv_unlock(priv); - return ret; -} - -/** * DPDK callback to change the MTU. * * Setting the MTU affects hardware MRU (packets larger than the MTU cannot be @@ -5426,7 +5406,7 @@ priv_dev_link_status_handler(struct priv *priv, struct rte_eth_dev *dev) struct rte_eth_link *link = &dev->data->dev_link; priv->pending_alarm = 0; - mlx4_link_update_unlocked(dev, 0); + mlx4_link_update(dev, 0); if (((link->link_speed == 0) && link->link_status) || ((link->link_speed != 0) && !link->link_status)) { /* Inconsistent status, check again later. */ diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index aa9d2dc..6f74e6d 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -668,7 +668,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) /* Bring Ethernet device up. */ DEBUG("forcing Ethernet interface up"); priv_set_flags(priv, ~IFF_UP, IFF_UP); - mlx5_link_update_unlocked(priv->dev, 1); + mlx5_link_update(priv->dev, 1); continue; port_error: diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 79b7a60..adb9d79 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -188,7 +188,6 @@ int priv_set_flags(struct priv *, unsigned int, unsigned int); int mlx5_dev_configure(struct rte_eth_dev *); void mlx5_dev_infos_get(struct rte_eth_dev *, struct rte_eth_dev_info *); const uint32_t *mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev); -int mlx5_link_update_unlocked(struct rte_eth_dev *, int); int mlx5_link_update(struct rte_eth_dev *, int); int mlx5_dev_set_mtu(struct rte_eth_dev *, uint16_t); int mlx5_dev_get_flow_ctrl(struct rte_eth_dev *, struct rte_eth_fc_conf *); diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index ca981a5..279f6d8 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -680,7 +680,7 @@ mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev) } /** - * Retrieve physical link information (unlocked version using legacy ioctl). + * DPDK callback to retrieve physical link information. * * @param dev * Pointer to Ethernet device structure. @@ -698,6 +698,8 @@ mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev, int wait_to_complete) struct rte_eth_link dev_link; int link_speed = 0; + /* priv_lock() is not taken to allow concurrent calls. */ + (void)wait_to_complete; if (priv_ifreq(priv, SIOCGIFFLAGS, &ifr)) { WARN("ioctl(SIOCGIFFLAGS) failed: %s", strerror(errno)); @@ -839,7 +841,7 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete) } /** - * DPDK callback to retrieve physical link information (unlocked version). + * DPDK callback to retrieve physical link information. * * @param dev * Pointer to Ethernet device structure. @@ -847,7 +849,7 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete) * Wait for request completion (ignored). */ int -mlx5_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete) +mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete) { struct utsname utsname; int ver[3]; @@ -861,26 +863,6 @@ mlx5_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete) } /** - * DPDK callback to retrieve physical link information. - * - * @param dev - * Pointer to Ethernet device structure. - * @param wait_to_complete - * Wait for request completion (ignored). - */ -int -mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete) -{ - struct priv *priv = mlx5_get_priv(dev); - int ret; - - priv_lock(priv); - ret = mlx5_link_update_unlocked(dev, wait_to_complete); - priv_unlock(priv); - return ret; -} - -/** * DPDK callback to change the MTU. * * Setting the MTU affects hardware MRU (packets larger than the MTU cannot be -- 2.1.4