2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

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: 352b6c7116 ("dpif-lookup: add avx512 gather implementation.")
Fixes: abb807e27d ("dpif-netdev: Add command to switch dpif implementation.")
Fixes: 250ceddcc2 ("dpif-netdev/mfex: Add AVX512 based optimized miniflow extract")
Fixes: b366fa2f49 ("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>
This commit is contained in:
David Marchand
2022-06-29 09:32:24 +02:00
committed by Ilya Maximets
parent 6835d4b01e
commit fe171e4f10
10 changed files with 79 additions and 77 deletions

View File

@@ -20,7 +20,6 @@
#include <config.h>
#include "cpu.h"
#include "dpif-netdev.h"
#include "dpif-netdev-perf.h"
#include "dpif-netdev-private.h"
@@ -59,19 +58,6 @@ struct dpif_userdata {
struct pkt_flow_meta pkt_meta[NETDEV_MAX_BURST];
};
int32_t
dp_netdev_input_outer_avx512_probe(void)
{
bool avx512f_available = cpu_has_isa(OVS_CPU_ISA_X86_AVX512F);
bool bmi2_available = cpu_has_isa(OVS_CPU_ISA_X86_BMI2);
if (!avx512f_available || !bmi2_available) {
return -ENOTSUP;
}
return 0;
}
int32_t
dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd,
struct dp_packet_batch *packets,