mirror of
https://github.com/openvswitch/ovs
synced 2025-09-03 07:45:30 +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:
committed by
Ilya Maximets
parent
6835d4b01e
commit
fe171e4f10
@@ -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__ */
|
||||
|
Reference in New Issue
Block a user