From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
To: David Marchand <david.marchand@redhat.com>, dev@dpdk.org
Cc: mdr@ashroe.eu, dkozlyuk@oss.nvidia.com, thomas@monjalon.net,
Olivier Matz <olivier.matz@6wind.com>
Subject: Re: [dpdk-dev] [PATCH] mempool: enforce valid flags at creation
Date: Tue, 12 Oct 2021 10:49:53 +0300 [thread overview]
Message-ID: <fe6477a3-a3d8-ebc0-d88f-b7c36b717d0b@oktetlabs.ru> (raw)
In-Reply-To: <20211012072848.17741-1-david.marchand@redhat.com>
On 10/12/21 10:28 AM, David Marchand wrote:
> If we do not enforce valid flags are passed by an application, this
> application might face issues in the future when we add more flags.
Thanks. I'd even consider it as a bug and the fix to be
backported.
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
A nit below, other than that:
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
[snip]
> diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
> index c5f859ae71..a2a78125f4 100644
> --- a/lib/mempool/rte_mempool.c
> +++ b/lib/mempool/rte_mempool.c
> @@ -777,6 +777,13 @@ rte_mempool_cache_free(struct rte_mempool_cache *cache)
> rte_free(cache);
> }
>
> +#define MEMPOOL_KNOWN_FLAGS ( MEMPOOL_F_NO_SPREAD \
> + | MEMPOOL_F_NO_CACHE_ALIGN \
> + | MEMPOOL_F_SP_PUT \
> + | MEMPOOL_F_SC_GET \
> + | MEMPOOL_F_POOL_CREATED \
> + | MEMPOOL_F_NO_IOVA_CONTIG \
> + )
> /* create an empty mempool */
> struct rte_mempool *
> rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
> @@ -806,6 +813,12 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
> RTE_CACHE_LINE_MASK) != 0);
> #endif
>
> + /* enforce no unknown flag is passed by the application */
> + if ((flags & ~MEMPOOL_KNOWN_FLAGS) != 0) {
> + rte_errno = EINVAL;
> + return NULL;
> + }
> +
I think it is better to check arguments in parameters order.
So, it is a bit better to move the check to happen after
cache_size validation below.
> mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
>
> /* asked for zero items */
[snip]
next prev parent reply other threads:[~2021-10-12 7:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 7:28 [dpdk-dev] [PATCH] mempool: enforce valid flags at creation David Marchand
2021-10-12 7:49 ` Andrew Rybchenko [this message]
2021-10-12 7:57 ` David Marchand
2021-10-14 19:16 ` David Marchand
2021-10-12 10:10 ` Kinsella, Ray
2021-10-14 19:29 ` [dpdk-dev] [PATCH v2] " David Marchand
2021-10-14 19:37 ` Stephen Hemminger
2021-10-15 7:02 ` Andrew Rybchenko
2021-10-15 8:26 ` David Marchand
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=fe6477a3-a3d8-ebc0-d88f-b7c36b717d0b@oktetlabs.ru \
--to=andrew.rybchenko@oktetlabs.ru \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=dkozlyuk@oss.nvidia.com \
--cc=mdr@ashroe.eu \
--cc=olivier.matz@6wind.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.