File tree Expand file tree Collapse file tree
include/ipfixprobe/outputPlugin/outputStorage Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ namespace ipxp::output {
1212
1313class ThreadAffinitySetter {
1414public:
15- static void setNumaNode (const size_t nodeIndex)
15+ static void setExactCoreOnNumaNode (const size_t nodeIndex)
1616 {
1717 const uint16_t threadIndex = getThreadId ();
1818 const std::size_t numaIndex = nodeIndex % m_architectureInfo.cpusByNumaNode .size ();
@@ -30,6 +30,21 @@ class ThreadAffinitySetter {
3030 }
3131 }
3232
33+ static void setNumaNode (const size_t nodeIndex)
34+ {
35+ const std::size_t numaIndex = nodeIndex % m_architectureInfo.cpusByNumaNode .size ();
36+ cpu_set_t cpuset;
37+ CPU_ZERO (&cpuset);
38+ for (const int cpuToBind : m_architectureInfo.cpusByNumaNode [numaIndex]) {
39+ CPU_SET (cpuToBind, &cpuset);
40+ }
41+ const pthread_t current_thread = pthread_self ();
42+ const int errCode = pthread_setaffinity_np (current_thread, sizeof (cpu_set_t ), &cpuset);
43+ if (errCode != 0 ) {
44+ throw std::system_error (errCode, std::generic_category (), " Failed to pin thread" );
45+ }
46+ }
47+
3348private:
3449 struct ArchitectureInfo {
3550 ArchitectureInfo ()
You can’t perform that action at this time.
0 commit comments