Go to the documentation of this file.
51 #ifdef PROFILE_LOCKING
71 #include <sys/param.h>
72 #include <sys/resource.h>
73 #include <sys/cpuset.h>
75 #define cpu_set_t cpuset_t
79 static int SetCPUAffinity(uint16_t cpu);
118 while (decode_pq->
top != NULL) {
124 if (TmThreadsSlotProcessPkt(
tv, slot, extra_p) !=
TM_ECODE_OK) {
145 TmThreadsSlotProcessPktFail(
tv, NULL);
189 r = TmThreadsSlotProcessPkt(
tv, fw_slot,
p);
221 if (slot->SlotThreadInit != NULL) {
222 void *slot_data = NULL;
223 TmEcode r = slot->SlotThreadInit(
tv, slot->slot_initdata, &slot_data);
292 if (slot->SlotThreadExitPrintStats != NULL) {
296 if (slot->SlotThreadDeinit != NULL) {
311 static void *TmThreadsSlotPktAcqLoop(
void *td)
319 SCLogError(
"TmSlot or ThreadVars badly setup: s=%p,"
320 " PktAcqLoop=%p, tmqh_in=%p,"
328 if (!TmThreadsSlotPktAcqLoopInit(td)) {
353 pthread_exit((
void *) 0);
391 static void *TmThreadsLib(
void *td)
398 SCLogError(
"TmSlot or ThreadVars badly setup: s=%p, tmqh_in=%p,"
405 if (!TmThreadsSlotPktAcqLoopInit(
tv)) {
420 static void *TmThreadsSlotVar(
void *td)
447 void *slot_data = NULL;
527 TmThreadsHandleInjectedPackets(
tv);
548 static void *TmThreadsManagement(
void *td)
567 void *slot_data = NULL;
608 pthread_exit((
void *) 0);
626 printf(
"Both slot name and function pointer can't be NULL inside "
627 "TmThreadSetSlots\n");
634 if (strcmp(
name,
"varslot") == 0) {
636 }
else if (strcmp(
name,
"pktacqloop") == 0) {
638 }
else if (strcmp(
name,
"management") == 0) {
640 }
else if (strcmp(
name,
"command") == 0) {
642 }
else if (strcmp(
name,
"lib") == 0) {
644 }
else if (strcmp(
name,
"custom") == 0) {
649 printf(
"Error: Slot \"%s\" not supported\n",
name);
712 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
713 static int SetCPUAffinitySet(cpu_set_t *cs)
715 #if defined OS_FREEBSD
716 int r = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID,
719 int r = thread_policy_set(mach_thread_self(), THREAD_AFFINITY_POLICY,
720 (
void*)cs, THREAD_AFFINITY_POLICY_COUNT);
722 pid_t tid = (pid_t)syscall(SYS_gettid);
723 int r = sched_setaffinity(tid,
sizeof(cpu_set_t), cs);
727 printf(
"Warning: sched_setaffinity failed (%" PRId32
"): %s\n", r,
744 static int SetCPUAffinity(uint16_t cpuid)
746 #if defined __OpenBSD__ || defined __sun
749 int cpu = (int)cpuid;
751 #if defined OS_WIN32 || defined __CYGWIN__
754 int r = (0 == SetThreadAffinityMask(GetCurrentThread(), cs));
756 printf(
"Warning: sched_setaffinity failed (%" PRId32
"): %s\n", r,
760 SCLogDebug(
"CPU Affinity for thread %lu set to CPU %" PRId32,
767 memset(&cs, 0,
sizeof(cs));
771 return SetCPUAffinitySet(&cs);
803 tv->
name, strerror(errno));
805 SCLogDebug(
"Priority set to %"PRId32
" for thread %s",
815 SCLogDebug(
"Nice value set to %"PRId32
" for thread %s",
876 SCLogPerf(
"Setting affinity for thread \"%s\"to cpu/core "
882 #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined __sun
892 if (use_iface_affinity) {
911 }
else if (CPU_ISSET(cpu, &taf->
hiprio_cpu)) {
916 SCLogPerf(
"Setting prio %d for thread \"%s\" to cpu/core "
920 SetCPUAffinitySet(&taf->
cpu_set);
922 SCLogPerf(
"Setting prio %d for thread \"%s\", "
949 const char *outq_name,
const char *outqh_name,
const char *slots,
950 void * (*fn_p)(
void *),
int mucond)
969 if (inq_name != NULL && strcmp(inq_name,
"packetpool") != 0) {
984 if (inqh_name != NULL) {
1001 if (outqh_name != NULL) {
1016 if (outq_name != NULL && strcmp(outq_name,
"packetpool") != 0) {
1075 const char *inqh_name,
const char *outq_name,
1076 const char *outqh_name,
const char *slots)
1206 if (t->
next == NULL) {
1276 if (
tv->
inq != NULL) {
1306 pthread_join(
tv->
t, NULL);
1330 static void TmThreadDrainPacketThreads(
void)
1333 struct timeval start_ts;
1334 struct timeval cur_ts;
1335 gettimeofday(&start_ts, NULL);
1338 gettimeofday(&cur_ts, NULL);
1339 if ((cur_ts.tv_sec - start_ts.tv_sec) > 60) {
1341 "to process their packets in time");
1350 if (ThreadStillHasPackets(
tv)) {
1360 if (ThreadBusy(
tv)) {
1395 struct timeval start_ts;
1396 struct timeval cur_ts;
1397 gettimeofday(&start_ts, NULL);
1400 gettimeofday(&cur_ts, NULL);
1401 if ((cur_ts.tv_sec - start_ts.tv_sec) > 60) {
1402 FatalError(
"Engine unable to disable detect "
1403 "thread - \"%s\". Killing engine",
1421 while (slots != NULL) {
1434 if (ThreadStillHasPackets(
tv)) {
1444 if (ThreadBusy(
tv)) {
1470 if (
tv->
inq != NULL) {
1497 TmThreadDrainPacketThreads();
1500 #ifdef DEBUG_VALIDATION
1501 static void TmThreadDumpThreads(
void);
1504 static void TmThreadDebugValidateNoMorePackets(
void)
1506 #ifdef DEBUG_VALIDATION
1509 if (ThreadStillHasPackets(
tv)) {
1511 TmThreadDumpThreads();
1545 const uint16_t set,
const uint16_t check,
const uint8_t module_flags)
1547 struct timeval start_ts;
1548 struct timeval cur_ts;
1551 TmThreadDrainPacketThreads();
1556 TmThreadDebugValidateNoMorePackets();
1558 gettimeofday(&start_ts, NULL);
1560 gettimeofday(&cur_ts, NULL);
1561 if ((cur_ts.tv_sec - start_ts.tv_sec) > 60) {
1562 FatalError(
"Engine unable to disable packet "
1563 "threads. Killing engine");
1570 if (!CheckModuleFlags(
tv, module_flags)) {
1571 SCLogDebug(
"%s does not have any of the modules %02x, skip",
tv->
name, module_flags);
1579 if (
tv->
inq != NULL) {
1600 #define MIN_WAIT_TIME 100
1601 #define MAX_WAIT_TIME 999999
1614 int r = TmThreadKillThread(
tv);
1628 #undef MIN_WAIT_TIME
1629 #undef MAX_WAIT_TIME
1635 for (i = 0; i <
TVT_MAX; i++) {
1658 TmThreadDeinitMC(
tv);
1690 if ((family < 0) || (family >=
TVT_MAX))
1712 pthread_attr_t attr;
1718 pthread_attr_init(&attr);
1720 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
1726 FatalError(
"Unable to increase stack size to %" PRIu64
" in thread attributes",
1732 pthread_attr_destroy(&attr);
1734 FatalError(
"Unable to create thread %s with pthread_create(): retval %d: %s",
tv->
name, rc,
1738 #if DEBUG && HAVE_PTHREAD_GETATTR_NP
1740 if (pthread_getattr_np(
tv->
t, &attr) == 0) {
1743 pthread_attr_getstack(&attr, &stack_addr, &stack_size);
1744 SCLogDebug(
"stack: %p; size %" PRIu64, stack_addr, (uintmax_t)stack_size);
1745 pthread_attr_destroy(&attr);
1747 SCLogDebug(
"Unable to retrieve current stack-size for display; return code from "
1748 "pthread_getattr_np() is %" PRId32,
1768 printf(
"ERROR: no thread function set\n");
1792 FatalError(
"Fatal error encountered in TmThreadInitMC. "
1797 printf(
"Error initializing the tv->m mutex\n");
1802 FatalError(
"Fatal error encountered in TmThreadInitMC. "
1807 FatalError(
"Error initializing the tv->cond condition "
1847 static TmEcode WaitOnThreadsRunningByType(
const int t)
1849 struct timeval start_ts;
1850 struct timeval cur_ts;
1851 uint32_t thread_cnt = 0;
1862 uint32_t time_budget = 60 + thread_cnt;
1864 gettimeofday(&start_ts, NULL);
1868 while (
tv != NULL) {
1873 "start: flags %04x",
1883 gettimeofday(&cur_ts, NULL);
1884 if (((uint32_t)cur_ts.tv_sec - (uint32_t)start_ts.tv_sec) > time_budget) {
1886 "start in time: flags %04x. Total threads: %u. Time budget %us",
1911 uint16_t RX_num = 0;
1913 uint16_t FM_num = 0;
1914 uint16_t FR_num = 0;
1915 uint16_t TX_num = 0;
1917 for (
int i = 0; i <
TVT_MAX; i++) {
1923 for (
int i = 0; i <
TVT_MAX; i++) {
1941 uint16_t app_len = 32;
1942 uint16_t buf_len = 256;
1944 char append_str[app_len];
1945 char thread_counts[buf_len];
1947 strlcpy(thread_counts,
"Threads created -> ", strlen(
"Threads created -> ") + 1);
1949 snprintf(append_str, app_len,
"RX: %u ", RX_num);
1950 strlcat(thread_counts, append_str, buf_len);
1953 snprintf(append_str, app_len,
"W: %u ", W_num);
1954 strlcat(thread_counts, append_str, buf_len);
1957 snprintf(append_str, app_len,
"TX: %u ", TX_num);
1958 strlcat(thread_counts, append_str, buf_len);
1961 snprintf(append_str, app_len,
"FM: %u ", FM_num);
1962 strlcat(thread_counts, append_str, buf_len);
1965 snprintf(append_str, app_len,
"FR: %u ", FR_num);
1966 strlcat(thread_counts, append_str, buf_len);
1968 snprintf(append_str, app_len,
" Engine started.");
1969 strlcat(thread_counts, append_str, buf_len);
1981 for (
int i = 0; i <
TVT_MAX; i++) {
1983 while (
tv != NULL) {
1997 for (
int i = 0; i <
TVT_MAX; i++) {
2019 struct timeval start_ts;
2020 struct timeval cur_ts;
2021 gettimeofday(&start_ts, NULL);
2025 for (
int i = 0; i <
TVT_MAX; i++) {
2027 while (
tv != NULL) {
2032 "initialize: flags %04x",
2040 gettimeofday(&cur_ts, NULL);
2041 if ((cur_ts.tv_sec - start_ts.tv_sec) > 120) {
2043 "initialize in time: flags %04x",
2084 for (
int i = 0; i <
TVT_MAX; i++) {
2086 while (
tv != NULL) {
2097 #ifdef DEBUG_VALIDATION
2107 static void TmThreadDumpThreads(
void)
2110 for (
int i = 0; i <
TVT_MAX; i++) {
2112 while (
tv != NULL) {
2114 SCLogNotice(
"tv %p: type %u name %s tmm_flags %02X flags %X stream_pq %p",
2120 SCLogNotice(
"tv %p: ==> stream_pq_local: pq.len %u packet src %s",
2125 SCLogNotice(
"tv %p: ==> decode_pq: decode_pq.len %u packet src %s",
2128 TmThreadDoDumpSlots(
tv);
2151 typedef struct Threads_ {
2153 size_t threads_size;
2157 static bool thread_store_sealed =
false;
2158 static Threads thread_store = { NULL, 0, 0 };
2165 thread_store_sealed =
true;
2173 thread_store_sealed =
false;
2180 for (
size_t s = 0; s < thread_store.threads_size; s++) {
2181 Thread *t = &thread_store.threads[s];
2182 if (t == NULL || t->in_use == 0)
2185 SCLogNotice(
"Thread %"PRIuMAX
", %s type %d, tv %p in_use %d",
2186 (uintmax_t)s+1, t->name, t->type, t->tv, t->in_use);
2190 SCLogNotice(
"tv %p type %u name %s tmm_flags %02X flags %X",
2205 if (thread_store.threads == NULL) {
2207 BUG_ON(thread_store.threads == NULL);
2208 thread_store.threads_size =
STEP;
2212 for (s = 0; s < thread_store.threads_size; s++) {
2213 if (thread_store.threads[s].in_use == 0) {
2214 Thread *t = &thread_store.threads[s];
2229 void *newmem =
SCRealloc(thread_store.threads, ((thread_store.threads_size +
STEP) *
sizeof(Thread)));
2231 thread_store.threads = newmem;
2232 memset((uint8_t *)thread_store.threads + (thread_store.threads_size *
sizeof(Thread)), 0x00,
STEP *
sizeof(Thread));
2234 Thread *t = &thread_store.threads[thread_store.threads_size];
2243 s = thread_store.threads_size;
2244 thread_store.threads_size +=
STEP;
2255 if (id <= 0 || id > (
int)thread_store.threads_size) {
2264 thread_store.threads[idx].in_use = 0;
2268 for (s = 0; s < thread_store.threads_size; s++) {
2269 Thread *t = &thread_store.threads[s];
2270 if (t->in_use == 1) {
2276 SCFree(thread_store.threads);
2277 thread_store.threads = NULL;
2278 thread_store.threads_size = 0;
2279 thread_store.threads_cnt = 0;
2289 Thread *t = &thread_store.threads[idx];
2294 if (t->sys_sec_stamp.secs != 0) {
2297 SCLogDebug(
"%s: thread slept for %u secs", t->name, (uint32_t)(now.
secs - tmpts.
secs));
2302 t->sys_sec_stamp = now;
2310 for (
size_t s = 0; s < thread_store.threads_size; s++) {
2311 Thread *t = &thread_store.threads[s];
2333 for (
size_t s = 0; s < thread_store.threads_size; s++) {
2334 Thread *t = &thread_store.threads[s];
2344 t->sys_sec_stamp = now;
2352 const int i = idx - 1;
2353 Thread *t = &thread_store.threads[i];
2359 struct timeval local = { 0 };
2364 for (
size_t s = 0; s < thread_store.threads_size; s++) {
2365 Thread *t = &thread_store.threads[s];
2366 if (t->in_use == 0) {
2395 SCLogDebug(
"ts->tv_sec %"PRIuMAX, (uintmax_t)
ts->tv_sec);
2403 if (thread_max == 0)
2407 if (thread_max > 1024) {
2408 SCLogWarning(
"limited number of 'worker' threads to 1024. Wanted %d", thread_max);
2411 return (uint16_t)thread_max;
2418 if (
id > 0 &&
id <= (
int)thread_store.threads_size) {
2420 Thread *t = &thread_store.threads[idx];
2426 if (
tv->
inq != NULL) {
2431 TmThreadsCaptureBreakLoop(
tv);
2441 #include <pthread.h>
2443 static void *UnpauseHelper(
void *arg)
2456 static int TmThreadsTestWaitForUnpause01(
void)
2481 static int TmThreadsTestWaitForUnpause02(
void)
2491 int rc = pthread_create(&th, NULL, UnpauseHelper, &
th_v);
2495 pthread_join(th, NULL);
2503 UtRegisterTest(
"TmThreadsTestWaitForUnpause01", TmThreadsTestWaitForUnpause01);
2504 UtRegisterTest(
"TmThreadsTestWaitForUnpause02", TmThreadsTestWaitForUnpause02);
const char * thread_name_workers
TmEcode TmThreadSetCPUAffinity(ThreadVars *tv, uint16_t cpu)
Set the thread options (cpu affinity).
bool SCTmThreadsSlotPacketLoopFinish(ThreadVars *tv)
struct FlowQueue_ * flow_queue
bool TmThreadsTimeSubsysIsReady(void)
void TmThreadInitMC(ThreadVars *tv)
Initializes the mutex and condition variables for this TV.
void TmThreadsSealThreads(void)
thread_local uint64_t spin_lock_cnt
TmEcode TmThreadLibSpawn(ThreadVars *tv)
Spawns a "fake" lib thread associated with the ThreadVars instance tv.
TmEcode TmThreadsSlotVarRun(ThreadVars *tv, Packet *p, TmSlot *slot)
Separate run function so we can call it recursively.
TmEcode TmThreadSpawn(ThreadVars *tv)
Spawns a thread associated with the ThreadVars instance tv.
ThreadVars * TmThreadCreateMgmtThreadByName(const char *name, const char *module, int mucond)
Creates and returns the TV instance for a Management thread(MGMT). This function supports only custom...
void TmThreadDisablePacketThreads(const uint16_t set, const uint16_t check, const uint8_t module_flags)
Disable all packet threads.
int TmqhNameToID(const char *name)
bool threading_set_cpu_affinity
TmEcode TmThreadSetupOptions(ThreadVars *tv)
Set the thread options (cpu affinitythread). Priority should be already set by pthread_create.
#define SCTIME_CMP_NEQ(a, b)
const char * thread_name_flow_mgr
SC_ATOMIC_DECLARE(SCTime_t, pktts)
void TmThreadContinueThreads(void)
Unpauses all threads present in tv_root.
ThreadVars * TmThreadCreatePacketHandler(const char *name, const char *inq_name, const char *inqh_name, const char *outq_name, const char *outqh_name, const char *slots)
Creates and returns a TV instance for a Packet Processing Thread. This function doesn't support custo...
#define SC_ATOMIC_SET(name, val)
Set the value for the atomic variable.
#define SCCtrlMutexDestroy
char * AffinityGetYamlPath(ThreadsAffinityType *taf)
Get the YAML path for the given affinity type. The path is built using the parent name (if available)...
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
void CaptureStatsSetup(ThreadVars *tv)
thread_local uint64_t rwr_lock_cnt
void TmThreadsSetFlag(ThreadVars *tv, uint32_t flag)
Set a thread flag.
void TmThreadWaitForFlag(ThreadVars *tv, uint32_t flags)
Waits till the specified flag(s) is(are) set. We don't bother if the kill flag has been set or not on...
void PacketEnqueue(PacketQueue *q, Packet *p)
simple fifo queue for packets with mutex and cond Calling the mutex or triggering the cond is respons...
@ PKT_SRC_CAPTURE_TIMEOUT
uint16_t UtilAffinityGetAffinedCPUNum(ThreadsAffinityType *taf)
Return the total number of CPUs in a given affinity.
void TmThreadsUnsealThreads(void)
#define SCSetThreadName(n)
const char * thread_name_flow_rec
void(* OutHandler)(ThreadVars *, Packet *)
uint32_t TmThreadCountThreadsByTmmFlags(uint8_t flags)
returns a count of all the threads that match the flag
const char * thread_name_autofp
struct PacketQueue_ * stream_pq_local
ThreadVars * tv_root[TVT_MAX]
void TmThreadDisableReceiveThreads(void)
Disable all threads having the specified TMs.
#define SCCtrlCondDestroy
#define SCMUTEX_INITIALIZER
TmEcode TmThreadSetThreadPriority(ThreadVars *tv, int prio)
Set the thread options (thread priority).
#define SCTIME_CMP_EQ(a, b)
bool(* ThreadBusy)(ThreadVars *tv, void *thread_data)
#define THREAD_SET_PRIORITY
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
thread_local uint64_t rww_lock_contention
simple fifo queue for packets
void FlowEnqueue(FlowQueue *q, Flow *f)
add a flow to a queue
SCTime_t TmThreadsGetThreadTime(const int idx)
TmEcode(* PktAcqLoop)(ThreadVars *, void *, void *)
void PacketPoolInit(void)
Packet *(* InHandler)(ThreadVars *)
void TmThreadsInjectFlowById(Flow *f, const int id)
inject a flow into a threads flow queue
thread_local uint64_t rwr_lock_contention
void TmThreadsGetMinimalTimestamp(struct timeval *ts)
ThreadVars * ThreadVarsAlloc(void)
Allocate a new ThreadVars structure.
size_t strlcpy(char *dst, const char *src, size_t siz)
TmEcode TmThreadsProcessDecodePseudoPackets(ThreadVars *tv, PacketQueueNoLock *decode_pq, TmSlot *slot)
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
TmModule * TmModuleGetByName(const char *name)
get a tm module ptr by name
thread_local uint64_t spin_lock_wait_ticks
#define PKT_SET_SRC(p, src_val)
void TmThreadsUnsetFlag(ThreadVars *tv, uint32_t flag)
Unset a thread flag.
void(* InShutdownHandler)(ThreadVars *)
void TmThreadSetPrio(ThreadVars *tv)
Adjusting nice value for threads.
void TmThreadContinue(ThreadVars *tv)
Unpauses a thread.
bool RunmodeIsWorkers(void)
TmEcode(* PktAcqLoop)(ThreadVars *, void *, void *)
#define PASS
Pass the test.
TmEcode TmThreadWaitOnThreadInit(void)
Used to check if all threads have finished their initialization. On finding an un-initialized thread,...
bool RunmodeIsAutofp(void)
TmEcode(* PktAcqBreakLoop)(ThreadVars *, void *)
size_t strlcat(char *, const char *src, size_t siz)
struct TmSlot_ * tm_slots
Packet * PacketDequeueNoLock(PacketQueueNoLock *qnl)
TmEcode(* Management)(ThreadVars *, void *)
#define SCMutexUnlock(mut)
uint64_t threading_set_stack_size
#define PKT_PSEUDO_STREAM_END
void TmThreadsSetThreadTimestamp(const int id, const SCTime_t ts)
thread_local uint64_t rww_lock_cnt
Per thread variable structure.
thread_local uint64_t mutex_lock_contention
#define SCTIME_FROM_TIMEVAL(tv)
Tmq * TmqGetQueueByName(const char *name)
TmEcode(* Management)(ThreadVars *, void *)
thread_local uint64_t spin_lock_contention
TmEcode(* Func)(ThreadVars *, Packet *, void *)
void TmThreadClearThreadsFamily(int family)
#define THV_REQ_FLOW_LOOP
ThreadVars * TmThreadCreate(const char *name, const char *inq_name, const char *inqh_name, const char *outq_name, const char *outqh_name, const char *slots, void *(*fn_p)(void *), int mucond)
Creates and returns the TV instance for a new thread.
FlowQueue * FlowQueueNew(void)
const char * PktSrcToString(enum PktSrcEnum pkt_src)
void TmThreadsUnregisterThread(const int id)
int TmThreadsRegisterThread(ThreadVars *tv, const int type)
#define SCLogWarning(...)
Macro used to log WARNING messages.
void(* OutHandlerCtxFree)(void *)
struct Thread_ __attribute__((aligned(CLS)))
struct ThreadVars_ * next
#define SCTIME_TO_TIMEVAL(tv, t)
int TmThreadTimeoutLoop(ThreadVars *tv, TmSlot *s)
int TmModuleGetIDForTM(TmModule *tm)
Given a TM Module, returns its id.
#define SCCtrlMutexLock(mut)
void TmThreadKillThreads(void)
#define PACKET_PROFILING_TMM_END(p, id)
#define TM_FLAG_DECODE_TM
void CaptureHooksOnPseudoPacketCreated(Packet *p)
TmModule * TmModuleGetById(int id)
Returns a TM Module by its id.
uint8_t thread_setup_flags
thread_local uint64_t rww_lock_wait_ticks
int StatsSetupPrivate(StatsThreadContext *stats, const char *thread_name)
ThreadVars * TmThreadCreateMgmtThread(const char *name, void *(fn_p)(void *), int mucond)
Creates and returns the TV instance for a Management thread(MGMT). This function supports only custom...
uint16_t AffinityGetNextCPU(ThreadVars *tv, ThreadsAffinityType *taf)
thread_local uint64_t rwr_lock_wait_ticks
#define SCMutexInit(mut, mutattrs)
#define TM_FLAG_RECEIVE_TM
void StatsThreadInit(StatsThreadContext *stats)
#define SCGetThreadIdLong(...)
#define SCRealloc(ptr, sz)
void TmThreadsInitThreadsTimestamp(const SCTime_t ts)
struct PacketQueue_ * stream_pq
#define SCTIME_CMP_LT(a, b)
void TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, const void *data)
Appends a new entry to the slots.
#define SCCtrlMutexUnlock(mut)
void TmThreadKillThreadsFamily(int family)
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
void TmThreadAppend(ThreadVars *tv, int type)
Appends this TV to tv_root based on its type.
TmEcode TmThreadSetCPU(ThreadVars *tv, uint8_t type)
ThreadsAffinityType thread_affinity[MAX_CPU_SET]
void(* tmqh_out)(struct ThreadVars_ *, struct Packet_ *)
bool TmThreadsWaitForUnpause(ThreadVars *tv)
Wait for a thread to become unpaused.
struct TmSlot_ * tm_flowworker
int TmThreadGetNbThreads(uint8_t type)
void StatsSyncCounters(StatsThreadContext *stats)
TmEcode(* SlotThreadInit)(ThreadVars *, const void *, void **)
TmEcode(* ThreadInit)(ThreadVars *, const void *, void **)
const void * slot_initdata
uint16_t TmThreadsGetWorkerThreadMax(void)
ThreadVars * TmThreadCreateCmdThreadByName(const char *name, const char *module, int mucond)
Creates and returns the TV instance for a Command thread (CMD). This function supports only custom sl...
#define THREAD_SET_AFFTYPE
void(* ThreadExitPrintStats)(ThreadVars *, void *)
Packet * PacketDequeue(PacketQueue *q)
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
void SCThreadRunInitCallbacks(ThreadVars *tv)
thread_local uint64_t mutex_lock_wait_ticks
#define PACKET_PROFILING_TMM_START(p, id)
struct Packet_ *(* tmqh_in)(struct ThreadVars_ *)
void *(* OutHandlerCtxSetup)(const char *)
#define SCLogError(...)
Macro used to log ERROR messages.
Tmq * TmqCreateQueue(const char *name)
TmEcode(* SlotThreadDeinit)(ThreadVars *, void *)
const char * thread_name_verdict
void(* SlotThreadExitPrintStats)(ThreadVars *, void *)
Tmqh * TmqhGetQueueHandlerByID(const int id)
#define SC_ATOMIC_INITPTR(name)
void TmThreadsRegisterTests(void)
PacketQueueNoLock decode_pq
#define SCCtrlMutexInit(mut, mutattr)
void ThreadVarsFree(ThreadVars *tv)
Free a ThreadVars structure.
void EngineDone(void)
Used to indicate that the current task is done.
#define THREAD_SET_AFFINITY
TmEcode TmThreadWaitOnThreadRunning(void)
Waits for all threads to be in a running state.
void TmThreadsListThreads(void)
struct TmSlot_ * slot_next
void TmThreadCheckThreadState(void)
Used to check the thread for certain conditions of failure.
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
ThreadsAffinityType * FindAffinityByInterface(ThreadsAffinityType *parent, const char *interface_name)
uint16_t UtilCpuGetNumProcessorsOnline(void)
Get the number of cpus online in the system.
void PacketPoolDestroy(void)
thread_local uint64_t mutex_lock_cnt
int TmThreadsCheckFlag(ThreadVars *tv, uint32_t flag)
Check if a thread flag is set.
#define SCTIME_INITIALIZER
#define SCLogNotice(...)
Macro used to log NOTICE messages.
#define SCTIME_ADD_SECS(ts, s)
Tmqh * TmqhGetQueueHandlerByName(const char *name)
void StatsThreadCleanup(StatsThreadContext *stats)
void *(* tm_func)(void *)
Packet * PacketGetFromQueueOrAlloc(void)
Get a packet. We try to get a packet from the packetpool first, but if that is empty we alloc a packe...
#define DEBUG_VALIDATE_BUG_ON(exp)
float threading_detect_ratio
#define SC_ATOMIC_AND(name, val)
Bitwise AND a value to our atomic variable.
void SCThreadFreeStorage(ThreadVars *tv)
volatile uint8_t suricata_ctl_flags
#define SC_ATOMIC_OR(name, val)
Bitwise OR a value to our atomic variable.