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)
240 if (!strcmp(lnode->
val,
"all")) {
244 }
else if ((sep = strchr(lnode->
val,
'-')) != NULL) {
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)
297 if (strcmp(val,
"decode-cpu-set") == 0 || strcmp(val,
"stream-cpu-set") == 0 ||
298 strcmp(val,
"reject-cpu-set") == 0 || strcmp(val,
"output-cpu-set") == 0) {
302 return (strcmp(val,
"detect-cpu-set") == 0) ?
"worker-cpu-set" : val;
312 if (cpu_node != NULL) {
313 if (BuildCpuset(setname, cpu_node, &taf->
cpu_set) < 0) {
314 SCLogWarning(
"Failed to parse CPU set for %s", setname);
317 SCLogWarning(
"Unable to find 'cpu' node for set %s", setname);
325 const char *priority, cpu_set_t *cpuset,
const char *setname)
329 if (BuildCpuset(setname, node, cpuset) < 0) {
330 SCLogWarning(
"Failed to parse %s priority CPU set for %s", priority, setname);
333 SCLogDebug(
"Unable to find '%s' priority for set %s", priority, setname);
341 static int SetupDefaultPriority(
345 if (default_node == NULL) {
349 if (strcmp(default_node->
val,
"low") == 0) {
351 }
else if (strcmp(default_node->
val,
"medium") == 0) {
353 }
else if (strcmp(default_node->
val,
"high") == 0) {
356 SCLogError(
"Unknown default CPU affinity priority: %s", default_node->
val);
360 SCLogConfig(
"Using default priority '%s' for set %s", default_node->
val, setname);
368 static int SetupAffinityPriority(
375 if (prio_node == NULL) {
379 BuildPriorityCpuset(taf, prio_node,
"low", &taf->
lowprio_cpu, setname);
380 BuildPriorityCpuset(taf, prio_node,
"medium", &taf->
medprio_cpu, setname);
381 BuildPriorityCpuset(taf, prio_node,
"high", &taf->
hiprio_cpu, setname);
382 return SetupDefaultPriority(taf, prio_node, setname);
392 if (mode_node == NULL) {
396 if (strcmp(mode_node->
val,
"exclusive") == 0) {
398 }
else if (strcmp(mode_node->
val,
"balanced") == 0) {
414 if (threads_node == NULL) {
434 static char rootpath[] =
"threading.cpu-affinity";
435 static char path[1024] = { 0 };
436 char subpath[256] = { 0 };
442 if (taf->
parent != NULL) {
444 subpath,
sizeof(subpath),
"%s.interface-specific-cpu-set.", taf->
parent->
name);
445 if (r < 0 || r >= (
long)
sizeof(subpath)) {
454 long r = snprintf(path,
sizeof(path),
"%s.%s%s", rootpath, subpath, taf->
name);
455 if (r < 0 || r >= (
long)
sizeof(path)) {
456 SCLogError(
"Unable to build YAML path for CPU affinity %s", taf->
name);
473 static bool IsWorkerCpuSet(
const char *setname)
475 return (strcmp(setname,
"worker-cpu-set") == 0);
481 static bool IsReceiveCpuSet(
const char *setname)
483 return (strcmp(setname,
"receive-cpu-set") == 0);
497 const char *interface_name = NULL;
499 if (strcmp(child_node->
name,
"interface") == 0) {
500 interface_name = child_node->
val;
504 if (interface_name == NULL) {
510 if (iface_taf == NULL) {
511 SCLogError(
"Failed to allocate CPU affinity type for interface: %s", interface_name);
515 SetupCpuSets(iface_taf, iface_node, interface_name);
516 if (SetupAffinityPriority(iface_taf, iface_node, interface_name) < 0) {
519 if (SetupAffinityMode(iface_taf, iface_node) < 0) {
522 if (SetupAffinityThreads(iface_taf, iface_node) < 0) {
534 char if_af[] =
"interface-specific-cpu-set";
536 if (per_iface_node == NULL) {
542 if (strcmp(iface_node->
val,
"interface") == 0) {
543 if (SetupSingleIfaceAffinity(taf, iface_node) < 0) {
558 static bool AffinityConfigIsLegacy(
void)
560 static bool is_using_legacy_affinity_format =
false;
563 is_using_legacy_affinity_format =
false;
565 return is_using_legacy_affinity_format;
570 return is_using_legacy_affinity_format;
578 if (strstr(affinity->
name,
"-cpu-set") == NULL) {
579 is_using_legacy_affinity_format =
true;
580 return is_using_legacy_affinity_format;
584 return is_using_legacy_affinity_format;
593 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
596 AffinityConfigIsLegacy();
609 char *v = AffinityConfigIsLegacy() ? affinity->
val : affinity->
name;
610 const char *setname = GetAffinitySetName(v);
611 if (setname == NULL) {
617 SCLogError(
"Failed to allocate CPU affinity type: %s", setname);
621 SCLogConfig(
"Found CPU affinity definition for \"%s\"", setname);
623 SCConfNode *aff_query_node = AffinityConfigIsLegacy() ? affinity->head.tqh_first : affinity;
624 SetupCpuSets(taf, aff_query_node, setname);
625 if (SetupAffinityPriority(taf, aff_query_node, setname) < 0) {
626 SCLogError(
"Failed to setup priority for CPU affinity type: %s", setname);
629 if (SetupAffinityMode(taf, aff_query_node) < 0) {
630 SCLogError(
"Failed to setup mode for CPU affinity type: %s", setname);
633 if (SetupAffinityThreads(taf, aff_query_node) < 0) {
634 SCLogError(
"Failed to setup threads for CPU affinity type: %s", setname);
638 if (!AffinityConfigIsLegacy() && (IsWorkerCpuSet(setname) || IsReceiveCpuSet(setname))) {
639 if (SetupPerIfaceAffinity(taf, affinity) < 0) {
640 SCLogError(
"Failed to setup per-interface affinity for CPU affinity type: %s",
649 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
651 static int HwLocDeviceNumaGet(hwloc_topology_t topo, hwloc_obj_t obj)
653 #if HWLOC_VERSION_MAJOR >= 2 && HWLOC_VERSION_MINOR >= 5
656 struct hwloc_location location;
658 location.type = HWLOC_LOCATION_TYPE_OBJECT;
659 location.location.object = obj;
661 int result = hwloc_get_local_numanode_objs(topo, &location, &num_nodes, nodes, 0);
662 if (result == 0 && num_nodes > 0 && num_nodes <=
MAX_NUMA_NODES) {
663 return nodes[0]->logical_index;
667 hwloc_obj_t non_io_ancestor = hwloc_get_non_io_ancestor_obj(topo, obj);
668 if (non_io_ancestor == NULL) {
673 hwloc_obj_t numa_node = NULL;
674 while ((numa_node = hwloc_get_next_obj_by_type(topo, HWLOC_OBJ_NUMANODE, numa_node)) != NULL) {
675 if (hwloc_bitmap_isset(non_io_ancestor->nodeset, numa_node->os_index)) {
676 return numa_node->logical_index;
684 static hwloc_obj_t HwLocDeviceGetByKernelName(hwloc_topology_t topo,
const char *interface_name)
686 hwloc_obj_t obj = NULL;
688 while ((obj = hwloc_get_next_osdev(topo, obj)) != NULL) {
689 if (obj->attr->osdev.type == HWLOC_OBJ_OSDEV_NETWORK &&
690 strcmp(obj->name, interface_name) == 0) {
691 hwloc_obj_t parent = obj->parent;
693 if (parent->type == HWLOC_OBJ_PCI_DEVICE) {
696 parent = parent->parent;
712 static int PcieAddressToComponents(
const char *pcie_address,
unsigned int *domain,
713 unsigned int *bus,
unsigned int *device,
unsigned int *
function)
716 if (sscanf(pcie_address,
"%x:%x:%x.%x", domain, bus, device,
function) != 4) {
717 if (sscanf(pcie_address,
"%x:%x.%x", bus, device,
function) != 3) {
726 static hwloc_obj_t HwLocDeviceGetByPcie(hwloc_topology_t topo,
const char *pcie_address)
728 hwloc_obj_t obj = NULL;
729 unsigned int domain, bus, device,
function;
730 int r = PcieAddressToComponents(pcie_address, &domain, &bus, &device, &
function);
732 while ((obj = hwloc_get_next_pcidev(topo, obj)) != NULL) {
733 if (obj->attr->pcidev.domain == domain && obj->attr->pcidev.bus == bus &&
734 obj->attr->pcidev.dev == device && obj->attr->pcidev.func ==
function) {
742 static void HwlocObjectDump(hwloc_obj_t obj,
const char *iface_name)
745 SCLogDebug(
"No object found for the given PCIe address.\n");
749 static char pcie_address[32];
750 snprintf(pcie_address,
sizeof(pcie_address),
"%04x:%02x:%02x.%x", obj->attr->pcidev.domain,
751 obj->attr->pcidev.bus, obj->attr->pcidev.dev, obj->attr->pcidev.func);
752 SCLogDebug(
"Interface (%s / %s) has NUMA ID %d", iface_name, pcie_address,
753 HwLocDeviceNumaGet(topology, obj));
755 SCLogDebug(
"Object type: %s\n", hwloc_obj_type_string(obj->type));
756 SCLogDebug(
"Logical index: %u\n", obj->logical_index);
759 if (obj->type == HWLOC_OBJ_PCI_DEVICE) {
760 SCLogDebug(
" Domain: %04x\n", obj->attr->pcidev.domain);
761 SCLogDebug(
" Bus: %02x\n", obj->attr->pcidev.bus);
762 SCLogDebug(
" Device: %02x\n", obj->attr->pcidev.dev);
763 SCLogDebug(
" Function: %01x\n", obj->attr->pcidev.func);
764 SCLogDebug(
" Class ID: %04x\n", obj->attr->pcidev.class_id);
765 SCLogDebug(
" Vendor ID: %04x\n", obj->attr->pcidev.vendor_id);
766 SCLogDebug(
" Device ID: %04x\n", obj->attr->pcidev.device_id);
767 SCLogDebug(
" Subvendor ID: %04x\n", obj->attr->pcidev.subvendor_id);
768 SCLogDebug(
" Subdevice ID: %04x\n", obj->attr->pcidev.subdevice_id);
769 SCLogDebug(
" Revision: %02x\n", obj->attr->pcidev.revision);
770 SCLogDebug(
" Link speed: %f GB/s\n", obj->attr->pcidev.linkspeed);
772 SCLogDebug(
" No PCI device attributes available.\n");
792 static int TopologyInitialize(
void)
794 if (topology == NULL) {
795 if (hwloc_topology_init(&topology) == -1) {
800 if (hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM) == -1 ||
801 hwloc_topology_set_io_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_ALL) == -1 ||
802 hwloc_topology_load(topology) == -1) {
804 hwloc_topology_destroy(topology);
814 if (topology != NULL) {
815 hwloc_topology_destroy(topology);
822 hwloc_obj_t if_obj = HwLocDeviceGetByKernelName(topology,
tv->
iface_name);
823 if (if_obj == NULL) {
824 if_obj = HwLocDeviceGetByPcie(topology,
tv->
iface_name);
831 int32_t numa_id = HwLocDeviceNumaGet(topology, if_obj);
848 static bool CPUIsFromNuma(uint16_t ncpu, uint16_t numa)
852 int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
853 hwloc_obj_t numa_node = NULL;
855 uint16_t found_numa = 0;
858 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN) {
862 while ((numa_node = hwloc_get_next_obj_by_depth(topology, depth, numa_node)) != NULL) {
863 hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
864 if (cpuset == NULL) {
868 hwloc_bitmap_copy(cpuset, numa_node->cpuset);
870 if (hwloc_bitmap_isset(cpuset, core_id)) {
871 SCLogDebug(
"Core %d - NUMA %d", core_id, numa_node->logical_index);
873 found_numa = numa_node->logical_index;
874 hwloc_bitmap_free(cpuset);
877 hwloc_bitmap_free(cpuset);
881 if (found && numa == found_numa) {
901 uint16_t cpu = taf->
lcpu[numa_node];
903 (!CPU_ISSET(cpu, &taf->
cpu_set) || !CPUIsFromNuma(cpu, (uint16_t)numa_node))) {
907 taf->
lcpu[numa_node] =
908 (CPU_ISSET(cpu, &taf->
cpu_set) && CPUIsFromNuma(cpu, (uint16_t)numa_node))
911 return (CPU_ISSET(cpu, &taf->
cpu_set) && CPUIsFromNuma(cpu, (uint16_t)numa_node)) ? (int16_t)cpu
917 if (iface_numa != -1) {
918 return FindCPUInNumaNode(iface_numa, taf);
926 if (iface_numa == nid) {
930 int16_t cpu = FindCPUInNumaNode(nid, taf);
932 SCLogPerf(
"CPU %d from NUMA %d assigned to a network interface located on NUMA %d", cpu,
951 uint16_t cpu = taf->
lcpu[0];
955 while (!CPU_ISSET(cpu, &taf->
cpu_set) && attempts < 2) {
956 cpu = (cpu + 1) % num_procs;
963 taf->
lcpu[0] = cpu + 1;
969 uint16_t attempts = 0;
971 while (attempts < 2) {
972 cpu = CPUSelectFromNuma(iface_numa, taf);
974 cpu = CPUSelectAlternative(iface_numa, taf);
983 return (uint16_t)cpu;
986 return CPUSelectDefault(taf);
991 if (iface_numa < 0) {
992 return CPUSelectDefault(taf);
995 return CPUSelectFromNumaOrDefault(iface_numa, taf);
998 static bool AutopinEnabled(
void)
1004 return (
bool)autopin;
1012 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
1013 int iface_numa = -1;
1014 if (AutopinEnabled()) {
1016 if (TopologyShouldAutopin(
tv, taf)) {
1017 if (TopologyInitialize() < 0) {
1018 SCLogError(
"Failed to initialize topology for CPU affinity");
1021 iface_numa = InterfaceGetNumaNode(
tv);
1024 static bool printed =
false;
1028 "threading.autopin option is enabled but hwloc support is not compiled in. "
1029 "Make sure to pass --enable-hwloc to configure when building Suricata.");
1035 ncpu = GetNextAvailableCPU(iface_numa, taf);
1036 SCLogDebug(
"Setting affinity on CPU %d", ncpu);
1049 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
1052 if (CPU_ISSET(i, &taf->
cpu_set)) {
1080 if (CPU_ISSET(i, &tmpcset)) {
1097 for (
int cpu = 0; cpu < max_cpus; cpu++) {
1098 if (CPU_ISSET(cpu, &mod_taf->
cpu_set) && CPU_ISSET(cpu, &static_taf->
cpu_set)) {
1099 CPU_CLR(cpu, &mod_taf->
cpu_set);
1109 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
1115 static void ResetAffinityForTest(
void)
1146 taf->
name =
"management-cpu-set";
1148 taf->
name =
"worker-cpu-set";
1150 taf->
name =
"verdict-cpu-set";
1152 taf->
name =
"receive-cpu-set";
1164 static int ThreadingAffinityTest01(
void)
1168 ResetAffinityForTest();
1169 const char *config =
"%YAML 1.1\n"
1173 " management-cpu-set:\n"
1175 " worker-cpu-set:\n"
1176 " cpu: [ 1, 2, 3 ]\n";
1201 static int ThreadingAffinityTest02(
void)
1205 ResetAffinityForTest();
1207 const char *config =
"%YAML 1.1\n"
1211 " - worker-cpu-set:\n"
1231 static int ThreadingAffinityTest03(
void)
1235 ResetAffinityForTest();
1237 const char *config =
"%YAML 1.1\n"
1241 " worker-cpu-set:\n"
1242 " cpu: [ \"0-3\" ]\n";
1262 static int ThreadingAffinityTest04(
void)
1266 ResetAffinityForTest();
1268 const char *config =
"%YAML 1.1\n"
1272 " worker-cpu-set:\n"
1273 " cpu: [ 1, 3, 5 ]\n";
1295 static int ThreadingAffinityTest05(
void)
1299 ResetAffinityForTest();
1301 const char *config =
"%YAML 1.1\n"
1305 " worker-cpu-set:\n"
1306 " cpu: [ \"all\" ]\n";
1322 static int ThreadingAffinityTest06(
void)
1326 ResetAffinityForTest();
1328 const char *config =
"%YAML 1.1\n"
1332 " worker-cpu-set:\n"
1333 " cpu: [ 0, 1, 2, 3 ]\n"
1336 " medium: [ \"1-2\" ]\n"
1338 " default: \"medium\"\n";
1358 static int ThreadingAffinityTest07(
void)
1362 ResetAffinityForTest();
1364 const char *config =
"%YAML 1.1\n"
1368 " worker-cpu-set:\n"
1370 " mode: \"exclusive\"\n";
1386 static int ThreadingAffinityTest08(
void)
1390 ResetAffinityForTest();
1392 const char *config =
"%YAML 1.1\n"
1396 " worker-cpu-set:\n"
1397 " cpu: [ 0, 1, 2 ]\n"
1414 static int ThreadingAffinityTest09(
void)
1418 ResetAffinityForTest();
1420 const char *config =
"%YAML 1.1\n"
1424 " worker-cpu-set:\n"
1426 " interface-specific-cpu-set:\n"
1427 " - interface: \"eth0\"\n"
1429 " mode: \"exclusive\"\n";
1452 static int ThreadingAffinityTest10(
void)
1456 ResetAffinityForTest();
1458 const char *config =
"%YAML 1.1\n"
1462 " receive-cpu-set:\n"
1464 " interface-specific-cpu-set:\n"
1465 " - interface: \"eth0\"\n"
1467 " - interface: \"eth1\"\n"
1476 bool eth0_found =
false, eth1_found =
false;
1478 for (uint32_t i = 0; i < receive_taf->
nb_children; i++) {
1480 if (strcmp(iface_taf->
name,
"eth0") == 0) {
1481 if (CPU_ISSET(1, &iface_taf->
cpu_set) && CPU_ISSET(2, &iface_taf->
cpu_set) &&
1482 CPU_COUNT(&iface_taf->
cpu_set) == 2) {
1485 }
else if (strcmp(iface_taf->
name,
"eth1") == 0) {
1486 if (CPU_ISSET(3, &iface_taf->
cpu_set) && CPU_ISSET(4, &iface_taf->
cpu_set) &&
1487 CPU_COUNT(&iface_taf->
cpu_set) == 2) {
1503 static int ThreadingAffinityTest11(
void)
1507 ResetAffinityForTest();
1509 const char *config =
"%YAML 1.1\n"
1513 " worker-cpu-set:\n"
1515 " interface-specific-cpu-set:\n"
1516 " - interface: \"eth0\"\n"
1517 " cpu: [ 1, 2, 3 ]\n"
1519 " high: [ \"all\" ]\n"
1520 " default: \"high\"\n";
1543 static int ThreadingAffinityTest12(
void)
1547 ResetAffinityForTest();
1549 const char *config =
"%YAML 1.1\n"
1553 " management-cpu-set:\n"
1555 " receive-cpu-set:\n"
1557 " worker-cpu-set:\n"
1559 " interface-specific-cpu-set:\n"
1560 " - interface: \"eth0\"\n"
1561 " cpu: [ \"5-7\" ]\n"
1563 " high: [ \"all\" ]\n"
1564 " default: \"high\"\n"
1565 " verdict-cpu-set:\n"
1597 static int ThreadingAffinityTest13(
void)
1601 ResetAffinityForTest();
1603 const char *config =
"%YAML 1.1\n"
1607 " worker-cpu-set:\n"
1608 " cpu: [ \"invalid-cpu\" ]\n";
1624 static int ThreadingAffinityTest14(
void)
1628 ResetAffinityForTest();
1630 const char *config =
"%YAML 1.1\n"
1650 static int ThreadingAffinityTest15(
void)
1654 ResetAffinityForTest();
1656 const char *config =
"%YAML 1.1\n"
1660 " - management-cpu-set:\n"
1661 " cpu: [ \"3-1\" ]\n";
1677 static int ThreadingAffinityTest16(
void)
1681 ResetAffinityForTest();
1683 const char *config =
"%YAML 1.1\n"
1687 " - management-cpu-set:\n"
1689 " default: invalid_priority\n";
1703 static int ThreadingAffinityTest17(
void)
1707 ResetAffinityForTest();
1709 const char *config =
"%YAML 1.1\n"
1713 " - management-cpu-set:\n"
1714 " mode: invalid_mode\n";
1728 static int ThreadingAffinityTest18(
void)
1732 ResetAffinityForTest();
1734 const char *config =
"%YAML 1.1\n"
1738 " - management-cpu-set:\n"
1753 static int ThreadingAffinityTest19(
void)
1757 ResetAffinityForTest();
1759 const char *config =
"%YAML 1.1\n"
1763 " - management-cpu-set:\n"
1778 static int ThreadingAffinityTest20(
void)
1782 ResetAffinityForTest();
1784 const char *config =
"%YAML 1.1\n"
1788 " - management-cpu-set:\n"
1789 " threads: invalid_number\n";
1803 static int ThreadingAffinityTest21(
void)
1807 ResetAffinityForTest();
1809 const char *config =
"%YAML 1.1\n"
1813 " - management-cpu-set:\n"
1814 " cpu: [ 0-99999 ]\n";
1828 static int ThreadingAffinityTest22(
void)
1832 ResetAffinityForTest();
1834 const char *config =
"%YAML 1.1\n"
1838 " worker-cpu-set:\n"
1839 " interface-specific-cpu-set:\n"
1840 " - interface: eth0\n"
1842 " interface-specific-cpu-set:\n"
1843 " - interface: eth1\n"
1865 static int ThreadingAffinityTest23(
void)
1869 ResetAffinityForTest();
1871 const char *config =
"%YAML 1.1\n"
1875 " worker-cpu-set:\n"
1876 " cpu: [ 1, 2, 3 ]\n";
1903 static int ThreadingAffinityTest24(
void)
1907 ResetAffinityForTest();
1909 const char *config =
"%YAML 1.1\n"
1913 " - worker-cpu-set:\n"
1914 " interface-specific-cpu-set:\n"
1916 " mode: exclusive\n"
1917 " - interface_name: eth0\n"
1935 static int ThreadingAffinityTest25(
void)
1937 ResetAffinityForTest();
1947 FAIL_IF_NOT(child1 && child2 && child3 && child4);
1963 static int ThreadingAffinityTest26(
void)
1965 ResetAffinityForTest();
1968 memset(&test_taf, 0,
sizeof(test_taf));
1970 char long_name[1024];
1971 memset(long_name,
'a',
sizeof(long_name) - 1);
1972 long_name[
sizeof(long_name) - 1] =
'\0';
1973 test_taf.
name = long_name;
1979 FAIL_IF(path == NULL || strcmp(path,
"threading.cpu-affinity") != 0);
1988 static int ThreadingAffinityTest27(
void)
1992 ResetAffinityForTest();
1994 const char *config =
"%YAML 1.1\n"
1998 " management-cpu-set:\n"
2000 " - worker-cpu-set:\n"
2025 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
2026 UtRegisterTest(
"ThreadingAffinityTest01", ThreadingAffinityTest01);
2027 UtRegisterTest(
"ThreadingAffinityTest02", ThreadingAffinityTest02);
2028 UtRegisterTest(
"ThreadingAffinityTest03", ThreadingAffinityTest03);
2029 UtRegisterTest(
"ThreadingAffinityTest04", ThreadingAffinityTest04);
2030 UtRegisterTest(
"ThreadingAffinityTest05", ThreadingAffinityTest05);
2031 UtRegisterTest(
"ThreadingAffinityTest06", ThreadingAffinityTest06);
2032 UtRegisterTest(
"ThreadingAffinityTest07", ThreadingAffinityTest07);
2033 UtRegisterTest(
"ThreadingAffinityTest08", ThreadingAffinityTest08);
2034 UtRegisterTest(
"ThreadingAffinityTest09", ThreadingAffinityTest09);
2035 UtRegisterTest(
"ThreadingAffinityTest10", ThreadingAffinityTest10);
2036 UtRegisterTest(
"ThreadingAffinityTest11", ThreadingAffinityTest11);
2037 UtRegisterTest(
"ThreadingAffinityTest12", ThreadingAffinityTest12);
2038 UtRegisterTest(
"ThreadingAffinityTest13", ThreadingAffinityTest13);
2039 UtRegisterTest(
"ThreadingAffinityTest14", ThreadingAffinityTest14);
2040 UtRegisterTest(
"ThreadingAffinityTest15", ThreadingAffinityTest15);
2041 UtRegisterTest(
"ThreadingAffinityTest16", ThreadingAffinityTest16);
2042 UtRegisterTest(
"ThreadingAffinityTest17", ThreadingAffinityTest17);
2043 UtRegisterTest(
"ThreadingAffinityTest18", ThreadingAffinityTest18);
2044 UtRegisterTest(
"ThreadingAffinityTest19", ThreadingAffinityTest19);
2045 UtRegisterTest(
"ThreadingAffinityTest20", ThreadingAffinityTest20);
2046 UtRegisterTest(
"ThreadingAffinityTest21", ThreadingAffinityTest21);
2047 UtRegisterTest(
"ThreadingAffinityTest22", ThreadingAffinityTest22);
2048 UtRegisterTest(
"ThreadingAffinityTest23", ThreadingAffinityTest23);
2049 UtRegisterTest(
"ThreadingAffinityTest24", ThreadingAffinityTest24);
2050 UtRegisterTest(
"ThreadingAffinityTest25", ThreadingAffinityTest25);
2051 UtRegisterTest(
"ThreadingAffinityTest26", ThreadingAffinityTest26);
2052 UtRegisterTest(
"ThreadingAffinityTest27", ThreadingAffinityTest27);