From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 7F8CDA0597;
	Thu,  9 Apr 2020 17:04:53 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 5F2691C300;
	Thu,  9 Apr 2020 17:04:53 +0200 (CEST)
Received: from mail-qv1-f65.google.com (mail-qv1-f65.google.com
 [209.85.219.65]) by dpdk.org (Postfix) with ESMTP id 970D21C2F7
 for <dev@dpdk.org>; Thu,  9 Apr 2020 17:04:51 +0200 (CEST)
Received: by mail-qv1-f65.google.com with SMTP id n1so5633776qvz.4
 for <dev@dpdk.org>; Thu, 09 Apr 2020 08:04:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=cOUhBtZOx9yK7OB9kdFCuwkoD76M7ouwZer+fGpfIrQ=;
 b=cnSZM7T/kumtcHPw90QWzixMl3ziaQ6Vm+foGs80NnfJAu2GNKuk2yg8pSgD41qqkM
 W2Q1X5hi3Kt6e+XVsJC1Mv+m9KbzZSytmv2isTrtJ8ySM95qeUilNTrJZblEbJ5y6qO1
 3e4SO3UaWw7xg/z21w+6+gLfj6Qx6G/TZUqJ/LVF/QJ322cVJik9FGDvz5yHKMotLRWA
 IItK7SOUoZC57ONhqNN3E50oxbh6wvqQpV+qWWaBE0cyaeWgqyXLeQelRgZTPQUrazST
 x8db6LHapqr2fZi3MVjCyejLpo0yf05VYLPoBmE69B2Zmr4VbbJIOrY9t+QS2zaIl99/
 LB2g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=cOUhBtZOx9yK7OB9kdFCuwkoD76M7ouwZer+fGpfIrQ=;
 b=SGocDZrQs1MowoGTiVjhw+4BTCC7PYc8thYaN9IQ7O1opEcxf0LwxlerP51TpevLUL
 cLgUC8R289uJExgwS250FJnMtDSM51TZgjgl1/Xu3EqutRmSTJjGJSUotHBFHt+9ibTc
 6dV8ywJ8GzGxoBvd9wZrEHi/NgIaJbER6JBg68xS+peHywD3ZjNOTge++LsAznhJT4TD
 t5LpsJgDnufx7duCvOn9mMZisaTSxJ/5UvTWuqKkbhBYCjlkv55YfJ2efK7w5hvpe66y
 aNFFSjERMa/u+GxUgk773Rhpw1L3Etj5QDx3xijp/+PaJ1IQxpxb6KI5jyf/hE8rSNAB
 F7cw==
X-Gm-Message-State: AGi0PuZ6dIUIVBlEMPuiClxZ5h83CTBYPFOi7byHjIJNHhDSo+mohycC
 4o+BXJMTmlrg9Rz9W+ZJqoWaxDBN62ygEXGrgew=
X-Google-Smtp-Source: APiQypLbd+uc3dWLdXS3A0ceZVB5DBOwxTKR58RfyvV8+vYayCspBG6jhrLZIKi9gAObS9trTLz/IPnRSdgnXy6yU4Y=
X-Received: by 2002:ad4:41c2:: with SMTP id a2mr469654qvq.112.1586444690834;
 Thu, 09 Apr 2020 08:04:50 -0700 (PDT)
MIME-Version: 1.0
References: <1583114253-15345-1-git-send-email-xiangxia.m.yue@gmail.com>
 <1586429580-6990-1-git-send-email-xiangxia.m.yue@gmail.com>
 <CALBAE1NvSPfhRvBn7AH=gc5QmaKje+o+riQchSsW4M_ADhXoTQ@mail.gmail.com>
