switch to libtopo and increased max NUMA nodes and cores

This commit is contained in:
quackerd 2022-05-27 04:23:58 +08:00
parent 025a453103
commit 13ef0ff653
6 changed files with 20 additions and 33 deletions

View File

@ -176,6 +176,11 @@ if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
dpdk_extra_ldflags += '-lpcap' dpdk_extra_ldflags += '-lpcap'
endif endif
if is_freebsd
add_project_link_arguments('-L/usr/local/lib/libtopo', language: 'c')
add_project_link_arguments('-ltopo', language: 'c')
endif
# for clang 32-bit compiles we need libatomic for 64-bit atomic ops # for clang 32-bit compiles we need libatomic for 64-bit atomic ops
if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
atomic_dep = cc.find_library('atomic', required: true) atomic_dep = cc.find_library('atomic', required: true)

View File

@ -20,6 +20,8 @@
#include <sys/queue.h> #include <sys/queue.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <libtopo/topo.h>
#include <rte_compat.h> #include <rte_compat.h>
#include <rte_common.h> #include <rte_common.h>
#include <rte_debug.h> #include <rte_debug.h>
@ -696,6 +698,12 @@ rte_eal_init(int argc, char **argv)
/* set log level as early as possible */ /* set log level as early as possible */
eal_log_level_parse(argc, argv); eal_log_level_parse(argc, argv);
if (topo_init(1, 1) != 0) {
rte_eal_init_alert("Cannot init libtopo.");
rte_errno = ENOTSUP;
return -1;
}
if (rte_eal_cpu_init() < 0) { if (rte_eal_cpu_init() < 0) {
rte_eal_init_alert("Cannot detect lcores."); rte_eal_init_alert("Cannot detect lcores.");
rte_errno = ENOTSUP; rte_errno = ENOTSUP;

View File

@ -50,15 +50,6 @@ create_shared_memory(const char *filename, const size_t mem_size)
return map_shared_memory(filename, mem_size, O_RDWR | O_CREAT); return map_shared_memory(filename, mem_size, O_RDWR | O_CREAT);
} }
#define NEXT_CPU_NULL -1;
static inline int
cmask_get_next_cpu(uint64_t *mask)
{
int ffs = ffsll(*mask);
*mask &= ~(1ul << (ffs - 1));
return ffs - 1;
}
static inline int static inline int
cmask_get_num_cpus(const uint64_t mask) cmask_get_num_cpus(const uint64_t mask)
{ {

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <libtopo/topo.h>
#include <rte_log.h> #include <rte_log.h>
#include <rte_eal.h> #include <rte_eal.h>
@ -25,33 +26,13 @@ eal_cpu_core_id(unsigned lcore_id)
static int static int
eal_get_ncpus(void) eal_get_ncpus(void)
{ {
static int ncpu = -1; return topo_num_core();
int mib[2] = {CTL_HW, HW_NCPU};
size_t len = sizeof(ncpu);
if (ncpu < 0) {
sysctl(mib, 2, &ncpu, &len, NULL, 0);
RTE_LOG(INFO, EAL, "Sysctl reports %d cpus\n", ncpu);
}
return ncpu;
} }
unsigned unsigned
eal_cpu_socket_id(unsigned cpu_id) eal_cpu_socket_id(unsigned cpu_id)
{ {
int error; return topo_core_to_numa(cpu_id);
int domain;
size_t domain_sz = sizeof(domain);
char sysctl_str[32];
snprintf(sysctl_str, sizeof(sysctl_str), "dev.cpu.%d.%%domain", cpu_id);
error = sysctlbyname(sysctl_str, &domain, &domain_sz, NULL, 0);
if (error < 0) {
RTE_LOG(WARNING, EAL, "Failed to get socket id for core %u, returning 0...\n", cpu_id);
domain = 0;
}
return domain;
} }
/* Check if a cpu is present by the presence of the /* Check if a cpu is present by the presence of the

View File

@ -19,3 +19,5 @@ sources += files(
) )
deps += ['kvargs', 'telemetry'] deps += ['kvargs', 'telemetry']
dpdk_extra_ldflags += '-ltopo'
cflags += [ '-I/usr/local/include' ]

View File

@ -24,9 +24,9 @@ option('machine', type: 'string', value: 'native',
description: 'set the target machine type') description: 'set the target machine type')
option('max_ethports', type: 'integer', value: 32, option('max_ethports', type: 'integer', value: 32,
description: 'maximum number of Ethernet devices') description: 'maximum number of Ethernet devices')
option('max_lcores', type: 'integer', value: 128, option('max_lcores', type: 'integer', value: 256,
description: 'maximum number of cores/threads supported by EAL') description: 'maximum number of cores/threads supported by EAL')
option('max_numa_nodes', type: 'integer', value: 4, option('max_numa_nodes', type: 'integer', value: 16,
description: 'maximum number of NUMA nodes supported by EAL') description: 'maximum number of NUMA nodes supported by EAL')
option('enable_trace_fp', type: 'boolean', value: false, option('enable_trace_fp', type: 'boolean', value: false,
description: 'enable fast path trace points.') description: 'enable fast path trace points.')