From: Bing Zhao <bingz@nvidia.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: NBU-Contact-Thomas Monjalon <thomas@monjalon.net>,
"ferruh.yigit@intel.com" <ferruh.yigit@intel.com>,
"andrew.rybchenko@oktetlabs.ru" <andrew.rybchenko@oktetlabs.ru>,
"dev@dpdk.org" <dev@dpdk.org>,
"konstantin.ananyev@intel.com" <konstantin.ananyev@intel.com>
Subject: Re: [dpdk-dev] [PATCH 2/2] ethdev: fix the race condition for fp ops reset
Date: Sun, 24 Oct 2021 05:54:14 +0000 [thread overview]
Message-ID: <DM5PR12MB175535953781B7DA543FAEDED0829@DM5PR12MB1755.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20211023091325.0120256c@hermes.local>
Hi Stephen,
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Sunday, October 24, 2021 12:13 AM
> To: Bing Zhao <bingz@nvidia.com>
> Cc: NBU-Contact-Thomas Monjalon <thomas@monjalon.net>;
> ferruh.yigit@intel.com; andrew.rybchenko@oktetlabs.ru; dev@dpdk.org;
> konstantin.ananyev@intel.com
> Subject: Re: [dpdk-dev] [PATCH 2/2] ethdev: fix the race condition
> for fp ops reset
>
> External email: Use caution opening links or attachments
>
>
> On Sat, 23 Oct 2021 00:14:07 +0300
> Bing Zhao <bingz@nvidia.com> wrote:
>
> > diff --git a/lib/ethdev/ethdev_private.c
> b/lib/ethdev/ethdev_private.c
> > index fbc3df91ad..cda9a6e228 100644
> > --- a/lib/ethdev/ethdev_private.c
> > +++ b/lib/ethdev/ethdev_private.c
> > @@ -206,7 +206,7 @@ eth_dev_fp_ops_reset(struct rte_eth_fp_ops
> *fpo)
> > .txq = {.data = dummy_data, .clbk = dummy_data,},
> > };
> >
> > - *fpo = dummy_ops;
> > + rte_memcpy(fpo, &dummy_ops, sizeof(struct rte_eth_fp_ops));
>
> memcpy is not thread safe either.
Sorry for my commit log and it may not be that clear. The reason is the thread-safe, it is because the structure assignment and initialization. Then the pointer will be set to 0 and then set to the new value again.
I am not quite sure if it is OK so use part of the old values and part of the new values in the same function (rx/tx burst). However, changing a pointer to NULL (0) is risk and would cause a crash of the whole application. Using memcpy will keep the old value still value and change is into the new value immediately w/o setting it to 0 fist.
But YES again, the application should avoid such case.
BR. Bing
next prev parent reply other threads:[~2021-10-24 5:54 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-22 21:14 [dpdk-dev] [PATCH 1/2] ethdev: fix log level of Tx and Rx dummy functions Bing Zhao
2021-10-22 21:14 ` [dpdk-dev] [PATCH 2/2] ethdev: fix the race condition for fp ops reset Bing Zhao
2021-10-23 8:34 ` Thomas Monjalon
2021-10-23 11:39 ` Ananyev, Konstantin
2021-11-10 14:34 ` Ferruh Yigit
2021-11-10 14:37 ` Ananyev, Konstantin
2021-11-10 14:57 ` Thomas Monjalon
2021-11-10 15:24 ` Bing Zhao
2021-10-23 16:13 ` [dpdk-dev] " Stephen Hemminger
2021-10-24 5:54 ` Bing Zhao [this message]
2021-10-23 8:32 ` [dpdk-dev] [PATCH 1/2] ethdev: fix log level of Tx and Rx dummy functions Thomas Monjalon
2021-10-23 11:46 ` Ananyev, Konstantin
2021-10-23 12:45 ` Bing Zhao
2021-10-24 11:48 ` Ananyev, Konstantin
2021-10-25 9:43 ` Thomas Monjalon
2021-10-25 9:51 ` David Marchand
2021-10-25 12:55 ` Ananyev, Konstantin
2021-10-25 13:27 ` Thomas Monjalon
2021-10-25 13:31 ` David Marchand
2021-10-25 20:29 ` Ananyev, Konstantin
2021-10-25 20:38 ` Thomas Monjalon
2021-10-26 12:38 ` Ananyev, Konstantin
2021-10-26 12:59 ` Thomas Monjalon
2021-10-26 3:18 ` Bing Zhao
2021-10-23 12:12 ` Bing Zhao
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=DM5PR12MB175535953781B7DA543FAEDED0829@DM5PR12MB1755.namprd12.prod.outlook.com \
--to=bingz@nvidia.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=konstantin.ananyev@intel.com \
--cc=stephen@networkplumber.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).