From: Michael Altizer Date: Tue, 29 Mar 2016 16:04:03 +0000 (-0400) Subject: thread_config: Only log when actually changing thread affinity X-Git-Tag: 3.0.0-233~456^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=641823d98f4fb82cf143de2ddae2102632ec25a2;p=thirdparty%2Fsnort3.git thread_config: Only log when actually changing thread affinity --- diff --git a/src/main/thread_config.cc b/src/main/thread_config.cc index ca43597b4..e2128c1be 100644 --- a/src/main/thread_config.cc +++ b/src/main/thread_config.cc @@ -140,24 +140,28 @@ void ThreadConfig::implement_thread_affinity(SThreadType type, unsigned id) return; TypeIdPair key { type, id }; - hwloc_cpuset_t desired_cpuset; + hwloc_cpuset_t current_cpuset, desired_cpuset; + char* s; auto iter = thread_affinity.find(key); if (iter != thread_affinity.end()) desired_cpuset = iter->second->cpuset; else desired_cpuset = process_cpuset; - - char* s; hwloc_bitmap_list_asprintf(&s, desired_cpuset); + + current_cpuset = hwloc_bitmap_alloc(); + hwloc_get_cpubind(topology, current_cpuset, HWLOC_CPUBIND_THREAD); + if (!hwloc_bitmap_isequal(current_cpuset, desired_cpuset)) + LogMessage("Binding thread %u (type %u) to %s.\n", id, type, s); + hwloc_bitmap_free(current_cpuset); + if (hwloc_set_cpubind(topology, desired_cpuset, HWLOC_CPUBIND_THREAD)) { FatalError("Failed to pin thread %u (type %u) to %s: %s (%d)\n", id, type, s, get_error(errno), errno); } -#ifndef REG_TEST - LogMessage("Bound thread %u (type %u) to %s.\n", id, type, s); -#endif + free(s); }