[v3,5/5] eal/x86: defer power intrinsics variable allocation
Checks
Commit Message
The lcore variable in this code unit is only used through
rte_power_monitor*() public symbols.
Defer the unconditional lcore variable allocation in those symbols.
Fixes: 18b5049ab4fe ("eal/x86: keep power intrinsics state in lcore variable")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Frode Nordahl <frode.nordahl@canonical.com>
---
Changes since v1:
- added an initialiser helper,
---
lib/eal/x86/rte_power_intrinsics.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
@@ -22,7 +22,13 @@ struct power_wait_status {
RTE_LCORE_VAR_HANDLE(struct power_wait_status, wait_status);
-RTE_LCORE_VAR_INIT(wait_status);
+static void
+init_wait_status(void)
+{
+ if (wait_status != NULL)
+ return;
+ RTE_LCORE_VAR_ALLOC(wait_status);
+}
/*
* This function uses UMONITOR/UMWAIT instructions and will enter C0.2 state.
@@ -177,6 +183,7 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc,
if (pmc->fn == NULL)
return -EINVAL;
+ init_wait_status();
s = RTE_LCORE_VAR_LCORE(lcore_id, wait_status);
/* update sleep address */
@@ -269,6 +276,7 @@ rte_power_monitor_wakeup(const unsigned int lcore_id)
if (lcore_id >= RTE_MAX_LCORE)
return -EINVAL;
+ init_wait_status();
s = RTE_LCORE_VAR_LCORE(lcore_id, wait_status);
/*
@@ -308,7 +316,7 @@ int
rte_power_monitor_multi(const struct rte_power_monitor_cond pmc[],
const uint32_t num, const uint64_t tsc_timestamp)
{
- struct power_wait_status *s = RTE_LCORE_VAR(wait_status);
+ struct power_wait_status *s;
uint32_t i, rc;
/* check if supported */
@@ -318,6 +326,9 @@ rte_power_monitor_multi(const struct rte_power_monitor_cond pmc[],
if (pmc == NULL || num == 0)
return -EINVAL;
+ init_wait_status();
+ s = RTE_LCORE_VAR(wait_status);
+
/* we are already inside transaction region, return */
if (rte_xtest() != 0)
return 0;