DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Phil Yang (Arm Technology China)" <Phil.Yang@arm.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "stable@dpdk.org" <stable@dpdk.org>,
	"he.qiao17@zte.com.cn" <he.qiao17@zte.com.cn>,
	Igor Ryzhov <iryzhov@nfware.com>, Dan Gora <dg@adax.com>
Subject: Re: [dpdk-dev] [PATCH] examples/kni: fix crash while handling userspace request
Date: Wed, 16 Jan 2019 06:34:13 +0000	[thread overview]
Message-ID: <DB7PR08MB33857C6D4F4085394775F9DCE9820@DB7PR08MB3385.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <20190115172802.72238-1-ferruh.yigit@intel.com>

Hi Ferruh,

> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Wednesday, January 16, 2019 1:28 AM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; he.qiao17@zte.com.cn; Igor Ryzhov
> <iryzhov@nfware.com>; Phil Yang (Arm Technology China)
> <Phil.Yang@arm.com>; Dan Gora <dg@adax.com>
> Subject: [PATCH] examples/kni: fix crash while handling userspace request
>
> When KNI interface receives RTE_KNI_REQ_CFG_NETWORK_IF request, it
> stap/start the physical device which as a result of stop() can free all the mbufs in
> its queue.
> Meanwhile sample application continues to read from KNI interface queues and
> push into device queues. This simultaneous access may cause a crash, crash log
> can be found at defect description.
>
> As a solution KNI sample application can do the proper synchronization, and
> stop transfer between KNI interface and physical interface while physical device
> stop/started.
>
> Bugzilla ID: 116
> Fixes: 3fc5ca2f6352 ("kni: initial import")
> Cc: stable@dpdk.org
>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> Cc: he.qiao17@zte.com.cn
> I am not able to re-produce the defect can you please test with this patch?
>
> And another concern is performance affect of this patch, new check is added
> into fast path. Cc'ed a few more people for comment:
> Cc: Igor Ryzhov <iryzhov@nfware.com>
> Cc: Phil Yang <phil.yang@arm.com>
> Cc: Dan Gora <dg@adax.com>
> ---
>  examples/kni/main.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/examples/kni/main.c b/examples/kni/main.c index
> c468ffd19..a8ce07e2a 100644
> --- a/examples/kni/main.c
> +++ b/examples/kni/main.c
> @@ -132,6 +132,7 @@ static int kni_config_network_interface(uint16_t port_id,
> uint8_t if_up);  static int kni_config_mac_address(uint16_t port_id, uint8_t
> mac_addr[]);
>
>  static rte_atomic32_t kni_stop = RTE_ATOMIC32_INIT(0);
> +static rte_atomic32_t kni_pause = RTE_ATOMIC32_INIT(0);
>
>  /* Print out statistics on packets handled */  static void @@ -276,6 +277,7 @@
> main_loop(__rte_unused void *arg)  {
>  uint16_t i;
>  int32_t f_stop;
> +int32_t f_pause;
>  const unsigned lcore_id = rte_lcore_id();
>  enum lcore_rxtx {
>  LCORE_NONE,
> @@ -304,8 +306,11 @@ main_loop(__rte_unused void *arg)
>  kni_port_params_array[i]->port_id);
>  while (1) {
>  f_stop = rte_atomic32_read(&kni_stop);
> +f_pause = rte_atomic32_read(&kni_pause);
>  if (f_stop)
>  break;
> +if (f_pause)
> +continue;
>  kni_ingress(kni_port_params_array[i]);
>  }
>  } else if (flag == LCORE_TX) {
> @@ -314,8 +319,11 @@ main_loop(__rte_unused void *arg)
>  kni_port_params_array[i]->port_id);
>  while (1) {
>  f_stop = rte_atomic32_read(&kni_stop);
> +f_pause = rte_atomic32_read(&kni_pause);
>  if (f_stop)
>  break;
> +if (f_pause)
> +continue;
>  kni_egress(kni_port_params_array[i]);
>  }
>  } else
> @@ -807,12 +815,16 @@ kni_config_network_interface(uint16_t port_id,
> uint8_t if_up)
>  RTE_LOG(INFO, APP, "Configure network interface of %d %s\n",
>  port_id, if_up ? "up" : "down");
>
> +rte_atomic32_inc(&kni_pause);
> +
>  if (if_up != 0) { /* Configure network interface up */
>  rte_eth_dev_stop(port_id);
>  ret = rte_eth_dev_start(port_id);
>  } else /* Configure network interface down */
>  rte_eth_dev_stop(port_id);
>
> +rte_atomic32_dec(&kni_pause);
> +
>  if (ret < 0)
>  RTE_LOG(ERR, APP, "Failed to start port %d\n", port_id);
>
> --
> 2.17.2

Acked-by: Phil Yang <phil.yang@arm.com>

Thanks,
Phil Yang
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

  reply	other threads:[~2019-01-16  6:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-15 17:28 Ferruh Yigit
2019-01-16  6:34 ` Phil Yang (Arm Technology China) [this message]
2019-01-17 22:48   ` 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=DB7PR08MB33857C6D4F4085394775F9DCE9820@DB7PR08MB3385.eurprd08.prod.outlook.com \
    --to=phil.yang@arm.com \
    --cc=dev@dpdk.org \
    --cc=dg@adax.com \
    --cc=ferruh.yigit@intel.com \
    --cc=he.qiao17@zte.com.cn \
    --cc=iryzhov@nfware.com \
    --cc=stable@dpdk.org \
    /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).