From: "Mattias Rönnblom" <hofors@lysator.liu.se>
To: David Marchand <david.marchand@redhat.com>, dev@dpdk.org
Cc: 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: Fri, 6 Dec 2024 12:29:24 +0100 [thread overview]
Message-ID: <16f6d334-d999-4fe7-b177-6daf881b8f1e@lysator.liu.se> (raw)
In-Reply-To: <20241205175754.1673888-3-david.marchand@redhat.com>
On 2024-12-05 18:57, David Marchand wrote:
> The lcore variable in this code unit is only used through
> rte_power_ethdev_pmgmt_queue_*() public symbols.
>
> Defer the unconditional lcore variable allocation in those symbols.
>
> Fixes: 130643319579 ("power: keep per-lcore state in lcore variable")
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> lib/power/rte_power_pmd_mgmt.c | 27 +++++++++++++++++++--------
> 1 file changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c
> index a2fff3b765..29e2d438a3 100644
> --- a/lib/power/rte_power_pmd_mgmt.c
> +++ b/lib/power/rte_power_pmd_mgmt.c
> @@ -72,6 +72,19 @@ struct __rte_cache_aligned pmd_core_cfg {
> };
> static RTE_LCORE_VAR_HANDLE(struct pmd_core_cfg, lcore_cfgs);
>
> +static void
> +alloc_lcore_cfgs(void)
> +{
> + struct pmd_core_cfg *lcore_cfg;
> + unsigned int lcore_id;
> +
> + RTE_LCORE_VAR_ALLOC(lcore_cfgs);
> +
> + /* initialize all tailqs */
> + RTE_LCORE_VAR_FOREACH(lcore_id, lcore_cfg, lcore_cfgs)
> + TAILQ_INIT(&lcore_cfg->head);
> +}
> +
> static inline bool
> queue_equal(const union queue *l, const union queue *r)
> {
> @@ -517,6 +530,9 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id,
> goto end;
> }
>
> + if (lcore_cfgs == NULL)
> + alloc_lcore_cfgs();
> +
I would wrap all RTE_LCORE_VAR_LCORE() and RTE_LCORE_VAR().
static struct pmd_core_cfg *
get_cfg_lcore(unsigned int lcore_id)
{
assure_lcore_cfgs_alloced();
return RTE_LCORE_VAR_LCORE(lcore_cfgs, lcore_id);
}
static struct pmd_core_cfg *
get_cfg(void)
{
get_cfg_lcore(rte_lcore_id());
}
Add
static void
assure_lcore_cfgs_alloced(unsigned int lcore_id)
{
if (lcore_cfgs != NULL)
lcore_cfgs_alloc();
}
..or maybe better merge assure_lcore_cfgs_alloced() and lcore_cfgs_alloc().
Makes it a little harder to make mistakes.
A somewhat unrelated question: why is pmd_core_cfg cache-line aligned? I
don't think it should be.
> lcore_cfg = RTE_LCORE_VAR_LCORE(lcore_id, lcore_cfgs);
>
> /* check if other queues are stopped as well */
> @@ -617,6 +633,9 @@ rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id,
> return ret < 0 ? -EINVAL : -EBUSY;
> }
>
> + if (lcore_cfgs == NULL)
> + alloc_lcore_cfgs();
> +
> /* no need to check queue id as wrong queue id would not be enabled */
> lcore_cfg = RTE_LCORE_VAR_LCORE(lcore_id, lcore_cfgs);
>
> @@ -768,16 +787,8 @@ rte_power_pmd_mgmt_get_scaling_freq_max(unsigned int lcore)
> }
>
> RTE_INIT(rte_power_ethdev_pmgmt_init) {
> - unsigned int lcore_id;
> - struct pmd_core_cfg *lcore_cfg;
> int i;
>
> - RTE_LCORE_VAR_ALLOC(lcore_cfgs);
> -
> - /* initialize all tailqs */
> - RTE_LCORE_VAR_FOREACH(lcore_id, lcore_cfg, lcore_cfgs)
> - TAILQ_INIT(&lcore_cfg->head);
> -
> /* initialize config defaults */
> emptypoll_max = 512;
> pause_duration = 1;
next prev parent reply other threads:[~2024-12-06 11:29 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 [this message]
2024-12-12 7:57 ` David Marchand
2024-12-13 6:58 ` Mattias Rönnblom
2024-12-16 10:02 ` David Marchand
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=16f6d334-d999-4fe7-b177-6daf881b8f1e@lysator.liu.se \
--to=hofors@lysator.liu.se \
--cc=anatoly.burakov@intel.com \
--cc=david.hunt@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=frode.nordahl@canonical.com \
--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).