From: David Marchand <david.marchand@redhat.com>
To: "Mattias Rönnblom" <hofors@lysator.liu.se>
Cc: dev@dpdk.org, thomas@monjalon.net, frode.nordahl@canonical.com,
mattias.ronnblom@ericsson.com, stable@dpdk.org,
"Anatoly Burakov" <anatoly.burakov@intel.com>,
"David Hunt" <david.hunt@intel.com>,
"Sivaprasad Tummala" <sivaprasad.tummala@amd.com>,
"Stephen Hemminger" <stephen@networkplumber.org>,
"Chengwen Feng" <fengchengwen@huawei.com>,
"Konstantin Ananyev" <konstantin.ananyev@huawei.com>,
"Morten Brørup" <mb@smartsharesystems.com>
Subject: Re: [PATCH 2/3] power: defer lcore variable allocation
Date: Mon, 16 Dec 2024 11:02:51 +0100 [thread overview]
Message-ID: <CAJFAV8zFTTQTV0ukAtPpkgZG2K0fqxTkbgKuQ4iY+kiwLKLzbw@mail.gmail.com> (raw)
In-Reply-To: <a76e3a84-57e6-42c9-97fe-bb1ebb02c210@lysator.liu.se>
On Fri, Dec 13, 2024 at 7:58 AM Mattias Rönnblom <hofors@lysator.liu.se> wrote:
> On 2024-12-12 08:57, David Marchand wrote:
> > clb_multiwait, clb_pause and clb_scale_freq callbacks can only be
> > reached after a successful call to
> > rte_power_ethdev_pmgmt_queue_enable.
> > Triggering an allocation in them means we are hiding a (internal)
> > programatic error as allocation and use of a lcore variable are
> > clearly separated atm.
> > If we keep the lcore var api as is, I would add an assert() (maybe
> > under a debug build option) in RTE_LCORE_VAR macros themselves, as
> > calling with a NULL handle means the initialisation path in some
> > code/RTE_LCORE_VAR API use was incorrect.
> >
>
> Sure, that would make sense. RTE_ASSERT(), that is. RTE_VERIFY() would
> be too expensive.
Yes, I'll send in next revision.
>
> >
> > Or because you propose to add the same type of helpers in both this
> > patch and the next, I am considering the other way: hide the
> > allocation in the RTE_LCORE_VAR* macros.
> > Checking for already allocated var in RTE_LCORE_VAR_ALLOC seems fine.
> > But the "fast path" RTE_LCORE_VAR would have an unwanted branch in most cases.
> >
>
> I would prefer to have the ALLOC() macro with semantics most people
> expect from a macro (or function) with that name, which is, I would
> argue, an unconditional allocation.
> It would make sense to have another macro, which performs an allocation
> only if the handle is NULL.
>
> RTE_LCORE_VAR_ASSURE_ALLOCATED(), or just RTE_LCORE_VAR_ASSURE()
> (although the latter sounds a little like an assertion, and not an
> allocation).
>
> RTE_LCORE_VAR_LAZY_ALLOC()
>
> I don't know. Something like that.
- In the power libary case, allocating the lcore variable is followed
by the initialisation of the lcore variable internals (per lcore
tailqs).
For this patch, I will rename the alloc_lcore_cfgs helper I had in v1 as:
static void
+init_lcore_cfgs(void)
+{
+ struct pmd_core_cfg *lcore_cfg;
+ unsigned int lcore_id;
+
+ if (lcore_cfgs != NULL)
+ return;
+
+ RTE_LCORE_VAR_ALLOC(lcore_cfgs);
+
+ /* initialize all tailqs */
+ RTE_LCORE_VAR_FOREACH(lcore_id, lcore_cfg, lcore_cfgs)
+ TAILQ_INIT(&lcore_cfg->head);
+}
and only keep those checks in the public symbols.
- About more macros, I am wondering if this is needed in the end.
Adding assertions in the lcore var accessor should catch incorrect
initialisation path.
> >
> >> A somewhat unrelated question: why is pmd_core_cfg cache-line aligned? I
> >> don't think it should be.
> >
> > Before the conversion to per lcore variable, it was probably useful
> > (avoiding false sharing).
> > With the conversion, indeed, it looks like a waste of space.
> > It seems worth a separate fix.
> >
> >
>
> You will include it, or should I submit a separate patch?
I'll send it in next revision.
--
David Marchand
next prev parent reply other threads:[~2024-12-16 10:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20241205175754.1673888-1-david.marchand@redhat.com>
2024-12-05 17:57 ` [PATCH 1/3] random: defer seeding to EAL init David Marchand
2024-12-06 11:09 ` Mattias Rönnblom
2024-12-16 9:38 ` Burakov, Anatoly
2024-12-05 17:57 ` [PATCH 2/3] power: defer lcore variable allocation David Marchand
2024-12-06 11:29 ` Mattias Rönnblom
2024-12-12 7:57 ` David Marchand
2024-12-13 6:58 ` Mattias Rönnblom
2024-12-16 10:02 ` David Marchand [this message]
2024-12-05 17:57 ` [PATCH 3/3] eal/x86: defer power intrinsics " David Marchand
2024-12-06 11:32 ` Mattias Rönnblom
[not found] ` <20241217085954.3310414-1-david.marchand@redhat.com>
2024-12-17 8:59 ` [PATCH v2 2/5] random: defer seeding to EAL init David Marchand
2024-12-18 16:35 ` Stephen Hemminger
2024-12-18 17:03 ` Mattias Rönnblom
2024-12-17 8:59 ` [PATCH v2 3/5] power: defer lcore variable allocation David Marchand
2024-12-18 11:17 ` Burakov, Anatoly
2024-12-17 8:59 ` [PATCH v2 5/5] eal/x86: defer power intrinsics " David Marchand
2024-12-18 11:17 ` Burakov, Anatoly
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=CAJFAV8zFTTQTV0ukAtPpkgZG2K0fqxTkbgKuQ4iY+kiwLKLzbw@mail.gmail.com \
--to=david.marchand@redhat.com \
--cc=anatoly.burakov@intel.com \
--cc=david.hunt@intel.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=frode.nordahl@canonical.com \
--cc=hofors@lysator.liu.se \
--cc=konstantin.ananyev@huawei.com \
--cc=mattias.ronnblom@ericsson.com \
--cc=mb@smartsharesystems.com \
--cc=sivaprasad.tummala@amd.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
--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 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).