suricata
util-affinity.c File Reference
#include "suricata-common.h"
#include "util-affinity.h"
#include "util-cpu.h"
#include "util-byte.h"
#include "conf.h"
#include "threads.h"
#include "queue.h"
#include "runmodes.h"
Include dependency graph for util-affinity.c:

Go to the source code of this file.

Macros

#define _THREAD_AFFINITY
 

Functions

ThreadsAffinityTypeGetAffinityTypeFromName (const char *name)
 find affinity by its name More...
 
void BuildCpusetWithCallback (const char *name, ConfNode *node, void(*Callback)(int i, void *data), void *data)
 
void AffinitySetupLoadFromConfig ()
 Extract cpu affinity configuration from current config file. More...
 
int AffinityGetNextCPU (ThreadsAffinityType *taf)
 Return next cpu to use for a given thread family. More...
 

Variables

ThreadsAffinityType thread_affinity [MAX_CPU_SET]
 
int thread_affinity_init_done = 0
 

Detailed Description

Author
Eric Leblond eric@.nosp@m.regi.nosp@m.t.org

CPU affinity related code and helper.

Definition in file util-affinity.c.

Macro Definition Documentation

◆ _THREAD_AFFINITY

#define _THREAD_AFFINITY

Definition at line 27 of file util-affinity.c.

Function Documentation

◆ AffinityGetNextCPU()

int AffinityGetNextCPU ( ThreadsAffinityType taf)

Return next cpu to use for a given thread family.

Return values
thecpu to used given by its id

Definition at line 297 of file util-affinity.c.

References ThreadsAffinityType_::cpu_set, ThreadsAffinityType_::lcpu, SC_ERR_INVALID_ARGUMENT, SCLogDebug, SCLogError, SCMutexLock, SCMutexUnlock, ThreadsAffinityType_::taf_mutex, and UtilCpuGetNumProcessorsOnline().

Here is the call graph for this function:

◆ AffinitySetupLoadFromConfig()

void AffinitySetupLoadFromConfig ( )

Extract cpu affinity configuration from current config file.

Definition at line 180 of file util-affinity.c.

Referenced by RunModeInitialize().

Here is the caller graph for this function:

◆ BuildCpusetWithCallback()

void BuildCpusetWithCallback ( const char *  name,
ConfNode node,
void(*)(int i, void *data)  Callback,
void *  data 
)

Definition at line 99 of file util-affinity.c.

References next, SC_ERR_INVALID_ARGUMENT, SCLogError, TAILQ_FOREACH, UtilCpuGetNumProcessorsOnline(), and ConfNode_::val.

Here is the call graph for this function:

◆ GetAffinityTypeFromName()

ThreadsAffinityType* GetAffinityTypeFromName ( const char *  name)

find affinity by its name

Return values
apointer to the affinity or NULL if not found

Definition at line 69 of file util-affinity.c.

References MAX_CPU_SET, and thread_affinity.

Variable Documentation

◆ thread_affinity

ThreadsAffinityType thread_affinity[MAX_CPU_SET]
Initial value:
= {
{
.name = "receive-cpu-set",
.mode_flag = EXCLUSIVE_AFFINITY,
.prio = PRIO_MEDIUM,
.lcpu = 0,
},
{
.name = "worker-cpu-set",
.mode_flag = EXCLUSIVE_AFFINITY,
.prio = PRIO_MEDIUM,
.lcpu = 0,
},
{
.name = "verdict-cpu-set",
.mode_flag = BALANCED_AFFINITY,
.prio = PRIO_MEDIUM,
.lcpu = 0,
},
{
.name = "management-cpu-set",
.mode_flag = BALANCED_AFFINITY,
.prio = PRIO_MEDIUM,
.lcpu = 0,
},
}

store thread affinity mode for all type of threads

Definition at line 35 of file util-affinity.c.

Referenced by GetAffinityTypeFromName(), and TmThreadGetNbThreads().

◆ thread_affinity_init_done

int thread_affinity_init_done = 0

Definition at line 63 of file util-affinity.c.

EXCLUSIVE_AFFINITY
@ EXCLUSIVE_AFFINITY
Definition: util-affinity.h:60
BALANCED_AFFINITY
@ BALANCED_AFFINITY
Definition: util-affinity.h:59
PRIO_MEDIUM
@ PRIO_MEDIUM
Definition: threads.h:91