27 #define _THREAD_AFFINITY
39 .
name =
"receive-cpu-set",
45 .name =
"worker-cpu-set",
51 .name =
"verdict-cpu-set",
57 .name =
"management-cpu-set",
67 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
69 static hwloc_topology_t topology = NULL;
77 if (new_affinity == NULL) {
78 FatalError(
"Unable to allocate memory for new CPU affinity type");
82 if (new_affinity->
name == NULL) {
83 FatalError(
"Unable to allocate memory for new CPU affinity type name");
85 new_affinity->
parent = parent;
89 new_affinity->
lcpu[i] = 0;
102 FatalError(
"Unable to reallocate memory for children CPU affinity types");
115 if (parent == NULL || interface_name == NULL || parent->
nb_children == 0 ||
120 for (uint32_t i = 0; i < parent->
nb_children; i++) {
122 strcmp(parent->
children[i]->
name, interface_name) == 0) {
139 if (
name == NULL || *
name ==
'\0') {
151 if (parent_affinity == NULL) {
156 if (interface_name != NULL) {
160 return child_affinity;
163 return parent_affinity;
177 const char *
name,
const char *interface_name)
189 if (parent_affinity == NULL) {
194 if (interface_name != NULL) {
197 if (child_affinity != NULL) {
198 return child_affinity;
202 return AllocAndInitAffinityType(
name, interface_name, parent_affinity);
205 return parent_affinity;
208 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
209 static void AffinitySetupInit(
void)
219 for (j = 0; j < ncpu; j++) {
227 const char *
name,
SCConfNode *node,
void (*Callback)(
int i,
void *data),
void *data)
239 if (!strcmp(lnode->
val,
"all")) {
243 }
else if ((sep = strchr(lnode->
val,
'-')) != NULL) {
257 SCLogError(
"%s: upper bound (%d) of cpu set is too high, only %d cpu(s)",
name, b,
268 for (i = a; i<= b; i++) {
278 static void AffinityCallback(
int i,
void *data)
280 CPU_SET(i, (cpu_set_t *)data);
283 static int BuildCpuset(
const char *
name,
SCConfNode *node, cpu_set_t *cpu)
291 static const char *GetAffinitySetName(
const char *val)
296 if (strcmp(val,
"decode-cpu-set") == 0 || strcmp(val,
"stream-cpu-set") == 0 ||
297 strcmp(val,
"reject-cpu-set") == 0 || strcmp(val,
"output-cpu-set") == 0) {
301 return (strcmp(val,
"detect-cpu-set") == 0) ?
"worker-cpu-set" : val;
311 if (cpu_node != NULL) {
312 if (BuildCpuset(setname, cpu_node, &taf->
cpu_set) < 0) {
313 SCLogWarning(
"Failed to parse CPU set for %s", setname);
316 SCLogWarning(
"Unable to find 'cpu' node for set %s", setname);
324 const char *priority, cpu_set_t *cpuset,
const char *setname)
328 if (BuildCpuset(setname, node, cpuset) < 0) {
329 SCLogWarning(
"Failed to parse %s priority CPU set for %s", priority, setname);
332 SCLogDebug(
"Unable to find '%s' priority for set %s", priority, setname);
340 static int SetupDefaultPriority(
344 if (default_node == NULL) {
348 if (strcmp(default_node->
val,
"low") == 0) {
350 }
else if (strcmp(default_node->
val,
"medium") == 0) {
352 }
else if (strcmp(default_node->
val,
"high") == 0) {
355 SCLogError(
"Unknown default CPU affinity priority: %s", default_node->
val);
359 SCLogConfig(
"Using default priority '%s' for set %s", default_node->
val, setname);
367 static int SetupAffinityPriority(
374 if (prio_node == NULL) {
378 BuildPriorityCpuset(taf, prio_node,
"low", &taf->
lowprio_cpu, setname);
379 BuildPriorityCpuset(taf, prio_node,
"medium", &taf->
medprio_cpu, setname);
380 BuildPriorityCpuset(taf, prio_node,
"high", &taf->
hiprio_cpu, setname);
381 return SetupDefaultPriority(taf, prio_node, setname);
391 if (mode_node == NULL) {
395 if (strcmp(mode_node->
val,
"exclusive") == 0) {
397 }
else if (strcmp(mode_node->
val,
"balanced") == 0) {
413 if (threads_node == NULL) {
433 static char rootpath[] =
"threading.cpu-affinity";
434 static char path[1024] = { 0 };
435 char subpath[256] = { 0 };
441 if (taf->
parent != NULL) {
443 subpath,
sizeof(subpath),
"%s.interface-specific-cpu-set.", taf->
parent->
name);
444 if (r < 0 || r >= (
long)
sizeof(subpath)) {
453 long r = snprintf(path,
sizeof(path),
"%s.%s%s", rootpath, subpath, taf->
name);
454 if (r < 0 || r >= (
long)
sizeof(path)) {
455 SCLogError(
"Unable to build YAML path for CPU affinity %s", taf->
name);
472 static bool IsWorkerCpuSet(
const char *setname)
474 return (strcmp(setname,
"worker-cpu-set") == 0);
480 static bool IsReceiveCpuSet(
const char *setname)
482 return (strcmp(setname,
"receive-cpu-set") == 0);
496 const char *interface_name = NULL;
498 if (strcmp(child_node->
name,
"interface") == 0) {
499 interface_name = child_node->
val;
503 if (interface_name == NULL) {
509 if (iface_taf == NULL) {
510 SCLogError(
"Failed to allocate CPU affinity type for interface: %s", interface_name);
514 SetupCpuSets(iface_taf, iface_node, interface_name);
515 if (SetupAffinityPriority(iface_taf, iface_node, interface_name) < 0) {
518 if (SetupAffinityMode(iface_taf, iface_node) < 0) {
521 if (SetupAffinityThreads(iface_taf, iface_node) < 0) {
533 char if_af[] =
"interface-specific-cpu-set";
535 if (per_iface_node == NULL) {
541 if (strcmp(iface_node->
val,
"interface") == 0) {
542 if (SetupSingleIfaceAffinity(taf, iface_node) < 0) {
557 static bool AffinityConfigIsLegacy(
void)
559 static bool is_using_legacy_affinity_format =
false;
562 is_using_legacy_affinity_format =
false;
564 return is_using_legacy_affinity_format;
569 return is_using_legacy_affinity_format;
577 if (strstr(affinity->
name,
"-cpu-set") == NULL) {
578 is_using_legacy_affinity_format =
true;
579 return is_using_legacy_affinity_format;
583 return is_using_legacy_affinity_format;
592 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
595 AffinityConfigIsLegacy();
608 char *v = AffinityConfigIsLegacy() ? affinity->
val : affinity->
name;
609 const char *setname = GetAffinitySetName(v);
610 if (setname == NULL) {
616 SCLogError(
"Failed to allocate CPU affinity type: %s", setname);
620 SCLogConfig(
"Found CPU affinity definition for \"%s\"", setname);
622 SCConfNode *aff_query_node = AffinityConfigIsLegacy() ? affinity->head.tqh_first : affinity;
623 SetupCpuSets(taf, aff_query_node, setname);
624 if (SetupAffinityPriority(taf, aff_query_node, setname) < 0) {
625 SCLogError(
"Failed to setup priority for CPU affinity type: %s", setname);
628 if (SetupAffinityMode(taf, aff_query_node) < 0) {
629 SCLogError(
"Failed to setup mode for CPU affinity type: %s", setname);
632 if (SetupAffinityThreads(taf, aff_query_node) < 0) {
633 SCLogError(
"Failed to setup threads for CPU affinity type: %s", setname);
637 if (!AffinityConfigIsLegacy() && (IsWorkerCpuSet(setname) || IsReceiveCpuSet(setname))) {
638 if (SetupPerIfaceAffinity(taf, affinity) < 0) {
639 SCLogError(
"Failed to setup per-interface affinity for CPU affinity type: %s",
648 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
650 static int HwLocDeviceNumaGet(hwloc_topology_t topo, hwloc_obj_t obj)
652 #if HWLOC_VERSION_MAJOR >= 2 && HWLOC_VERSION_MINOR >= 5
655 struct hwloc_location location;
657 location.type = HWLOC_LOCATION_TYPE_OBJECT;
658 location.location.object = obj;
660 int result = hwloc_get_local_numanode_objs(topo, &location, &num_nodes, nodes, 0);
661 if (result == 0 && num_nodes > 0 && num_nodes <=
MAX_NUMA_NODES) {
662 return nodes[0]->logical_index;
666 hwloc_obj_t non_io_ancestor = hwloc_get_non_io_ancestor_obj(topo, obj);
667 if (non_io_ancestor == NULL) {
672 hwloc_obj_t numa_node = NULL;
673 while ((numa_node = hwloc_get_next_obj_by_type(topo, HWLOC_OBJ_NUMANODE, numa_node)) != NULL) {
674 if (hwloc_bitmap_isset(non_io_ancestor->nodeset, numa_node->os_index)) {
675 return numa_node->logical_index;
683 static hwloc_obj_t HwLocDeviceGetByKernelName(hwloc_topology_t topo,
const char *interface_name)
685 hwloc_obj_t obj = NULL;
687 while ((obj = hwloc_get_next_osdev(topo, obj)) != NULL) {
688 if (obj->attr->osdev.type == HWLOC_OBJ_OSDEV_NETWORK &&
689 strcmp(obj->name, interface_name) == 0) {
690 hwloc_obj_t parent = obj->parent;
692 if (parent->type == HWLOC_OBJ_PCI_DEVICE) {
695 parent = parent->parent;
711 static int PcieAddressToComponents(
const char *pcie_address,
unsigned int *domain,
712 unsigned int *bus,
unsigned int *device,
unsigned int *
function)
715 if (sscanf(pcie_address,
"%x:%x:%x.%x", domain, bus, device,
function) != 4) {
716 if (sscanf(pcie_address,
"%x:%x.%x", bus, device,
function) != 3) {
725 static hwloc_obj_t HwLocDeviceGetByPcie(hwloc_topology_t topo,
const char *pcie_address)
727 hwloc_obj_t obj = NULL;
728 unsigned int domain, bus, device,
function;
729 int r = PcieAddressToComponents(pcie_address, &domain, &bus, &device, &
function);
731 while ((obj = hwloc_get_next_pcidev(topo, obj)) != NULL) {
732 if (obj->attr->pcidev.domain == domain && obj->attr->pcidev.bus == bus &&
733 obj->attr->pcidev.dev == device && obj->attr->pcidev.func ==
function) {
741 static void HwlocObjectDump(hwloc_obj_t obj,
const char *iface_name)
744 SCLogDebug(
"No object found for the given PCIe address.\n");
748 static char pcie_address[32];
749 snprintf(pcie_address,
sizeof(pcie_address),
"%04x:%02x:%02x.%x", obj->attr->pcidev.domain,
750 obj->attr->pcidev.bus, obj->attr->pcidev.dev, obj->attr->pcidev.func);
751 SCLogDebug(
"Interface (%s / %s) has NUMA ID %d", iface_name, pcie_address,
752 HwLocDeviceNumaGet(topology, obj));
754 SCLogDebug(
"Object type: %s\n", hwloc_obj_type_string(obj->type));
755 SCLogDebug(
"Logical index: %u\n", obj->logical_index);
758 if (obj->type == HWLOC_OBJ_PCI_DEVICE) {
759 SCLogDebug(
" Domain: %04x\n", obj->attr->pcidev.domain);
760 SCLogDebug(
" Bus: %02x\n", obj->attr->pcidev.bus);
761 SCLogDebug(
" Device: %02x\n", obj->attr->pcidev.dev);
762 SCLogDebug(
" Function: %01x\n", obj->attr->pcidev.func);
763 SCLogDebug(
" Class ID: %04x\n", obj->attr->pcidev.class_id);
764 SCLogDebug(
" Vendor ID: %04x\n", obj->attr->pcidev.vendor_id);
765 SCLogDebug(
" Device ID: %04x\n", obj->attr->pcidev.device_id);
766 SCLogDebug(
" Subvendor ID: %04x\n", obj->attr->pcidev.subvendor_id);
767 SCLogDebug(
" Subdevice ID: %04x\n", obj->attr->pcidev.subdevice_id);
768 SCLogDebug(
" Revision: %02x\n", obj->attr->pcidev.revision);
769 SCLogDebug(
" Link speed: %f GB/s\n", obj->attr->pcidev.linkspeed);
771 SCLogDebug(
" No PCI device attributes available.\n");
791 static int TopologyInitialize(
void)
793 if (topology == NULL) {
794 if (hwloc_topology_init(&topology) == -1) {
799 if (hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM) == -1 ||
800 hwloc_topology_set_io_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_ALL) == -1 ||
801 hwloc_topology_load(topology) == -1) {
803 hwloc_topology_destroy(topology);
813 if (topology != NULL) {
814 hwloc_topology_destroy(topology);
821 hwloc_obj_t if_obj = HwLocDeviceGetByKernelName(topology,
tv->
iface_name);
822 if (if_obj == NULL) {
823 if_obj = HwLocDeviceGetByPcie(topology,
tv->
iface_name);
830 int32_t numa_id = HwLocDeviceNumaGet(topology, if_obj);
847 static bool CPUIsFromNuma(uint16_t ncpu, uint16_t numa)
851 int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
852 hwloc_obj_t numa_node = NULL;
854 uint16_t found_numa = 0;
857 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN) {
861 while ((numa_node = hwloc_get_next_obj_by_depth(topology, depth, numa_node)) != NULL) {
862 hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
863 if (cpuset == NULL) {
867 hwloc_bitmap_copy(cpuset, numa_node->cpuset);
869 if (hwloc_bitmap_isset(cpuset, core_id)) {
870 SCLogDebug(
"Core %d - NUMA %d", core_id, numa_node->logical_index);
872 found_numa = numa_node->logical_index;
873 hwloc_bitmap_free(cpuset);
876 hwloc_bitmap_free(cpuset);
880 if (found && numa == found_numa) {
900 uint16_t cpu = taf->
lcpu[numa_node];
902 (!CPU_ISSET(cpu, &taf->
cpu_set) || !CPUIsFromNuma(cpu, (uint16_t)numa_node))) {
906 taf->
lcpu[numa_node] =
907 (CPU_ISSET(cpu, &taf->
cpu_set) && CPUIsFromNuma(cpu, (uint16_t)numa_node))
910 return (CPU_ISSET(cpu, &taf->
cpu_set) && CPUIsFromNuma(cpu, (uint16_t)numa_node)) ? (int16_t)cpu
916 if (iface_numa != -1) {
917 return FindCPUInNumaNode(iface_numa, taf);
925 if (iface_numa == nid) {
929 int16_t cpu = FindCPUInNumaNode(nid, taf);
931 SCLogPerf(
"CPU %d from NUMA %d assigned to a network interface located on NUMA %d", cpu,
950 uint16_t cpu = taf->
lcpu[0];
954 while (!CPU_ISSET(cpu, &taf->
cpu_set) && attempts < 2) {
955 cpu = (cpu + 1) % num_procs;
962 taf->
lcpu[0] = cpu + 1;
968 uint16_t attempts = 0;
970 while (attempts < 2) {
971 cpu = CPUSelectFromNuma(iface_numa, taf);
973 cpu = CPUSelectAlternative(iface_numa, taf);
982 return (uint16_t)cpu;
985 return CPUSelectDefault(taf);
990 if (iface_numa < 0) {
991 return CPUSelectDefault(taf);
994 return CPUSelectFromNumaOrDefault(iface_numa, taf);
997 static bool AutopinEnabled(
void)
1003 return (
bool)autopin;
1011 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
1012 int iface_numa = -1;
1013 if (AutopinEnabled()) {
1015 if (TopologyShouldAutopin(
tv, taf)) {
1016 if (TopologyInitialize() < 0) {
1017 SCLogError(
"Failed to initialize topology for CPU affinity");
1020 iface_numa = InterfaceGetNumaNode(
tv);
1023 static bool printed =
false;
1027 "threading.autopin option is enabled but hwloc support is not compiled in. "
1028 "Make sure to pass --enable-hwloc to configure when building Suricata.");
1034 ncpu = GetNextAvailableCPU(iface_numa, taf);
1035 SCLogDebug(
"Setting affinity on CPU %d", ncpu);
1048 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
1051 if (CPU_ISSET(i, &taf->
cpu_set)) {
1079 if (CPU_ISSET(i, &tmpcset)) {
1096 for (
int cpu = 0; cpu < max_cpus; cpu++) {
1097 if (CPU_ISSET(cpu, &mod_taf->
cpu_set) && CPU_ISSET(cpu, &static_taf->
cpu_set)) {
1098 CPU_CLR(cpu, &mod_taf->
cpu_set);
1108 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
1114 static void ResetAffinityForTest(
void)
1145 taf->
name =
"management-cpu-set";
1147 taf->
name =
"worker-cpu-set";
1149 taf->
name =
"verdict-cpu-set";
1151 taf->
name =
"receive-cpu-set";
1163 static int ThreadingAffinityTest01(
void)
1167 ResetAffinityForTest();
1168 const char *config =
"%YAML 1.1\n"
1172 " management-cpu-set:\n"
1174 " worker-cpu-set:\n"
1175 " cpu: [ 1, 2, 3 ]\n";
1200 static int ThreadingAffinityTest02(
void)
1204 ResetAffinityForTest();
1206 const char *config =
"%YAML 1.1\n"
1210 " - worker-cpu-set:\n"
1230 static int ThreadingAffinityTest03(
void)
1234 ResetAffinityForTest();
1236 const char *config =
"%YAML 1.1\n"
1240 " worker-cpu-set:\n"
1241 " cpu: [ \"0-3\" ]\n";
1261 static int ThreadingAffinityTest04(
void)
1265 ResetAffinityForTest();
1267 const char *config =
"%YAML 1.1\n"
1271 " worker-cpu-set:\n"
1272 " cpu: [ 1, 3, 5 ]\n";
1294 static int ThreadingAffinityTest05(
void)
1298 ResetAffinityForTest();
1300 const char *config =
"%YAML 1.1\n"
1304 " worker-cpu-set:\n"
1305 " cpu: [ \"all\" ]\n";
1321 static int ThreadingAffinityTest06(
void)
1325 ResetAffinityForTest();
1327 const char *config =
"%YAML 1.1\n"
1331 " worker-cpu-set:\n"
1332 " cpu: [ 0, 1, 2, 3 ]\n"
1335 " medium: [ \"1-2\" ]\n"
1337 " default: \"medium\"\n";
1357 static int ThreadingAffinityTest07(
void)
1361 ResetAffinityForTest();
1363 const char *config =
"%YAML 1.1\n"
1367 " worker-cpu-set:\n"
1369 " mode: \"exclusive\"\n";
1385 static int ThreadingAffinityTest08(
void)
1389 ResetAffinityForTest();
1391 const char *config =
"%YAML 1.1\n"
1395 " worker-cpu-set:\n"
1396 " cpu: [ 0, 1, 2 ]\n"
1413 static int ThreadingAffinityTest09(
void)
1417 ResetAffinityForTest();
1419 const char *config =
"%YAML 1.1\n"
1423 " worker-cpu-set:\n"
1425 " interface-specific-cpu-set:\n"
1426 " - interface: \"eth0\"\n"
1428 " mode: \"exclusive\"\n";
1451 static int ThreadingAffinityTest10(
void)
1455 ResetAffinityForTest();
1457 const char *config =
"%YAML 1.1\n"
1461 " receive-cpu-set:\n"
1463 " interface-specific-cpu-set:\n"
1464 " - interface: \"eth0\"\n"
1466 " - interface: \"eth1\"\n"
1475 bool eth0_found =
false, eth1_found =
false;
1477 for (uint32_t i = 0; i < receive_taf->
nb_children; i++) {
1479 if (strcmp(iface_taf->
name,
"eth0") == 0) {
1480 if (CPU_ISSET(1, &iface_taf->
cpu_set) && CPU_ISSET(2, &iface_taf->
cpu_set) &&
1481 CPU_COUNT(&iface_taf->
cpu_set) == 2) {
1484 }
else if (strcmp(iface_taf->
name,
"eth1") == 0) {
1485 if (CPU_ISSET(3, &iface_taf->
cpu_set) && CPU_ISSET(4, &iface_taf->
cpu_set) &&
1486 CPU_COUNT(&iface_taf->
cpu_set) == 2) {
1502 static int ThreadingAffinityTest11(
void)
1506 ResetAffinityForTest();
1508 const char *config =
"%YAML 1.1\n"
1512 " worker-cpu-set:\n"
1514 " interface-specific-cpu-set:\n"
1515 " - interface: \"eth0\"\n"
1516 " cpu: [ 1, 2, 3 ]\n"
1518 " high: [ \"all\" ]\n"
1519 " default: \"high\"\n";
1542 static int ThreadingAffinityTest12(
void)
1546 ResetAffinityForTest();
1548 const char *config =
"%YAML 1.1\n"
1552 " management-cpu-set:\n"
1554 " receive-cpu-set:\n"
1556 " worker-cpu-set:\n"
1558 " interface-specific-cpu-set:\n"
1559 " - interface: \"eth0\"\n"
1560 " cpu: [ \"5-7\" ]\n"
1562 " high: [ \"all\" ]\n"
1563 " default: \"high\"\n"
1564 " verdict-cpu-set:\n"
1596 static int ThreadingAffinityTest13(
void)
1600 ResetAffinityForTest();
1602 const char *config =
"%YAML 1.1\n"
1606 " worker-cpu-set:\n"
1607 " cpu: [ \"invalid-cpu\" ]\n";
1623 static int ThreadingAffinityTest14(
void)
1627 ResetAffinityForTest();
1629 const char *config =
"%YAML 1.1\n"
1649 static int ThreadingAffinityTest15(
void)
1653 ResetAffinityForTest();
1655 const char *config =
"%YAML 1.1\n"
1659 " - management-cpu-set:\n"
1660 " cpu: [ \"3-1\" ]\n";
1676 static int ThreadingAffinityTest16(
void)
1680 ResetAffinityForTest();
1682 const char *config =
"%YAML 1.1\n"
1686 " - management-cpu-set:\n"
1688 " default: invalid_priority\n";
1702 static int ThreadingAffinityTest17(
void)
1706 ResetAffinityForTest();
1708 const char *config =
"%YAML 1.1\n"
1712 " - management-cpu-set:\n"
1713 " mode: invalid_mode\n";
1727 static int ThreadingAffinityTest18(
void)
1731 ResetAffinityForTest();
1733 const char *config =
"%YAML 1.1\n"
1737 " - management-cpu-set:\n"
1752 static int ThreadingAffinityTest19(
void)
1756 ResetAffinityForTest();
1758 const char *config =
"%YAML 1.1\n"
1762 " - management-cpu-set:\n"
1777 static int ThreadingAffinityTest20(
void)
1781 ResetAffinityForTest();
1783 const char *config =
"%YAML 1.1\n"
1787 " - management-cpu-set:\n"
1788 " threads: invalid_number\n";
1802 static int ThreadingAffinityTest21(
void)
1806 ResetAffinityForTest();
1808 const char *config =
"%YAML 1.1\n"
1812 " - management-cpu-set:\n"
1813 " cpu: [ 0-99999 ]\n";
1827 static int ThreadingAffinityTest22(
void)
1831 ResetAffinityForTest();
1833 const char *config =
"%YAML 1.1\n"
1837 " worker-cpu-set:\n"
1838 " interface-specific-cpu-set:\n"
1839 " - interface: eth0\n"
1841 " interface-specific-cpu-set:\n"
1842 " - interface: eth1\n"
1864 static int ThreadingAffinityTest23(
void)
1868 ResetAffinityForTest();
1870 const char *config =
"%YAML 1.1\n"
1874 " worker-cpu-set:\n"
1875 " cpu: [ 1, 2, 3 ]\n";
1902 static int ThreadingAffinityTest24(
void)
1906 ResetAffinityForTest();
1908 const char *config =
"%YAML 1.1\n"
1912 " - worker-cpu-set:\n"
1913 " interface-specific-cpu-set:\n"
1915 " mode: exclusive\n"
1916 " - interface_name: eth0\n"
1934 static int ThreadingAffinityTest25(
void)
1936 ResetAffinityForTest();
1946 FAIL_IF_NOT(child1 && child2 && child3 && child4);
1962 static int ThreadingAffinityTest26(
void)
1964 ResetAffinityForTest();
1967 memset(&test_taf, 0,
sizeof(test_taf));
1969 char long_name[1024];
1970 memset(long_name,
'a',
sizeof(long_name) - 1);
1971 long_name[
sizeof(long_name) - 1] =
'\0';
1972 test_taf.
name = long_name;
1978 FAIL_IF(path == NULL || strcmp(path,
"threading.cpu-affinity") != 0);
1987 static int ThreadingAffinityTest27(
void)
1991 ResetAffinityForTest();
1993 const char *config =
"%YAML 1.1\n"
1997 " management-cpu-set:\n"
1999 " - worker-cpu-set:\n"
2024 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
2025 UtRegisterTest(
"ThreadingAffinityTest01", ThreadingAffinityTest01);
2026 UtRegisterTest(
"ThreadingAffinityTest02", ThreadingAffinityTest02);
2027 UtRegisterTest(
"ThreadingAffinityTest03", ThreadingAffinityTest03);
2028 UtRegisterTest(
"ThreadingAffinityTest04", ThreadingAffinityTest04);
2029 UtRegisterTest(
"ThreadingAffinityTest05", ThreadingAffinityTest05);
2030 UtRegisterTest(
"ThreadingAffinityTest06", ThreadingAffinityTest06);
2031 UtRegisterTest(
"ThreadingAffinityTest07", ThreadingAffinityTest07);
2032 UtRegisterTest(
"ThreadingAffinityTest08", ThreadingAffinityTest08);
2033 UtRegisterTest(
"ThreadingAffinityTest09", ThreadingAffinityTest09);
2034 UtRegisterTest(
"ThreadingAffinityTest10", ThreadingAffinityTest10);
2035 UtRegisterTest(
"ThreadingAffinityTest11", ThreadingAffinityTest11);
2036 UtRegisterTest(
"ThreadingAffinityTest12", ThreadingAffinityTest12);
2037 UtRegisterTest(
"ThreadingAffinityTest13", ThreadingAffinityTest13);
2038 UtRegisterTest(
"ThreadingAffinityTest14", ThreadingAffinityTest14);
2039 UtRegisterTest(
"ThreadingAffinityTest15", ThreadingAffinityTest15);
2040 UtRegisterTest(
"ThreadingAffinityTest16", ThreadingAffinityTest16);
2041 UtRegisterTest(
"ThreadingAffinityTest17", ThreadingAffinityTest17);
2042 UtRegisterTest(
"ThreadingAffinityTest18", ThreadingAffinityTest18);
2043 UtRegisterTest(
"ThreadingAffinityTest19", ThreadingAffinityTest19);
2044 UtRegisterTest(
"ThreadingAffinityTest20", ThreadingAffinityTest20);
2045 UtRegisterTest(
"ThreadingAffinityTest21", ThreadingAffinityTest21);
2046 UtRegisterTest(
"ThreadingAffinityTest22", ThreadingAffinityTest22);
2047 UtRegisterTest(
"ThreadingAffinityTest23", ThreadingAffinityTest23);
2048 UtRegisterTest(
"ThreadingAffinityTest24", ThreadingAffinityTest24);
2049 UtRegisterTest(
"ThreadingAffinityTest25", ThreadingAffinityTest25);
2050 UtRegisterTest(
"ThreadingAffinityTest26", ThreadingAffinityTest26);
2051 UtRegisterTest(
"ThreadingAffinityTest27", ThreadingAffinityTest27);