From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BF65FA0C47; Tue, 12 Oct 2021 09:58:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5198B40151; Tue, 12 Oct 2021 09:58:10 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id D3F434003C for ; Tue, 12 Oct 2021 09:58:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634025488; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lZBMPjWIQMIy6UmZfCSgA46qKJ0GzLftNVVqdc02nYg=; b=f+s+V4aHv4+VLL8SGDi1U7fbKSV94PNBSLfM0H0SvFPQRy2FiBQ6PljlKeuQHhPmPCT5Nt OzQofU/Z7i3/EEBavkyvcLmgt+X+Y8g5tM8TPbwmiH5oJ12+INiYvE0TBroioGKPp5DI+e OPDIBPp2WkS0Ofod3hleJoZHkRvjtQ4= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-142-TAwGBS9cN5iRrc7Rkaevdw-1; Tue, 12 Oct 2021 03:58:06 -0400 X-MC-Unique: TAwGBS9cN5iRrc7Rkaevdw-1 Received: by mail-lf1-f71.google.com with SMTP id c42-20020a05651223aa00b003fd328cfeccso14530333lfv.4 for ; Tue, 12 Oct 2021 00:58:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lZBMPjWIQMIy6UmZfCSgA46qKJ0GzLftNVVqdc02nYg=; b=bueKy353zMso9CvsROj/qrKB7MOIsLJ/lenD3o8NFfNdLo0lvomhH6UaKdicBS6Aat zmroTmlg0YgI0gAFQmcZv7bIPaenzjrI4YyI8oViJxAj1AIUIc+O11I3tvwmHGzt+4I+ w6riaKcl5vx5J4YjHNrmlUBtUNqP6IEB5rs3YC27rdezzS3k3m0nFU00GwguWvGJYdLf bQIVdlB6hg3+TXf2eAQnjS2asWn54fd9D+LhqW9JjVde0tsr92VpEAVDj4648G3crRe3 6oV2RopGCA5cBwu1NTX2AaJR850nILRNaSoSo/J4dGrbwryjaRKa0t22dSh9BgHEE22n IejQ== X-Gm-Message-State: AOAM532z5CbJRK+uMYstlTAeZ58RdGakD1kPYTyyQnyGQBmSSYx+bbKQ LZMtSuX8Hpjm1u2dK4BGPHLSrLpfm+QAI7qFz4A1EUaTu91HqyTwGFc2Taxe/PzSK5zWgDh8YZ5 BgObcQl4EB3ffEH1Jexs= X-Received: by 2002:a05:6512:202a:: with SMTP id s10mr7018883lfs.560.1634025485318; Tue, 12 Oct 2021 00:58:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5J28ubyC2KiNaaKem+dHwNaNHnXrIw3z37bg/uM411BZ3iGEaLWZxzVDr508FSn48gwtQRbIO7HCmrOYWz1I= X-Received: by 2002:a05:6512:202a:: with SMTP id s10mr7018859lfs.560.1634025485089; Tue, 12 Oct 2021 00:58:05 -0700 (PDT) MIME-Version: 1.0 References: <20211012072848.17741-1-david.marchand@redhat.com> In-Reply-To: From: David Marchand Date: Tue, 12 Oct 2021 09:57:53 +0200 Message-ID: To: Andrew Rybchenko Cc: dev , Ray Kinsella , dkozlyuk@oss.nvidia.com, Thomas Monjalon , Olivier Matz , Kevin Traynor , Luca Boccassi , Christian Ehrhardt , "Xueming(Steven) Li" Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH] mempool: enforce valid flags at creation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Oct 12, 2021 at 9:49 AM Andrew Rybchenko wrote: > > 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. I wondered too when writing the patch. I'd like to hear from others. > > > > > Signed-off-by: David Marchand > > A nit below, other than that: > > Reviewed-by: Andrew Rybchenko > > [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. Sounds reasonable, for v2. -- David Marchand