DPDK patches and discussions
 help / color / mirror / Atom feed
From: Renata Saiakhova <renata.saiakhova@ekinops.com>
To: "Burakov, Anatoly" <anatoly.burakov@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 1/2] librte_ethdev: Introduce a function to release HW rings
Date: Tue, 5 May 2020 12:49:27 +0000	[thread overview]
Message-ID: <MRXP264MB0325B273A6185AAF5E64B59292A70@MRXP264MB0325.FRAP264.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <be5c91af-ddfa-340b-5b00-052fd0e3f8c0@intel.com>

Hi Anatoly,

thanks! The fact that memzone is found and matched only based on the name, could it create potential problem like the one I described besides HW rings?

Kind regards,
Renata
________________________________
From: Burakov, Anatoly <anatoly.burakov@intel.com>
Sent: Tuesday, May 5, 2020 12:45 PM
To: Renata Saiakhova <renata.saiakhova@ekinops.com>; dev@dpdk.org <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 1/2] librte_ethdev: Introduce a function to release HW rings

On 05-May-20 11:25 AM, Burakov, Anatoly wrote:
> On 03-May-20 5:26 PM, Renata Saiakhova wrote:
>> Free previously allocated memzone for HW rings
>>
>> Signed-off-by: Renata Saiakhova <Renata.Saiakhova@ekinops.com>
>> ---
>>   lib/librte_ethdev/rte_ethdev.c           | 23 +++++++++++++++++++++++
>>   lib/librte_ethdev/rte_ethdev_driver.h    | 14 ++++++++++++++
>>   lib/librte_ethdev/rte_ethdev_version.map |  1 +
>>   3 files changed, 38 insertions(+)
>>
>> diff --git a/lib/librte_ethdev/rte_ethdev.c
>> b/lib/librte_ethdev/rte_ethdev.c
>> index 72aed59a5..c6d27e1aa 100644
>> --- a/lib/librte_ethdev/rte_ethdev.c
>> +++ b/lib/librte_ethdev/rte_ethdev.c
>> @@ -4206,6 +4206,29 @@ rte_eth_dma_zone_reserve(const struct
>> rte_eth_dev *dev, const char *ring_name,
>>               RTE_MEMZONE_IOVA_CONTIG, align);
>>   }
>> +int
>> +rte_eth_dma_zone_free(const struct rte_eth_dev *dev, const char
>> *ring_name,
>> +        uint16_t queue_id)
>> +{
>> +    char z_name[RTE_MEMZONE_NAMESIZE];
>> +    const struct rte_memzone *mz;
>> +    int rc = 0;
>> +
>> +    snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s",
>> +            dev->data->port_id, queue_id, ring_name);
>> +    if (rc >= RTE_MEMZONE_NAMESIZE) {
>> +        RTE_ETHDEV_LOG(ERR, "ring name too long\n");
>> +        rte_errno = ENAMETOOLONG;
>> +        return NULL;
>> +    }
>> +
>> +    mz = rte_memzone_lookup(z_name);
>> +    if (mz)
>> +        rc = rte_memzone_free(mz);
>
> This is racy. Please just use rte_memzone_free() unconditionally. It'll
> return 0 if memzone existed, or will set rte_errno to EINVAL if it
> didn't. (this is suboptimal, it should be ENOENT, but changing this
> would be an API break... I'll submit a patch for future release to fix
> this)
>

My apologies, just using rte_memzone_free will not solve the problem
because you don't have memzone pointer. Now that i think of it, the
rte_eth_dma_zone_reserve() suffers from this issue too, and the problem
is lack of atomic "find or create" memzone API.

This patch is OK for now, as it follows similar code in
rte_eth_dma_zone_reserve(), but ideally, this should be fixed at the
memzone API level. I'll see if i can cobble together a quick patchset
adding atomic "find or reserve" and "find and free" operations.

--
Thanks,
Anatoly

  reply	other threads:[~2020-05-06 10:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-03 16:26 [dpdk-dev] [PATCH 0/2] Memory corruption due to HW rings allocation Renata Saiakhova
2020-05-03 16:26 ` [dpdk-dev] [PATCH 1/2] librte_ethdev: Introduce a function to release HW rings Renata Saiakhova
2020-05-05 10:25   ` Burakov, Anatoly
2020-05-05 10:45     ` Burakov, Anatoly
2020-05-05 12:49       ` Renata Saiakhova [this message]
2020-05-05 13:36         ` Burakov, Anatoly
2020-05-05 15:47   ` Lukasz Wojciechowski
2020-05-05 17:25     ` Renata Saiakhova
2020-05-05 17:31       ` Lukasz Wojciechowski
2020-05-06 10:14       ` Burakov, Anatoly
2020-05-03 16:26 ` [dpdk-dev] [PATCH 2/2] drivers/net: Fix in e1000 and ixgbe HW rings memory overlap Renata Saiakhova
2020-05-05 10:28   ` Burakov, Anatoly
2020-05-05 10:59     ` Thomas Monjalon
2020-05-05 11:36       ` Burakov, Anatoly
2020-05-05 11:01 ` [dpdk-dev] [PATCH 0/2] Memory corruption due to HW rings allocation Thomas Monjalon
2020-05-05 11:19   ` Renata Saiakhova
2020-05-05 12:35     ` 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=MRXP264MB0325B273A6185AAF5E64B59292A70@MRXP264MB0325.FRAP264.PROD.OUTLOOK.COM \
    --to=renata.saiakhova@ekinops.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@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).