27 #define _THREAD_AFFINITY
40 .
name =
"receive-cpu-set",
46 .name =
"worker-cpu-set",
52 .name =
"verdict-cpu-set",
58 .name =
"management-cpu-set",
68 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
70 static hwloc_topology_t topology = NULL;
78 if (new_affinity == NULL) {
79 FatalError(
"Unable to allocate memory for new CPU affinity type");
83 if (new_affinity->
name == NULL) {
84 FatalError(
"Unable to allocate memory for new CPU affinity type name");
86 new_affinity->
parent = parent;
90 new_affinity->
lcpu[i] = 0;
103 FatalError(
"Unable to reallocate memory for children CPU affinity types");
116 if (parent == NULL || interface_name == NULL || parent->
nb_children == 0 ||
121 for (uint32_t i = 0; i < parent->
nb_children; i++) {
123 strcmp(parent->
children[i]->
name, interface_name) == 0) {
140 if (
name == NULL || *
name ==
'\0') {
152 if (parent_affinity == NULL) {
157 if (interface_name != NULL) {
161 return child_affinity;
164 return parent_affinity;
178 const char *
name,
const char *interface_name)
190 if (parent_affinity == NULL) {
195 if (interface_name != NULL) {
198 if (child_affinity != NULL) {
199 return child_affinity;
203 return AllocAndInitAffinityType(
name, interface_name, parent_affinity);
206 return parent_affinity;
209 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
210 static void AffinitySetupInit(
void)
220 for (j = 0; j < ncpu; j++) {
228 const char *
name,
SCConfNode *node,
void (*Callback)(
int i,
void *data),
void *data)
239 if (!strcmp(lnode->
val,
"all")) {
243 }
else if (strchr(lnode->
val,
'-') != NULL) {
244 char *sep = strchr(lnode->
val,
'-');
258 SCLogError(
"%s: upper bound (%d) of cpu set is too high, only %d cpu(s)",
name, b,
269 for (i = a; i<= b; i++) {
279 static void AffinityCallback(
int i,
void *data)
281 CPU_SET(i, (cpu_set_t *)data);
284 static int BuildCpuset(
const char *
name,
SCConfNode *node, cpu_set_t *cpu)
292 static const char *GetAffinitySetName(
const char *val)
294 if (strcmp(val,
"decode-cpu-set") == 0 || strcmp(val,
"stream-cpu-set") == 0 ||
295 strcmp(val,
"reject-cpu-set") == 0 || strcmp(val,
"output-cpu-set") == 0) {
299 return (strcmp(val,
"detect-cpu-set") == 0) ?
"worker-cpu-set" : val;
309 if (cpu_node != NULL) {
310 if (BuildCpuset(setname, cpu_node, &taf->
cpu_set) < 0) {
311 SCLogWarning(
"Failed to parse CPU set for %s", setname);
314 SCLogWarning(
"Unable to find 'cpu' node for set %s", setname);
322 const char *priority, cpu_set_t *cpuset,
const char *setname)
326 if (BuildCpuset(setname, node, cpuset) < 0) {
327 SCLogWarning(
"Failed to parse %s priority CPU set for %s", priority, setname);
330 SCLogDebug(
"Unable to find '%s' priority for set %s", priority, setname);
338 static int SetupDefaultPriority(
342 if (default_node == NULL) {
346 if (strcmp(default_node->
val,
"low") == 0) {
348 }
else if (strcmp(default_node->
val,
"medium") == 0) {
350 }
else if (strcmp(default_node->
val,
"high") == 0) {
353 SCLogError(
"Unknown default CPU affinity priority: %s", default_node->
val);
357 SCLogConfig(
"Using default priority '%s' for set %s", default_node->
val, setname);
365 static int SetupAffinityPriority(
372 if (prio_node == NULL) {
376 BuildPriorityCpuset(taf, prio_node,
"low", &taf->
lowprio_cpu, setname);
377 BuildPriorityCpuset(taf, prio_node,
"medium", &taf->
medprio_cpu, setname);
378 BuildPriorityCpuset(taf, prio_node,
"high", &taf->
hiprio_cpu, setname);
379 return SetupDefaultPriority(taf, prio_node, setname);
389 if (mode_node == NULL) {
393 if (strcmp(mode_node->
val,
"exclusive") == 0) {
395 }
else if (strcmp(mode_node->
val,
"balanced") == 0) {
411 if (threads_node == NULL) {
431 static char rootpath[] =
"threading.cpu-affinity";
432 static char path[1024] = { 0 };
433 char subpath[256] = { 0 };
439 if (taf->
parent != NULL) {
441 subpath,
sizeof(subpath),
"%s.interface-specific-cpu-set.", taf->
parent->
name);
442 if (r < 0 || r >= (
long)
sizeof(subpath)) {
451 long r = snprintf(path,
sizeof(path),
"%s.%s%s", rootpath, subpath, taf->
name);
452 if (r < 0 || r >= (
long)
sizeof(path)) {
453 SCLogError(
"Unable to build YAML path for CPU affinity %s", taf->
name);
470 static bool IsWorkerCpuSet(
const char *setname)
472 return (strcmp(setname,
"worker-cpu-set") == 0);
478 static bool IsReceiveCpuSet(
const char *setname)
480 return (strcmp(setname,
"receive-cpu-set") == 0);
494 const char *interface_name = NULL;
496 if (strcmp(child_node->
name,
"interface") == 0) {
497 interface_name = child_node->
val;
501 if (interface_name == NULL) {
507 if (iface_taf == NULL) {
508 SCLogError(
"Failed to allocate CPU affinity type for interface: %s", interface_name);
512 SetupCpuSets(iface_taf, iface_node, interface_name);
513 if (SetupAffinityPriority(iface_taf, iface_node, interface_name) < 0) {
516 if (SetupAffinityMode(iface_taf, iface_node) < 0) {
519 if (SetupAffinityThreads(iface_taf, iface_node) < 0) {
531 char if_af[] =
"interface-specific-cpu-set";
533 if (per_iface_node == NULL) {
539 if (strcmp(iface_node->
val,
"interface") == 0) {
540 if (SetupSingleIfaceAffinity(taf, iface_node) < 0) {
555 static bool AffinityConfigIsLegacy(
void)
557 static bool is_using_legacy_affinity_format =
false;
560 is_using_legacy_affinity_format =
false;
562 return is_using_legacy_affinity_format;
567 return is_using_legacy_affinity_format;
575 if (strstr(affinity->
name,
"-cpu-set") == NULL) {
576 is_using_legacy_affinity_format =
true;
577 return is_using_legacy_affinity_format;
581 return is_using_legacy_affinity_format;
590 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
593 AffinityConfigIsLegacy();
606 char *v = AffinityConfigIsLegacy() ? affinity->
val : affinity->
name;
607 const char *setname = GetAffinitySetName(v);
608 if (setname == NULL) {
614 SCLogError(
"Failed to allocate CPU affinity type: %s", setname);
618 SCLogConfig(
"Found CPU affinity definition for \"%s\"", setname);
620 SCConfNode *aff_query_node = AffinityConfigIsLegacy() ? affinity->head.tqh_first : affinity;
621 SetupCpuSets(taf, aff_query_node, setname);
622 if (SetupAffinityPriority(taf, aff_query_node, setname) < 0) {
623 SCLogError(
"Failed to setup priority for CPU affinity type: %s", setname);
626 if (SetupAffinityMode(taf, aff_query_node) < 0) {
627 SCLogError(
"Failed to setup mode for CPU affinity type: %s", setname);
630 if (SetupAffinityThreads(taf, aff_query_node) < 0) {
631 SCLogError(
"Failed to setup threads for CPU affinity type: %s", setname);
635 if (!AffinityConfigIsLegacy() && (IsWorkerCpuSet(setname) || IsReceiveCpuSet(setname))) {
636 if (SetupPerIfaceAffinity(taf, affinity) < 0) {
637 SCLogError(
"Failed to setup per-interface affinity for CPU affinity type: %s",
646 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
648 static int HwLocDeviceNumaGet(hwloc_topology_t topo, hwloc_obj_t obj)
650 #if HWLOC_VERSION_MAJOR >= 2 && HWLOC_VERSION_MINOR >= 5
653 struct hwloc_location location;
655 location.type = HWLOC_LOCATION_TYPE_OBJECT;
656 location.location.object = obj;
658 int result = hwloc_get_local_numanode_objs(topo, &location, &num_nodes, nodes, 0);
659 if (result == 0 && num_nodes > 0 && num_nodes <=
MAX_NUMA_NODES) {
660 return nodes[0]->logical_index;
665 hwloc_obj_t non_io_ancestor = hwloc_get_non_io_ancestor_obj(topo, obj);
666 if (non_io_ancestor == NULL) {
671 hwloc_obj_t numa_node = NULL;
672 while ((numa_node = hwloc_get_next_obj_by_type(topo, HWLOC_OBJ_NUMANODE, numa_node)) != NULL) {
673 if (hwloc_bitmap_isset(non_io_ancestor->nodeset, numa_node->os_index)) {
674 return numa_node->logical_index;
681 static hwloc_obj_t HwLocDeviceGetByKernelName(hwloc_topology_t topo,
const char *interface_name)
683 hwloc_obj_t obj = NULL;
685 while ((obj = hwloc_get_next_osdev(topo, obj)) != NULL) {
686 if (obj->attr->osdev.type == HWLOC_OBJ_OSDEV_NETWORK &&
687 strcmp(obj->name, interface_name) == 0) {
688 hwloc_obj_t parent = obj->parent;
690 if (parent->type == HWLOC_OBJ_PCI_DEVICE) {
693 parent = parent->parent;
709 static int PcieAddressToComponents(
const char *pcie_address,
unsigned int *domain,
710 unsigned int *bus,
unsigned int *device,
unsigned int *
function)
713 if (sscanf(pcie_address,
"%x:%x:%x.%x", domain, bus, device,
function) != 4) {
714 if (sscanf(pcie_address,
"%x:%x.%x", bus, device,
function) != 3) {
723 static hwloc_obj_t HwLocDeviceGetByPcie(hwloc_topology_t topo,
const char *pcie_address)
725 hwloc_obj_t obj = NULL;
726 unsigned int domain, bus, device,
function;
727 int r = PcieAddressToComponents(pcie_address, &domain, &bus, &device, &
function);
729 while ((obj = hwloc_get_next_pcidev(topo, obj)) != NULL) {
730 if (obj->attr->pcidev.domain == domain && obj->attr->pcidev.bus == bus &&
731 obj->attr->pcidev.dev == device && obj->attr->pcidev.func ==
function) {
739 static void HwlocObjectDump(hwloc_obj_t obj,
const char *iface_name)
742 SCLogDebug(
"No object found for the given PCIe address.\n");
746 static char pcie_address[32];
747 snprintf(pcie_address,
sizeof(pcie_address),
"%04x:%02x:%02x.%x", obj->attr->pcidev.domain,
748 obj->attr->pcidev.bus, obj->attr->pcidev.dev, obj->attr->pcidev.func);
749 SCLogDebug(
"Interface (%s / %s) has NUMA ID %d", iface_name, pcie_address,
750 HwLocDeviceNumaGet(topology, obj));
752 SCLogDebug(
"Object type: %s\n", hwloc_obj_type_string(obj->type));
753 SCLogDebug(
"Logical index: %u\n", obj->logical_index);
756 if (obj->type == HWLOC_OBJ_PCI_DEVICE) {
757 SCLogDebug(
" Domain: %04x\n", obj->attr->pcidev.domain);
758 SCLogDebug(
" Bus: %02x\n", obj->attr->pcidev.bus);
759 SCLogDebug(
" Device: %02x\n", obj->attr->pcidev.dev);
760 SCLogDebug(
" Function: %01x\n", obj->attr->pcidev.func);
761 SCLogDebug(
" Class ID: %04x\n", obj->attr->pcidev.class_id);
762 SCLogDebug(
" Vendor ID: %04x\n", obj->attr->pcidev.vendor_id);
763 SCLogDebug(
" Device ID: %04x\n", obj->attr->pcidev.device_id);
764 SCLogDebug(
" Subvendor ID: %04x\n", obj->attr->pcidev.subvendor_id);
765 SCLogDebug(
" Subdevice ID: %04x\n", obj->attr->pcidev.subdevice_id);
766 SCLogDebug(
" Revision: %02x\n", obj->attr->pcidev.revision);
767 SCLogDebug(
" Link speed: %f GB/s\n", obj->attr->pcidev.linkspeed);
769 SCLogDebug(
" No PCI device attributes available.\n");
789 static int TopologyInitialize(
void)
791 if (topology == NULL) {
792 if (hwloc_topology_init(&topology) == -1) {
797 if (hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM) == -1 ||
798 hwloc_topology_set_io_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_ALL) == -1 ||
799 hwloc_topology_load(topology) == -1) {
801 hwloc_topology_destroy(topology);
811 if (topology != NULL) {
812 hwloc_topology_destroy(topology);
819 hwloc_obj_t if_obj = HwLocDeviceGetByKernelName(topology,
tv->
iface_name);
820 if (if_obj == NULL) {
821 if_obj = HwLocDeviceGetByPcie(topology,
tv->
iface_name);
828 int32_t numa_id = HwLocDeviceNumaGet(topology, if_obj);
845 static bool CPUIsFromNuma(uint16_t ncpu, uint16_t numa)
849 int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
850 hwloc_obj_t numa_node = NULL;
852 uint16_t found_numa = 0;
855 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN) {
859 while ((numa_node = hwloc_get_next_obj_by_depth(topology, depth, numa_node)) != NULL) {
860 hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
861 if (cpuset == NULL) {
865 hwloc_bitmap_copy(cpuset, numa_node->cpuset);
867 if (hwloc_bitmap_isset(cpuset, core_id)) {
868 SCLogDebug(
"Core %d - NUMA %d", core_id, numa_node->logical_index);
870 found_numa = numa_node->logical_index;
871 hwloc_bitmap_free(cpuset);
874 hwloc_bitmap_free(cpuset);
878 if (found && numa == found_numa) {
898 uint16_t cpu = taf->
lcpu[numa_node];
900 (!CPU_ISSET(cpu, &taf->
cpu_set) || !CPUIsFromNuma(cpu, (uint16_t)numa_node))) {
904 taf->
lcpu[numa_node] =
905 (CPU_ISSET(cpu, &taf->
cpu_set) && CPUIsFromNuma(cpu, (uint16_t)numa_node))
908 return (CPU_ISSET(cpu, &taf->
cpu_set) && CPUIsFromNuma(cpu, (uint16_t)numa_node)) ? (int16_t)cpu
914 if (iface_numa != -1) {
915 return FindCPUInNumaNode(iface_numa, taf);
923 if (iface_numa == nid) {
927 int16_t cpu = FindCPUInNumaNode(nid, taf);
929 SCLogPerf(
"CPU %d from NUMA %d assigned to a network interface located on NUMA %d", cpu,
948 uint16_t cpu = taf->
lcpu[0];
952 while (!CPU_ISSET(cpu, &taf->
cpu_set) && attempts < 2) {
953 cpu = (cpu + 1) % num_procs;
960 taf->
lcpu[0] = cpu + 1;
966 uint16_t attempts = 0;
968 while (attempts < 2) {
969 cpu = CPUSelectFromNuma(iface_numa, taf);
971 cpu = CPUSelectAlternative(iface_numa, taf);
980 return (uint16_t)cpu;
983 return CPUSelectDefault(taf);
988 if (iface_numa < 0) {
989 return CPUSelectDefault(taf);
992 return CPUSelectFromNumaOrDefault(iface_numa, taf);
995 static bool AutopinEnabled(
void)
1001 return (
bool)autopin;
1009 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
1010 int iface_numa = -1;
1011 if (AutopinEnabled()) {
1013 if (TopologyShouldAutopin(
tv, taf)) {
1014 if (TopologyInitialize() < 0) {
1015 SCLogError(
"Failed to initialize topology for CPU affinity");
1018 iface_numa = InterfaceGetNumaNode(
tv);
1021 static bool printed =
false;
1025 "threading.autopin option is enabled but hwloc support is not compiled in. "
1026 "Make sure to pass --enable-hwloc to configure when building Suricata.");
1032 ncpu = GetNextAvailableCPU(iface_numa, taf);
1033 SCLogDebug(
"Setting affinity on CPU %d", ncpu);
1046 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
1049 if (CPU_ISSET(i, &taf->
cpu_set)) {
1077 if (CPU_ISSET(i, &tmpcset)) {
1094 for (
int cpu = 0; cpu < max_cpus; cpu++) {
1095 if (CPU_ISSET(cpu, &mod_taf->
cpu_set) && CPU_ISSET(cpu, &static_taf->
cpu_set)) {
1096 CPU_CLR(cpu, &mod_taf->
cpu_set);
1106 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
1112 static void ResetAffinityForTest(
void)
1143 taf->
name =
"management-cpu-set";
1145 taf->
name =
"worker-cpu-set";
1147 taf->
name =
"verdict-cpu-set";
1149 taf->
name =
"receive-cpu-set";
1161 static int ThreadingAffinityTest01(
void)
1165 ResetAffinityForTest();
1166 const char *config =
"%YAML 1.1\n"
1170 " management-cpu-set:\n"
1172 " worker-cpu-set:\n"
1173 " cpu: [ 1, 2, 3 ]\n";
1197 static int ThreadingAffinityTest02(
void)
1201 ResetAffinityForTest();
1203 const char *config =
"%YAML 1.1\n"
1207 " - worker-cpu-set:\n"
1226 static int ThreadingAffinityTest03(
void)
1230 ResetAffinityForTest();
1232 const char *config =
"%YAML 1.1\n"
1236 " worker-cpu-set:\n"
1237 " cpu: [ \"0-3\" ]\n";
1256 static int ThreadingAffinityTest04(
void)
1260 ResetAffinityForTest();
1262 const char *config =
"%YAML 1.1\n"
1266 " worker-cpu-set:\n"
1267 " cpu: [ 1, 3, 5 ]\n";
1288 static int ThreadingAffinityTest05(
void)
1292 ResetAffinityForTest();
1294 const char *config =
"%YAML 1.1\n"
1298 " worker-cpu-set:\n"
1299 " cpu: [ \"all\" ]\n";
1314 static int ThreadingAffinityTest06(
void)
1318 ResetAffinityForTest();
1320 const char *config =
"%YAML 1.1\n"
1324 " worker-cpu-set:\n"
1325 " cpu: [ 0, 1, 2, 3 ]\n"
1328 " medium: [ \"1-2\" ]\n"
1330 " default: \"medium\"\n";
1349 static int ThreadingAffinityTest07(
void)
1353 ResetAffinityForTest();
1355 const char *config =
"%YAML 1.1\n"
1359 " worker-cpu-set:\n"
1361 " mode: \"exclusive\"\n";
1376 static int ThreadingAffinityTest08(
void)
1380 ResetAffinityForTest();
1382 const char *config =
"%YAML 1.1\n"
1386 " worker-cpu-set:\n"
1387 " cpu: [ 0, 1, 2 ]\n"
1403 static int ThreadingAffinityTest09(
void)
1407 ResetAffinityForTest();
1409 const char *config =
"%YAML 1.1\n"
1413 " worker-cpu-set:\n"
1415 " interface-specific-cpu-set:\n"
1416 " - interface: \"eth0\"\n"
1418 " mode: \"exclusive\"\n";
1440 static int ThreadingAffinityTest10(
void)
1444 ResetAffinityForTest();
1446 const char *config =
"%YAML 1.1\n"
1450 " receive-cpu-set:\n"
1452 " interface-specific-cpu-set:\n"
1453 " - interface: \"eth0\"\n"
1455 " - interface: \"eth1\"\n"
1464 bool eth0_found =
false, eth1_found =
false;
1466 for (uint32_t i = 0; i < receive_taf->
nb_children; i++) {
1468 if (strcmp(iface_taf->
name,
"eth0") == 0) {
1469 if (CPU_ISSET(1, &iface_taf->
cpu_set) && CPU_ISSET(2, &iface_taf->
cpu_set) &&
1470 CPU_COUNT(&iface_taf->
cpu_set) == 2) {
1473 }
else if (strcmp(iface_taf->
name,
"eth1") == 0) {
1474 if (CPU_ISSET(3, &iface_taf->
cpu_set) && CPU_ISSET(4, &iface_taf->
cpu_set) &&
1475 CPU_COUNT(&iface_taf->
cpu_set) == 2) {
1490 static int ThreadingAffinityTest11(
void)
1494 ResetAffinityForTest();
1496 const char *config =
"%YAML 1.1\n"
1500 " worker-cpu-set:\n"
1502 " interface-specific-cpu-set:\n"
1503 " - interface: \"eth0\"\n"
1504 " cpu: [ 1, 2, 3 ]\n"
1506 " high: [ \"all\" ]\n"
1507 " default: \"high\"\n";
1529 static int ThreadingAffinityTest12(
void)
1533 ResetAffinityForTest();
1535 const char *config =
"%YAML 1.1\n"
1539 " management-cpu-set:\n"
1541 " receive-cpu-set:\n"
1543 " worker-cpu-set:\n"
1545 " interface-specific-cpu-set:\n"
1546 " - interface: \"eth0\"\n"
1547 " cpu: [ \"5-7\" ]\n"
1549 " high: [ \"all\" ]\n"
1550 " default: \"high\"\n"
1551 " verdict-cpu-set:\n"
1582 static int ThreadingAffinityTest13(
void)
1586 ResetAffinityForTest();
1588 const char *config =
"%YAML 1.1\n"
1592 " worker-cpu-set:\n"
1593 " cpu: [ \"invalid-cpu\" ]\n";
1608 static int ThreadingAffinityTest14(
void)
1612 ResetAffinityForTest();
1614 const char *config =
"%YAML 1.1\n"
1633 static int ThreadingAffinityTest15(
void)
1637 ResetAffinityForTest();
1639 const char *config =
"%YAML 1.1\n"
1643 " - management-cpu-set:\n"
1644 " cpu: [ \"3-1\" ]\n";
1659 static int ThreadingAffinityTest16(
void)
1663 ResetAffinityForTest();
1665 const char *config =
"%YAML 1.1\n"
1669 " - management-cpu-set:\n"
1671 " default: invalid_priority\n";
1684 static int ThreadingAffinityTest17(
void)
1688 ResetAffinityForTest();
1690 const char *config =
"%YAML 1.1\n"
1694 " - management-cpu-set:\n"
1695 " mode: invalid_mode\n";
1708 static int ThreadingAffinityTest18(
void)
1712 ResetAffinityForTest();
1714 const char *config =
"%YAML 1.1\n"
1718 " - management-cpu-set:\n"
1732 static int ThreadingAffinityTest19(
void)
1736 ResetAffinityForTest();
1738 const char *config =
"%YAML 1.1\n"
1742 " - management-cpu-set:\n"
1756 static int ThreadingAffinityTest20(
void)
1760 ResetAffinityForTest();
1762 const char *config =
"%YAML 1.1\n"
1766 " - management-cpu-set:\n"
1767 " threads: invalid_number\n";
1780 static int ThreadingAffinityTest21(
void)
1784 ResetAffinityForTest();
1786 const char *config =
"%YAML 1.1\n"
1790 " - management-cpu-set:\n"
1791 " cpu: [ 0-99999 ]\n";
1804 static int ThreadingAffinityTest22(
void)
1808 ResetAffinityForTest();
1810 const char *config =
"%YAML 1.1\n"
1814 " worker-cpu-set:\n"
1815 " interface-specific-cpu-set:\n"
1816 " - interface: eth0\n"
1818 " interface-specific-cpu-set:\n"
1819 " - interface: eth1\n"
1840 static int ThreadingAffinityTest23(
void)
1844 ResetAffinityForTest();
1846 const char *config =
"%YAML 1.1\n"
1850 " worker-cpu-set:\n"
1851 " cpu: [ 1, 2, 3 ]\n";
1877 static int ThreadingAffinityTest24(
void)
1881 ResetAffinityForTest();
1883 const char *config =
"%YAML 1.1\n"
1887 " - worker-cpu-set:\n"
1888 " interface-specific-cpu-set:\n"
1890 " mode: exclusive\n"
1891 " - interface_name: eth0\n"
1908 static int ThreadingAffinityTest25(
void)
1910 ResetAffinityForTest();
1920 FAIL_IF_NOT(child1 && child2 && child3 && child4);
1936 static int ThreadingAffinityTest26(
void)
1938 ResetAffinityForTest();
1941 memset(&test_taf, 0,
sizeof(test_taf));
1943 char long_name[1024];
1944 memset(long_name,
'a',
sizeof(long_name) - 1);
1945 long_name[
sizeof(long_name) - 1] =
'\0';
1946 test_taf.
name = long_name;
1952 FAIL_IF(path == NULL || strcmp(path,
"threading.cpu-affinity") != 0);
1961 static int ThreadingAffinityTest27(
void)
1965 ResetAffinityForTest();
1967 const char *config =
"%YAML 1.1\n"
1971 " management-cpu-set:\n"
1973 " - worker-cpu-set:\n"
1997 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
1998 UtRegisterTest(
"ThreadingAffinityTest01", ThreadingAffinityTest01);
1999 UtRegisterTest(
"ThreadingAffinityTest02", ThreadingAffinityTest02);
2000 UtRegisterTest(
"ThreadingAffinityTest03", ThreadingAffinityTest03);
2001 UtRegisterTest(
"ThreadingAffinityTest04", ThreadingAffinityTest04);
2002 UtRegisterTest(
"ThreadingAffinityTest05", ThreadingAffinityTest05);
2003 UtRegisterTest(
"ThreadingAffinityTest06", ThreadingAffinityTest06);
2004 UtRegisterTest(
"ThreadingAffinityTest07", ThreadingAffinityTest07);
2005 UtRegisterTest(
"ThreadingAffinityTest08", ThreadingAffinityTest08);
2006 UtRegisterTest(
"ThreadingAffinityTest09", ThreadingAffinityTest09);
2007 UtRegisterTest(
"ThreadingAffinityTest10", ThreadingAffinityTest10);
2008 UtRegisterTest(
"ThreadingAffinityTest11", ThreadingAffinityTest11);
2009 UtRegisterTest(
"ThreadingAffinityTest12", ThreadingAffinityTest12);
2010 UtRegisterTest(
"ThreadingAffinityTest13", ThreadingAffinityTest13);
2011 UtRegisterTest(
"ThreadingAffinityTest14", ThreadingAffinityTest14);
2012 UtRegisterTest(
"ThreadingAffinityTest15", ThreadingAffinityTest15);
2013 UtRegisterTest(
"ThreadingAffinityTest16", ThreadingAffinityTest16);
2014 UtRegisterTest(
"ThreadingAffinityTest17", ThreadingAffinityTest17);
2015 UtRegisterTest(
"ThreadingAffinityTest18", ThreadingAffinityTest18);
2016 UtRegisterTest(
"ThreadingAffinityTest19", ThreadingAffinityTest19);
2017 UtRegisterTest(
"ThreadingAffinityTest20", ThreadingAffinityTest20);
2018 UtRegisterTest(
"ThreadingAffinityTest21", ThreadingAffinityTest21);
2019 UtRegisterTest(
"ThreadingAffinityTest22", ThreadingAffinityTest22);
2020 UtRegisterTest(
"ThreadingAffinityTest23", ThreadingAffinityTest23);
2021 UtRegisterTest(
"ThreadingAffinityTest24", ThreadingAffinityTest24);
2022 UtRegisterTest(
"ThreadingAffinityTest25", ThreadingAffinityTest25);
2023 UtRegisterTest(
"ThreadingAffinityTest26", ThreadingAffinityTest26);
2024 UtRegisterTest(
"ThreadingAffinityTest27", ThreadingAffinityTest27);