SCLogDebug("ts->tv_sec %"PRIuMAX, (uintmax_t)ts->tv_sec);
}
+uint16_t TmThreadsGetWorkerThreadMax()
+{
+ uint16_t ncpus = UtilCpuGetNumProcessorsOnline();
+ int thread_max = TmThreadGetNbThreads(WORKER_CPU_SET);
+ /* always create at least one thread */
+ if (thread_max == 0)
+ thread_max = ncpus * threading_detect_ratio;
+ if (thread_max < 1)
+ thread_max = 1;
+ if (thread_max > 1024) {
+ SCLogWarning(SC_ERR_RUNMODE, "limited number of 'worker' threads to 1024. Wanted %d", thread_max);
+ thread_max = 1024;
+ }
+ return thread_max;
+}
+
/**
* \retval r 1 if packet was accepted, 0 otherwise
* \note if packet was not accepted, it's still the responsibility
void TmThreadsInitThreadsTimestamp(const struct timeval *ts);
void TmThreadsSetThreadTimestamp(const int id, const struct timeval *ts);
void TmThreadsGetMinimalTimestamp(struct timeval *ts);
+uint16_t TmThreadsGetWorkerThreadMax(void);
bool TmThreadsTimeSubsysIsReady(void);
#endif /* __TM_THREADS_H__ */
char qname[TM_QUEUE_NAME_MAX];
/* Available cpus */
- uint16_t ncpus = UtilCpuGetNumProcessorsOnline();
int nlive = LiveGetDeviceCount();
- int thread_max = TmThreadGetNbThreads(WORKER_CPU_SET);
- /* always create at least one thread */
- if (thread_max == 0)
- thread_max = ncpus * threading_detect_ratio;
- if (thread_max < 1)
- thread_max = 1;
- if (thread_max > 1024) {
- SCLogWarning(SC_ERR_RUNMODE, "limited number of 'worker' threads to 1024. Wanted %d", thread_max);
- thread_max = 1024;
- }
+ uint16_t thread_max = TmThreadsGetWorkerThreadMax();
char *queues = RunmodeAutoFpCreatePickupQueuesString(thread_max);
if (queues == NULL) {
threads_count, recv_mod_name);
/* create the threads */
- for (int thread = 0; thread < MIN(thread_max, threads_count); thread++) {
+ for (int thread = 0; thread < threads_count; thread++) {
snprintf(tname, sizeof(tname), "%s#%02d", thread_name, thread+1);
ThreadVars *tv_receive =
TmThreadCreatePacketHandler(tname,
unsigned char single_mode)
{
int threads_count;
+ uint16_t thread_max = TmThreadsGetWorkerThreadMax();
if (single_mode) {
threads_count = 1;
} else {
- threads_count = ModThreadsCount(aconf);
+ threads_count = MIN(ModThreadsCount(aconf), thread_max);
SCLogInfo("Going to use %" PRId32 " thread(s)", threads_count);
}
TmModule *tm_module ;
/* Available cpus */
- uint16_t ncpus = UtilCpuGetNumProcessorsOnline();
const int nqueue = LiveGetDeviceCount();
- int thread_max = TmThreadGetNbThreads(WORKER_CPU_SET);
- /* always create at least one thread */
- if (thread_max == 0)
- thread_max = ncpus * threading_detect_ratio;
- if (thread_max < 1)
- thread_max = 1;
- if (thread_max > 1024) {
- SCLogWarning(SC_ERR_RUNMODE, "limited number of 'worker' threads to 1024. Wanted %d", thread_max);
- thread_max = 1024;
- }
+ uint16_t thread_max = TmThreadsGetWorkerThreadMax();
char *queues = RunmodeAutoFpCreatePickupQueuesString(thread_max);
if (queues == NULL) {