suricata
|
#include "suricata-common.h"
#include "suricata.h"
#include "util-affinity.h"
#include "conf.h"
#include "conf-yaml-loader.h"
#include "runmodes.h"
#include "util-cpu.h"
#include "util-byte.h"
#include "util-debug.h"
#include "util-dpdk.h"
#include "util-unittest.h"
Go to the source code of this file.
Macros | |
#define | _THREAD_AFFINITY |
Functions | |
ThreadsAffinityType * | FindAffinityByInterface (ThreadsAffinityType *parent, const char *interface_name) |
ThreadsAffinityType * | GetAffinityTypeForNameAndIface (const char *name, const char *interface_name) |
Find affinity by name (*-cpu-set name) and an interface name. More... | |
ThreadsAffinityType * | GetOrAllocAffinityTypeForIfaceOfName (const char *name, const char *interface_name) |
Finds affinity by its name and interface name. Interfaces are children of cpu-set names. If the queried interface is not found, then it is allocated, initialized and assigned to the queried cpu-set. More... | |
int | BuildCpusetWithCallback (const char *name, SCConfNode *node, void(*Callback)(int i, void *data), void *data) |
char * | AffinityGetYamlPath (ThreadsAffinityType *taf) |
Get the YAML path for the given affinity type. The path is built using the parent name (if available) and the affinity name. Do not free the returned string. More... | |
void | AffinitySetupLoadFromConfig (void) |
Extract CPU affinity configuration from current config file. More... | |
uint16_t | AffinityGetNextCPU (ThreadVars *tv, ThreadsAffinityType *taf) |
uint16_t | UtilAffinityGetAffinedCPUNum (ThreadsAffinityType *taf) |
Return the total number of CPUs in a given affinity. More... | |
void | ThreadingAffinityRegisterTests (void) |
Register all threading affinity unit tests. More... | |
Variables | |
ThreadsAffinityType | thread_affinity [MAX_CPU_SET] |
int | thread_affinity_init_done = 0 |
CPU affinity related code and helper.
Definition in file util-affinity.c.
#define _THREAD_AFFINITY |
Definition at line 28 of file util-affinity.c.
uint16_t AffinityGetNextCPU | ( | ThreadVars * | tv, |
ThreadsAffinityType * | taf | ||
) |
Definition at line 1006 of file util-affinity.c.
char* AffinityGetYamlPath | ( | ThreadsAffinityType * | taf | ) |
Get the YAML path for the given affinity type. The path is built using the parent name (if available) and the affinity name. Do not free the returned string.
taf | the affinity type - if NULL, the path is built for the root node |
Definition at line 429 of file util-affinity.c.
References ThreadsAffinityType_::name, ThreadsAffinityType_::parent, and SCLogError.
void AffinitySetupLoadFromConfig | ( | void | ) |
Extract CPU affinity configuration from current config file.
Definition at line 588 of file util-affinity.c.
References thread_affinity_init_done.
Referenced by RunModeInitializeThreadSettings().
int BuildCpusetWithCallback | ( | const char * | name, |
SCConfNode * | node, | ||
void(*)(int i, void *data) | Callback, | ||
void * | data | ||
) |
Definition at line 227 of file util-affinity.c.
References name, next, SCLogError, StringParseUint32(), TAILQ_FOREACH, UtilCpuGetNumProcessorsOnline(), and SCConfNode_::val.
ThreadsAffinityType* FindAffinityByInterface | ( | ThreadsAffinityType * | parent, |
const char * | interface_name | ||
) |
Definition at line 113 of file util-affinity.c.
References ThreadsAffinityType_::children, ThreadsAffinityType_::name, and ThreadsAffinityType_::nb_children.
Referenced by GetAffinityTypeForNameAndIface(), and GetOrAllocAffinityTypeForIfaceOfName().
ThreadsAffinityType* GetAffinityTypeForNameAndIface | ( | const char * | name, |
const char * | interface_name | ||
) |
Find affinity by name (*-cpu-set name) and an interface name.
name | the name of the affinity (e.g. worker-cpu-set, receive-cpu-set). The name is required and cannot be NULL. |
interface_name | the name of the interface. If NULL, the affinity is looked up by name only. |
a | pointer to the affinity or NULL if not found |
Definition at line 138 of file util-affinity.c.
References FindAffinityByInterface(), MAX_CPU_SET, name, SCLogError, and thread_affinity.
Referenced by LiveGetDeviceCountWithoutAssignedThreading().
ThreadsAffinityType* GetOrAllocAffinityTypeForIfaceOfName | ( | const char * | name, |
const char * | interface_name | ||
) |
Finds affinity by its name and interface name. Interfaces are children of cpu-set names. If the queried interface is not found, then it is allocated, initialized and assigned to the queried cpu-set.
name | the name of the affinity (e.g. worker-cpu-set, receive-cpu-set). The name is required and cannot be NULL. |
interface_name | the name of the interface. If NULL, the affinity is looked up by name only. |
a | pointer to the affinity or NULL if not found |
Definition at line 177 of file util-affinity.c.
References FindAffinityByInterface(), MAX_CPU_SET, name, SCLogError, and thread_affinity.
void ThreadingAffinityRegisterTests | ( | void | ) |
Register all threading affinity unit tests.
Definition at line 1992 of file util-affinity.c.
References UtRegisterTest().
uint16_t UtilAffinityGetAffinedCPUNum | ( | ThreadsAffinityType * | taf | ) |
Return the total number of CPUs in a given affinity.
the | number of affined CPUs |
Definition at line 1043 of file util-affinity.c.
References ThreadsAffinityType_::cpu_set, SCMutexLock, SCMutexUnlock, ThreadsAffinityType_::taf_mutex, and UtilCpuGetNumProcessorsOnline().
ThreadsAffinityType thread_affinity[MAX_CPU_SET] |
store thread affinity mode for all type of threads
Definition at line 38 of file util-affinity.c.
Referenced by GetAffinityTypeForNameAndIface(), GetOrAllocAffinityTypeForIfaceOfName(), and TmThreadGetNbThreads().
int thread_affinity_init_done = 0 |
Definition at line 66 of file util-affinity.c.
Referenced by AffinitySetupLoadFromConfig().