[PATCH v7 05/14] eal: use umonitor umwait and tpause intrinsics
Konstantin Ananyev
konstantin.v.ananyev at yandex.ru
Mon May 1 14:55:07 CEST 2023
> Inline assembly is not supported for MSVC x64 instead use _umonitor,
> _umwait and _tpause intrinsics.
>
> Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
> Acked-by: Morten Brørup <mb at smartsharesystems.com>
> ---
> lib/eal/x86/rte_power_intrinsics.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/lib/eal/x86/rte_power_intrinsics.c b/lib/eal/x86/rte_power_intrinsics.c
> index f749da9..7d83c24 100644
> --- a/lib/eal/x86/rte_power_intrinsics.c
> +++ b/lib/eal/x86/rte_power_intrinsics.c
> @@ -109,9 +109,13 @@
> */
>
> /* set address for UMONITOR */
> +#ifndef RTE_TOOLCHAIN_MSVC
> asm volatile(".byte 0xf3, 0x0f, 0xae, 0xf7;"
> :
> : "D"(pmc->addr));
> +#else
> + _umonitor(pmc->addr);
> +#endif
>
> /* now that we've put this address into monitor, we can unlock */
> rte_spinlock_unlock(&s->lock);
> @@ -123,10 +127,14 @@
> goto end;
>
> /* execute UMWAIT */
> +#ifndef RTE_TOOLCHAIN_MSVC
> asm volatile(".byte 0xf2, 0x0f, 0xae, 0xf7;"
> : /* ignore rflags */
> : "D"(0), /* enter C0.2 */
> "a"(tsc_l), "d"(tsc_h));
> +#else
> + _umwait(tsc_l, tsc_h);
> +#endif
>
> end:
> /* erase sleep address */
> @@ -153,10 +161,14 @@
> return -ENOTSUP;
>
> /* execute TPAUSE */
> +#ifndef RTE_TOOLCHAIN_MSVC
> asm volatile(".byte 0x66, 0x0f, 0xae, 0xf7;"
> : /* ignore rflags */
> : "D"(0), /* enter C0.2 */
> "a"(tsc_l), "d"(tsc_h));
> +#else
> + _tpause(tsc_l, tsc_h);
> +#endif
>
> return 0;
> }
> --
> 1.8.3.1
AFAIK, with GCC (and CLANG?) these instrincts are controlled
by __WAITPKG__ macro.
So might be it is possible to have sort of 'unite' code:
#if defined (RTE_TOOLCHAIN_MSVC) || defined (__WAITPKG__)
<use insrinct>
#else
<use inline asm>
#endif
Apart from that, LGTM
Acked-by: Konstantin Ananyev <konstantin.v.ananyev at yandex.ru>
More information about the dev
mailing list