DPDK patches and discussions
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz@6wind.com>
To: Zoltan Kiss <zoltan.kiss@linaro.org>,
	Zoltan Kiss <zoltan.kiss@schaman.hu>,
	dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] mempool: adjust name string size in related data types
Date: Tue, 19 Jul 2016 18:17:32 +0200	[thread overview]
Message-ID: <85d13abf-b05e-67f0-16fd-3279cb4064be@6wind.com> (raw)
In-Reply-To: <578E4E60.80802@linaro.org>

Hi Zoltan,

On 07/19/2016 05:59 PM, Zoltan Kiss wrote:
> 
> 
> On 19/07/16 16:37, Olivier Matz wrote:
>> Hi Zoltan,
>>
>> On 07/19/2016 04:37 PM, Zoltan Kiss wrote:
>>> A recent fix brought up an issue about the size of the 'name' fields:
>>>
>>> 85cf0079 mem: avoid memzone/mempool/ring name truncation
>>>
>>> These relations should be observed:
>>>
>>> RTE_RING_NAMESIZE <= RTE_MEMZONE_NAMESIZE - strlen(RTE_RING_MZ_PREFIX)
>>> RTE_MEMPOOL_NAMESIZE <= RTE_RING_NAMESIZE -
>>> strlen(RTE_MEMPOOL_MZ_PREFIX)
>>>
>>> Setting all of them to 32 hides this restriction from the application.
>>> This patch increases the memzone string size to accomodate for these
>>> prefixes, and the same happens with the ring name string. The ABI
>>> needs to
>>> be broken to fix this API issue, this way doesn't break applications
>>> previously not failing due to the truncating bug now fixed.
>>>
>>> Signed-off-by: Zoltan Kiss <zoltan.kiss@schaman.hu>
>>
>> I agree it is a problem for an application because it cannot know what
>> is the maximum name length. On the other hand, breaking the ABI for this
>> looks a bit overkill. Maybe we could reduce RTE_MEMPOOL_NAMESIZE and
>> RTE_RING_NAMESIZE instead of increasing RTE_MEMZONE_NAMESIZE? That way,
>> we could keep the ABI as is.
> 
> But that would break the ABI too, wouldn't it? Unless you keep the array
> the same size (32 bytes) by using RTE_MEMZONE_NAMESIZE.

Yes, that was the idea.

> And even then, the API breaks anyway. There are applications - I have at
> least some - which use all 32 bytes to store the name. Decrease that
> would cause headache to change the naming scheme, because it's a 30
> character long id, and chopping the last few chars would cause name
> collisions and annoying bugs.

Before my patch (85cf0079), long names were silently truncated when
mempool created its ring and/or memzones. Now, it returns an error.

I'm not getting why changing the struct to something like below would
break the API, since it would already return an error today.

  #define RTE_MEMPOOL_NAMESIZE \
      (RTE_MEMZONE_NAMESIZE - sizeof(pool_prefix) - sizeof(ring prefix))
  struct rte_mempool {
      union {
            char name[RTE_MEMPOOL_NAMESIZE];
            char pad[32];
      };
      ...
  }

Anyway, it may not be the proper solution since it supposes that a
mempool includes a ring based on a memzone, which is not always true now
with mempool handlers.

>> It would even be better to get rid of this static char[] for the
>> structure names and replace it by an allocated const char *. I didn't
>> check it's feasible for memzones. What do you think?
> 
> It would work too, but I don't think it would help a lot. We would still
> need max sizes for the names. Storing them somewhere else won't help us
> in this problem.

Why should we have a maximum length for the names?


Thanks,
Olivier

  reply	other threads:[~2016-07-19 16:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-19 14:37 [dpdk-dev] [PATCH] mempool: fix lack of free() registration Zoltan Kiss
2016-07-19 14:37 ` [dpdk-dev] [PATCH] mempool: adjust name string size in related data types Zoltan Kiss
2016-07-19 15:37   ` Olivier Matz
2016-07-19 15:59     ` Zoltan Kiss
2016-07-19 16:17       ` Olivier Matz [this message]
2016-07-20 12:41         ` Zoltan Kiss
2016-07-20 13:37           ` Olivier Matz
2016-07-20 14:01             ` Richardson, Bruce
2016-07-20 17:20             ` Zoltan Kiss
2016-07-20 17:16   ` [dpdk-dev] [PATCH v2] " Zoltan Kiss
2016-07-21 13:40     ` Olivier Matz
2016-07-21 13:47       ` Zoltan Kiss
2016-07-21 14:25         ` Olivier Matz
2016-07-21 21:16           ` Thomas Monjalon
2016-07-19 15:26 ` [dpdk-dev] [PATCH] mempool: fix lack of free() registration Olivier Matz
2016-07-19 16:17   ` Zoltan Kiss
2016-07-20 17:14 ` [dpdk-dev] [PATCH v2] mempool: fix lack of free registration Zoltan Kiss
2016-07-21 21:04   ` 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=85d13abf-b05e-67f0-16fd-3279cb4064be@6wind.com \
    --to=olivier.matz@6wind.com \
    --cc=dev@dpdk.org \
    --cc=zoltan.kiss@linaro.org \
    --cc=zoltan.kiss@schaman.hu \
    /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).