In-Reply-To: <CALBAE1NvSPfhRvBn7AH=gc5QmaKje+o+riQchSsW4M_ADhXoTQ@mail.gmail.com>
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Date: Thu, 9 Apr 2020 23:04:14 +0800
Message-ID: <CAMDZJNURuCJ5wrAO8n8Ei82WWMaaXyE5E68P5yoJkKj3po=4_g@mail.gmail.com>
To: Jerin Jacob <jerinjacobk@gmail.com>
Cc: Olivier Matz <olivier.matz@6wind.com>,
 Andrew Rybchenko <arybchenko@solarflare.com>, 
 Gage Eads <gage.eads@intel.com>,
 "Artem V. Andreev" <artem.andreev@oktetlabs.ru>, 
 Jerin Jacob <jerinj@marvell.com>, Nithin Dabilpuram <ndabilpuram@marvell.com>, 
 Vamsi Attunuru <vattunuru@marvell.com>, Hemant Agrawal <hemant.agrawal@nxp.com>,
 David Marchand <david.marchand@redhat.com>,
 Anatoly Burakov <anatoly.burakov@intel.com>, 
 "Richardson, Bruce" <bruce.richardson@intel.com>, dpdk-dev <dev@dpdk.org>
Content-Type: text/plain; charset="UTF-8"
Subject: Re: [dpdk-dev] [PATCH dpdk-dev 1/2] eal: introduce last-init queue
 for libraries initialization
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

On Thu, Apr 9, 2020 at 7:31 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
>
> On Thu, Apr 9, 2020 at 4:24 PM <xiangxia.m.yue@gmail.com> wrote:
> >
> > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> >
> > This patch introduces last-init queue, user can register a
> > callback for theirs initialization. Running rte_last_init_run(),
> > the almost resource of DPDK are available, such as memzone, ring.
> > With this way, user don't introduce additional codes in eal layer.
> >
> > [This patch will be used for next patch.]
> >
> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > ---
> >  lib/librte_eal/common/eal_common_last_init.c | 43 ++++++++++++++++++++++++++++
> >  lib/librte_eal/common/meson.build            |  1 +
> >  lib/librte_eal/freebsd/Makefile              |  1 +
> >  lib/librte_eal/freebsd/eal.c                 |  7 +++++
> >  lib/librte_eal/include/rte_last_init.h       | 36 +++++++++++++++++++++++
>
> Update doc/api/doxy-api-index.md and hook to documenion.
>
> > +void
> > +rte_last_init_register(rte_last_init_cb cb, const void *arg)
> > +{
> > +       struct rte_last_init *last;
> > +
> > +       RTE_VERIFY(cb);
> > +
> > +       last = malloc(sizeof(*last));
>
> Does not look like this memory is NOT freed anywhere.
>
> > +       if (last == NULL)
> > +               rte_panic("Alloc memory for rte_last_init node failed\n");
> > +
> > +       last->cb = cb;
> > +       last->arg = arg;
> > +
> > +       TAILQ_INSERT_TAIL(&rte_last_init_list, last, next);
> > +}
> > +
> > +int
> > +rte_last_init_run(void)
> > +{
> > +       struct rte_last_init *init;
> > +       int ret;
> > +
> > +       TAILQ_FOREACH(init, &rte_last_init_list, next) {
> > +               ret = init->cb(init->arg);
> > +               if (ret)
> > +                       return ret;
> > +       }
> > +
> > +       return 0;
> > +}
> > diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build
>
> > +typedef int (*rte_last_init_cb)(const void *arg);
> > +
> > +/**
> > + * A structure describing a generic initialization.
> > + */
> > +struct rte_last_init {
> > +       TAILQ_ENTRY(rte_last_init) next;   /**< Next bus object in linked list */
> > +       const void *arg;
> > +       rte_last_init_cb cb;
> > +};
>
> No need to expose this structure. Move to eal_private.h
>
>
> > +
> > +/** Double linked list of buses */
> > +TAILQ_HEAD(rte_last_init_list, rte_last_init);
>
> No need to expose this structure. Move to eal_private.h
>
> > +
> > +void rte_last_init_register(rte_last_init_cb cb, const void *arg);
>
> Add Doxygen comment.
>
> Should we change to rte_init_register()? add an enum to specify where to
> call this RTE_INIT_PRE, RTE_INIT_POST to take care of the future needs.
> Just thought of bringing this point to make sure we can use this
> scheme for another use case IF ANY.
>
>
> > +int rte_last_init_run(void);
>
> No need to expose this function in public API. Move to eal_private.h.
> Please start the internal functions with eal_(dont use rte_ for
> internal functions)
Thanks for your review, v2 is sent. thanks.


-- 
Best regards, Tonghao