DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Gaëtan Rivet" <gaetan.rivet@6wind.com>
To: Ophir Munk <ophirmu@mellanox.com>
Cc: Adrien Mazarguil <adrien.mazarguil@6wind.com>,
	dev@dpdk.org, Thomas Monjalon <thomas@monjalon.net>,
	Olga Shern <olgas@mellanox.com>,
	stable@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] net/failsafe: fix calling device during RMV events
Date: Mon, 11 Sep 2017 10:31:18 +0200	[thread overview]
Message-ID: <20170911083117.GM21444@bidouze.vm.6wind.com> (raw)
In-Reply-To: <1504985231-21031-1-git-send-email-ophirmu@mellanox.com>

Hi Ophir,

On Sat, Sep 09, 2017 at 07:27:11PM +0000, Ophir Munk wrote:
> This commit prevents control path operations from failing after a sub
> device has informed failsafe it has been removed.
> 
> Before this commit if a device was removed and then a control path

Here are the steps if I understood correctly:

0. The physical device is removed
1. The interrupt thread flags the device
2. A control lcore initiates a control operation
3. The alarm triggers, waking up the eal-intr-thread,
   initiating the actual device removal.
4. Race condition occurs between control lcore and interrupt thread.

"if a device was removed" is ambiguous I think (are we speaking about
the physical port? Is it only flagged? Is it after the removal of the
device itself?). From the context I gather that you mean the device is
flagged to be removed, but it won't be as clear in a few month when we
revisit this bug :) .

Could you please rephrase this so that the whole context of the issue
is available?

> operations was initiated on failsafe - in some cases failsafe called the
> sub device operation instead of avoiding it. Such cases could lead to
> operations failures.
> 
> This commit fixes failsafe criteria to determine when the device is removed
> such that it will avoid calling the sub device operations during that time
> and will only call them otherwise.
> 

This commit mitigates the race condition, reducing the probability for
it to have an effect. It does not, however, remove this race condition,
which is inherent to the DPDK architecture at the moment.

A proper fix, a more detailed workaround and additional documentation
warning users writing applications to mind their threads could be
interesting.

But let's focus on this patch for the time being.

> Fixes: a46f8d584eb8 ("net/failsafe: add fail-safe PMD")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> ---
>  drivers/net/failsafe/failsafe_ether.c |  1 +
>  drivers/net/failsafe/failsafe_ops.c   | 52 +++++++++++++++++++++++++++++------
>  2 files changed, 45 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c
> index a3a8cce..1def110 100644
> --- a/drivers/net/failsafe/failsafe_ether.c
> +++ b/drivers/net/failsafe/failsafe_ether.c
> @@ -378,6 +378,7 @@

Could you please generate your patches with the function name in the
diff?

>  				      i);
>  				goto err_remove;
>  			}
> +			sdev->remove = 0;

You are adding this here, within failsafe_eth_dev_state_sync,
and removing it from the dev_configure ops.

10 lines above, the call to dev_configure is done, meaning that the
remove flag was resetted at this point.

Can you explain why you prefer resetting the flag here?

The position of this flag reset will be dependent upon my subsequent
remarks anyway, so hold that thought :) .

