diff options
author | David Marchand <david.marchand@redhat.com> | 2022-06-29 09:32:24 +0200 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-06-29 11:27:09 +0200 |
commit | fe171e4f109f001f07b867756a261d898f0d2cfc (patch) | |
tree | 431467a9ba5a9cd47d456284efb834f43d88f0a2 /lib/dpif-netdev-extract-avx512.c | |
parent | 6835d4b01e7523535876cd8b6a3e84b23c7d58d1 (diff) | |
download | openvswitch-fe171e4f109f001f07b867756a261d898f0d2cfc.tar.gz |
dpif-netdev: Refactor AVX512 runtime checks.
As described in the bugzilla below, cpu_has_isa code may be compiled
with some AVX512 instructions in it, because cpu.c is built as part of
the libopenvswitchavx512.
This is a problem when this function (supposed to probe for AVX512
instructions availability) is invoked from generic OVS code, on older
CPUs that don't support them.
For the same reason, dpcls_subtable_avx512_gather_probe,
dp_netdev_input_outer_avx512_probe, mfex_avx512_probe and
mfex_avx512_vbmi_probe are potential runtime bombs and can't either be
built as part of libopenvswitchavx512.
Move cpu.c to be part of the "normal" libopenvswitch.
And move other helpers in generic OVS code.
Note:
- dpcls_subtable_avx512_gather_probe is split in two, because it also
needs to do its own magic,
- while moving those helpers, prefer direct calls to cpu_has_isa and
avoid cast to intermediate integer variables when a simple boolean
is enough,
Fixes: 352b6c7116cd ("dpif-lookup: add avx512 gather implementation.")
Fixes: abb807e27dd4 ("dpif-netdev: Add command to switch dpif implementation.")
Fixes: 250ceddcc2d0 ("dpif-netdev/mfex: Add AVX512 based optimized miniflow extract")
Fixes: b366fa2f4947 ("dpif-netdev: Call cpuid for x86 isa availability.")
Reported-at: https://bugzilla.redhat.com/2100393
Reported-by: Ales Musil <amusil@redhat.com>
Co-authored-by: Ales Musil <amusil@redhat.com>
Signed-off-by: Ales Musil <amusil@redhat.com>
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Ales Musil <amusil@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'lib/dpif-netdev-extract-avx512.c')
-rw-r--r-- | lib/dpif-netdev-extract-avx512.c | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/lib/dpif-netdev-extract-avx512.c b/lib/dpif-netdev-extract-avx512.c index f1919befd..502973029 100644 --- a/lib/dpif-netdev-extract-avx512.c +++ b/lib/dpif-netdev-extract-avx512.c @@ -42,7 +42,6 @@ #include <stdint.h> #include <string.h> -#include "cpu.h" #include "flow.h" #include "dpif-netdev-private-dpcls.h" @@ -690,47 +689,5 @@ DECLARE_MFEX_FUNC(ip_udp, PROFILE_ETH_IPV4_UDP) DECLARE_MFEX_FUNC(ip_tcp, PROFILE_ETH_IPV4_TCP) DECLARE_MFEX_FUNC(dot1q_ip_udp, PROFILE_ETH_VLAN_IPV4_UDP) DECLARE_MFEX_FUNC(dot1q_ip_tcp, PROFILE_ETH_VLAN_IPV4_TCP) - - -static int32_t -avx512_isa_probe(uint32_t needs_vbmi) -{ - static enum ovs_cpu_isa isa_required[] = { - OVS_CPU_ISA_X86_AVX512F, - OVS_CPU_ISA_X86_AVX512BW, - OVS_CPU_ISA_X86_BMI2, - }; - - int32_t ret = 0; - for (uint32_t i = 0; i < ARRAY_SIZE(isa_required); i++) { - if (!cpu_has_isa(isa_required[i])) { - ret = -ENOTSUP; - } - } - - if (needs_vbmi) { - if (!cpu_has_isa(OVS_CPU_ISA_X86_AVX512VBMI)) { - ret = -ENOTSUP; - } - } - - return ret; -} - -/* Probe functions to check ISA requirements. */ -int32_t -mfex_avx512_probe(void) -{ - const uint32_t needs_vbmi = 0; - return avx512_isa_probe(needs_vbmi); -} - -int32_t -mfex_avx512_vbmi_probe(void) -{ - const uint32_t needs_vbmi = 1; - return avx512_isa_probe(needs_vbmi); -} - #endif /* __CHECKER__ */ #endif /* __x86_64__ */ |