DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] eal/x86: fix build on systems with WAITPKG support
@ 2023-08-25 15:28 Bruce Richardson
  2023-08-25 16:07 ` Morten Brørup
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Bruce Richardson @ 2023-08-25 15:28 UTC (permalink / raw)
  To: dev; +Cc: mb, david.marchand, Bruce Richardson, roretzla

When doing a build for a system with WAITPKG support and a modern
compiler, we get build errors for the "_umonitor" intrinsic, due to the
casting away of the "volatile" on the parameter.

../lib/eal/x86/rte_power_intrinsics.c: In function 'rte_power_monitor':
../lib/eal/x86/rte_power_intrinsics.c:113:22: error: passing argument 1
of '_umonitor' discards 'volatile' qualifier from pointer target type
[-Werror=discarded-qualifiers]
  113 |         _umonitor(pmc->addr);
        |                   ~~~^~~~~~

We can avoid this issue by using RTE_PTR_ADD(..., 0) to cast the pointer
through "uintptr_t" and thereby remove the volatile without warning.
We also ensure comments are correct for each leg of the
ifdef..else..endif block.

Fixes: 60943c04f3bc ("eal/x86: use intrinsics for power management")
Cc: roretzla@linux.microsoft.com

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/eal/x86/rte_power_intrinsics.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/eal/x86/rte_power_intrinsics.c b/lib/eal/x86/rte_power_intrinsics.c
index 4066d1392e..4f0404bfb8 100644
--- a/lib/eal/x86/rte_power_intrinsics.c
+++ b/lib/eal/x86/rte_power_intrinsics.c
@@ -103,15 +103,15 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 	rte_spinlock_lock(&s->lock);
 	s->monitor_addr = pmc->addr;
 
-	/*
-	 * we're using raw byte codes for now as only the newest compiler
-	 * versions support this instruction natively.
-	 */
-
 	/* set address for UMONITOR */
 #if defined(RTE_TOOLCHAIN_MSVC) || defined(__WAITPKG__)
-	_umonitor(pmc->addr);
+	/* use RTE_PTR_ADD to cast away "volatile" when using the intrinsic */
+	_umonitor(RTE_PTR_ADD(pmc->addr, 0));
 #else
+	/*
+	 * we're using raw byte codes for compiler versions which
+	 * don't support this instruction natively.
+	 */
 	asm volatile(".byte 0xf3, 0x0f, 0xae, 0xf7;"
 			:
 			: "D"(pmc->addr));
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-08-28 15:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-25 15:28 [PATCH] eal/x86: fix build on systems with WAITPKG support Bruce Richardson
2023-08-25 16:07 ` Morten Brørup
2023-08-28  7:08 ` David Marchand
2023-08-28  8:05   ` David Marchand
2023-08-28  9:29 ` David Marchand
2023-08-28 10:29   ` Bruce Richardson
2023-08-28 10:42     ` Stephen Hemminger
2023-08-28 11:03       ` Bruce Richardson
2023-08-28 14:31         ` Ferruh Yigit
2023-08-28 15:56         ` Tyler Retzlaff
2023-08-28 10:39 ` [PATCH v2] " Bruce Richardson
2023-08-28 14:39   ` David Marchand

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).