>  		}
>  	}
>  	/*
> diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c
> index ff9ad15..314d53d 100644
> --- a/drivers/net/failsafe/failsafe_ops.c
> +++ b/drivers/net/failsafe/failsafe_ops.c
> @@ -232,7 +232,6 @@
>  			dev->data->dev_conf.intr_conf.lsc = 0;
>  		}
>  		DEBUG("Configuring sub-device %d", i);
> -		sdev->remove = 0;
>  		ret = rte_eth_dev_configure(PORT_ID(sdev),
>  					dev->data->nb_rx_queues,
>  					dev->data->nb_tx_queues,
> @@ -311,6 +310,8 @@
>  	int ret;
>  
>  	FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
> +		if (sdev->remove)
> +			continue;
>  		DEBUG("Calling rte_eth_dev_set_link_up on sub_device %d", i);
>  		ret = rte_eth_dev_set_link_up(PORT_ID(sdev));
>  		if (ret) {
> @@ -330,6 +331,8 @@
>  	int ret;
>  
>  	FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
> +		if (sdev->remove)
> +			continue;

For this change and all the others:

I think it might be best to have this check added to fs_find_next
directly.

Most of the call to the iterators are done within dev_ops, so it makes
sense I think to have it there.

But then there'd be an issue with the sub-EAL iterations done on
previously-removed ports, as the removed flag is precisely resetted too
late. The function failsafe_dev_remove would also need to have a manual
iteration upon the sub-devices instead of using the macro.

I think you can actually reset this flag within fs_dev_remove, instead
of the next plug-in, then having this check within fs_find_next *should*
not be a problem.

I think you should break up those changes in two: first move the flag
reset to fs_dev_remove instead of fs_dev_configure, then add this check
to the iterator.

This way, a git bisect should allow us to pinpoint more easily any new bug
as both changes have the potential to introduce subtle ones.

>  		DEBUG("Calling rte_eth_dev_set_link_down on sub_device %d", i);
>  		ret = rte_eth_dev_set_link_down(PORT_ID(sdev));
>  		if (ret) {
> @@ -517,8 +520,11 @@
>  	struct sub_device *sdev;
>  	uint8_t i;
>  
> -	FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
> +	FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
> +		if (sdev->remove)
> +			continue;
>  		rte_eth_promiscuous_enable(PORT_ID(sdev));
> +	}
>  }
>  
>  static void

<snip>

> -- 
> 1.8.3.1
> 

Thanks,
-- 
Gaëtan Rivet
6WIND

  reply	other threads:[~2017-09-11  8:31 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-09 19:27 Ophir Munk
2017-09-11  8:31 ` Gaëtan Rivet [this message]
2017-09-23 21:57   ` Ophir Munk
2017-10-05 22:42     ` [dpdk-dev] [PATCH v3] " Ophir Munk
2017-10-20 10:35       ` Gaëtan Rivet
2017-10-23  7:17         ` Ophir Munk
2017-10-23  8:36           ` Gaëtan Rivet
2017-11-29 19:17             ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
2018-01-18 22:22               ` Thomas Monjalon
2018-01-18 23:35                 ` Gaëtan Rivet
2018-02-08 12:20       ` [dpdk-dev] [PATCH v4 0/2] failsafe: " Matan Azrad
2018-02-08 12:20         ` [dpdk-dev] [PATCH v4 1/2] net/failsafe: fix hotplug alarm cancel Matan Azrad
2018-02-08 12:20         ` [dpdk-dev] [PATCH v4 2/2] net/failsafe: fix calling device during RMV events Matan Azrad
2018-02-08 16:34         ` [dpdk-dev] [PATCH v5 0/3] failsafe: " Matan Azrad
2018-02-08 16:34           ` [dpdk-dev] [PATCH v5 1/3] net/failsafe: fix hotplug alarm cancel Matan Azrad
2018-02-08 16:34           ` [dpdk-dev] [PATCH v5 2/3] net/failsafe: fix removal scope Matan Azrad
2018-02-08 17:19             ` Gaëtan Rivet
2018-02-08 19:03               ` Matan Azrad
2018-02-08 16:34           ` [dpdk-dev] [PATCH v5 3/3] net/failsafe: fix calling device during RMV events Matan Azrad
2018-02-08 18:11             ` Gaëtan Rivet
2018-02-08 19:24               ` Matan Azrad
2018-02-11 17:24           ` [dpdk-dev] [PATCH v6 0/3] failsafe: fix hotplug races Matan Azrad
2018-02-11 17:24             ` [dpdk-dev] [PATCH v6 1/3] net/failsafe: fix hotplug alarm cancel Matan Azrad
2018-02-11 17:24             ` [dpdk-dev] [PATCH v6 2/3] net/failsafe: fix removal scope Matan Azrad
2018-02-11 17:24             ` [dpdk-dev] [PATCH v6 3/3] net/failsafe: fix hotplug races Matan Azrad
2018-02-12 18:33               ` Gaëtan Rivet
2018-02-12 20:35                 ` Matan Azrad
2018-02-12 20:51             ` [dpdk-dev] [PATCH v7 0/3] failsafe: " Matan Azrad
2018-02-12 20:51               ` [dpdk-dev] [PATCH v7 1/3] net/failsafe: fix hotplug alarm cancel Matan Azrad
2018-02-12 20:51               ` [dpdk-dev] [PATCH v7 2/3] net/failsafe: fix removal scope Matan Azrad
2018-02-12 20:51               ` [dpdk-dev] [PATCH v7 3/3] net/failsafe: fix hotplug races Matan Azrad
2018-02-13 13:31               ` [dpdk-dev] [PATCH v7 0/3] failsafe: " Gaëtan Rivet
2018-02-13 16:12                 ` Thomas Monjalon
2018-02-13 20:58                   ` De Lara Guarch, Pablo
2018-02-13 21:13                     ` Matan Azrad
2018-02-13 21:21                       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170911083117.GM21444@bidouze.vm.6wind.com \
    --to=gaetan.rivet@6wind.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=olgas@mellanox.com \
    --cc=ophirmu@mellanox.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).