Merge in SNORT/snort3 from ~AMUTTUVA/snort3:watchdog_tid to master
Squashed commit of the following:
commit
c21969d8a3bd28db271f2ee069cec9e1a795c25b
Author: Akhilesh MY <amuttuva@cisco.com>
Date: Fri Dec 16 03:08:01 2022 -0500
watchdog: Print thread id as well for better identification of unresponsive threads
// init here to pin separately from packet threads
DetectionEngine::thread_init();
-
+ SnortConfig::get_conf()->thread_config->set_instance_tid(id, (int)gettid());
// Perform all packet thread initialization actions that need to be taken with escalated
// privileges prior to starting the DAQ module.
SnortConfig::get_conf()->thread_config->implement_thread_affinity(
Flow::Flow() = default;
Flow::~Flow() = default;
void ThreadConfig::implement_thread_affinity(SThreadType, unsigned) { }
+void ThreadConfig::set_instance_tid(const int, const int) { }
}
namespace memory
ParseWarning(WARN_CONF, "This platform does not support setting thread affinity.\n");
}
+void ThreadConfig::set_instance_tid(const int id, const int tid)
+{
+ instance_id_to_tid.emplace(id,tid);
+}
+
+const int ThreadConfig::get_instance_tid(const int id)
+{
+ int ret = -1;
+ auto iter = instance_id_to_tid.find(id);
+ if ( iter != instance_id_to_tid.end() )
+ ret = instance_id_to_tid.at(id);
+ return ret;
+}
+
static inline string stringify_thread(const SThreadType& type, const unsigned& id)
{
string info;
if ( !resp[i] )
{
++thread_count;
- WarningMessage("%d ", i);
+ const int tid = SnortConfig::get_conf()->thread_config->get_instance_tid(i);
+ if ( tid != -1 )
+ WarningMessage("%d (TID: %d)", i, tid);
+ else
+ WarningMessage("%d ", i);
}
}
WarningMessage("\n");
void set_named_thread_affinity(const std::string&, CpuSet*);
void implement_thread_affinity(SThreadType, unsigned id);
void implement_named_thread_affinity(const std::string& name);
+ void set_instance_tid(const int, const int);
+ const int get_instance_tid(const int);
static constexpr unsigned int DEFAULT_THREAD_ID = 0;
};
std::map<TypeIdPair, CpuSet*, TypeIdPairComparer> thread_affinity;
std::map<std::string, CpuSet*> named_thread_affinity;
+ std::map<int, int> instance_id_to_tid;
};
}