suricata
util-profiling.h File Reference
#include "util-cpu.h"
#include "detect.h"
#include "util-profiling-locks.h"
Include dependency graph for util-profiling.h:

Go to the source code of this file.

Macros

#define KEYWORD_PROFILING_SET_LIST(ctx, list)
 
#define KEYWORD_PROFILING_START
 
#define KEYWORD_PROFILING_END(ctx, type, m)
 
#define PACKET_PROFILING_START(p)
 
#define PACKET_PROFILING_RESTART(p)
 
#define PACKET_PROFILING_END(p)
 
#define PACKET_PROFILING_RESET_LOCKS
 
#define PACKET_PROFILING_COPY_LOCKS(p, id)
 
#define PACKET_PROFILING_TMM_START(p, id)
 
#define PACKET_PROFILING_TMM_END(p, id)
 
#define FLOWWORKER_PROFILING_START(p, id)
 
#define FLOWWORKER_PROFILING_END(p, id)
 
#define PACKET_PROFILING_RESET(p)
 
#define PACKET_PROFILING_APP_START(dp, id)
 
#define PACKET_PROFILING_APP_END(dp)
 
#define PACKET_PROFILING_APP_PD_START(dp)
 
#define PACKET_PROFILING_APP_PD_END(dp)
 
#define PACKET_PROFILING_APP_RESET(dp)
 
#define PACKET_PROFILING_APP_STORE(dp, p)
 
#define PACKET_PROFILING_DETECT_START(p, id)
 
#define PACKET_PROFILING_DETECT_END(p, id)
 
#define PACKET_PROFILING_LOGGER_START(p, id)
 
#define PACKET_PROFILING_LOGGER_END(p, id)
 
#define SGH_PROFILING_RECORD(det_ctx, sgh)
 
#define PREFILTER_PROFILING_START(det_ctx)
 
#define PREFILTER_PROFILING_END(ctx, profile_id)
 
#define PREFILTER_PROFILING_ADD_BYTES(det_ctx, bytes)
 
#define RULE_PROFILING_START(p)
 
#define RULE_PROFILING_END(a, b, c, p)
 

Functions

void SCProfilingPrintPacketProfile (Packet *)
 
void SCProfilingAddPacket (Packet *)
 
PktProfilingSCProfilePacketStart (void)
 
void SCProfilingKeywordsGlobalInit (void)
 
void SCProfilingKeywordDestroyCtx (DetectEngineCtx *)
 
void SCProfilingKeywordInitCounters (DetectEngineCtx *)
 Register the keyword profiling counters. More...
 
void SCProfilingKeywordUpdateCounter (DetectEngineThreadCtx *det_ctx, int id, uint64_t ticks, int match)
 Update a rule counter. More...
 
void SCProfilingKeywordThreadSetup (struct SCProfileKeywordDetectCtx_ *, DetectEngineThreadCtx *)
 
void SCProfilingKeywordThreadCleanup (DetectEngineThreadCtx *)
 
void SCProfilingPrefilterGlobalInit (void)
 
void SCProfilingPrefilterDestroyCtx (DetectEngineCtx *)
 
void SCProfilingPrefilterInitCounters (DetectEngineCtx *)
 Register the prefilter profiling counters. More...
 
void SCProfilingPrefilterUpdateCounter (DetectEngineThreadCtx *det_ctx, int id, uint64_t ticks, uint64_t bytes, uint64_t bytes_called)
 Update a rule counter. More...
 
void SCProfilingPrefilterThreadSetup (struct SCProfilePrefilterDetectCtx_ *, DetectEngineThreadCtx *)
 
void SCProfilingPrefilterThreadCleanup (DetectEngineThreadCtx *)
 
void SCProfilingSghsGlobalInit (void)
 
void SCProfilingSghDestroyCtx (DetectEngineCtx *)
 
void SCProfilingSghInitCounters (DetectEngineCtx *)
 Register the keyword profiling counters. More...
 
void SCProfilingSghUpdateCounter (DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh)
 Update a rule counter. More...
 
void SCProfilingSghThreadSetup (struct SCProfileSghDetectCtx_ *, DetectEngineThreadCtx *)
 
void SCProfilingSghThreadCleanup (DetectEngineThreadCtx *)
 
void SCProfilingInit (void)
 Initialize profiling. More...
 
void SCProfilingDestroy (void)
 Free resources used by profiling. More...
 
void SCProfilingRegisterTests (void)
 
void SCProfilingDump (void)
 

Variables

int profiling_rules_enabled
 
int profiling_packets_enabled
 
int profiling_sghs_enabled
 
int profiling_keyword_enabled
 
thread_local int profiling_keyword_entered
 
int profiling_prefilter_enabled
 
thread_local int profiling_prefilter_entered
 

Detailed Description

Author
Endace Technology Limited.
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t

Definition in file util-profiling.h.

Macro Definition Documentation

◆ FLOWWORKER_PROFILING_END

#define FLOWWORKER_PROFILING_END (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < PROFILE_FLOWWORKER_SIZE) { \
(p)->profile->flowworker[(id)].ticks_end = UtilCpuGetTicks(); \
} \
}

Definition at line 155 of file util-profiling.h.

◆ FLOWWORKER_PROFILING_START

#define FLOWWORKER_PROFILING_START (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < PROFILE_FLOWWORKER_SIZE) { \
(p)->profile->flowworker[(id)].ticks_start = UtilCpuGetTicks();\
} \
}

Definition at line 148 of file util-profiling.h.

◆ KEYWORD_PROFILING_END

#define KEYWORD_PROFILING_END (   ctx,
  type,
  m 
)
Value:
profile_keyword_end_ = UtilCpuGetTicks(); \
SCProfilingKeywordUpdateCounter((ctx),(type),(profile_keyword_end_ - profile_keyword_start_),(m)); \
profiling_keyword_entered--; \
}

Definition at line 65 of file util-profiling.h.

◆ KEYWORD_PROFILING_SET_LIST

#define KEYWORD_PROFILING_SET_LIST (   ctx,
  list 
)
Value:
{ \
(ctx)->keyword_perf_list = (list); \
}

Definition at line 47 of file util-profiling.h.

◆ KEYWORD_PROFILING_START

#define KEYWORD_PROFILING_START
Value:
uint64_t profile_keyword_start_ = 0; \
uint64_t profile_keyword_end_ = 0; \
SCLogError("Re-entered profiling, exiting."); \
abort(); \
} \
profiling_keyword_entered++; \
profile_keyword_start_ = UtilCpuGetTicks(); \
}

Definition at line 51 of file util-profiling.h.

◆ PACKET_PROFILING_APP_END

#define PACKET_PROFILING_APP_END (   dp)
Value:
(dp)->ticks_end = UtilCpuGetTicks(); \
if ((dp)->ticks_start != 0 && (dp)->ticks_start < ((dp)->ticks_end)) { \
(dp)->ticks_spent = ((dp)->ticks_end - (dp)->ticks_start); \
} \
}

Definition at line 174 of file util-profiling.h.

◆ PACKET_PROFILING_APP_PD_END

#define PACKET_PROFILING_APP_PD_END (   dp)
Value:
(dp)->proto_detect_ticks_end = UtilCpuGetTicks(); \
if ((dp)->proto_detect_ticks_start != 0 && (dp)->proto_detect_ticks_start < ((dp)->proto_detect_ticks_end)) { \
(dp)->proto_detect_ticks_spent = \
((dp)->proto_detect_ticks_end - (dp)->proto_detect_ticks_start); \
} \
}

Definition at line 187 of file util-profiling.h.

◆ PACKET_PROFILING_APP_PD_START

#define PACKET_PROFILING_APP_PD_START (   dp)
Value:
(dp)->proto_detect_ticks_start = UtilCpuGetTicks(); \
}

Definition at line 182 of file util-profiling.h.

◆ PACKET_PROFILING_APP_RESET

#define PACKET_PROFILING_APP_RESET (   dp)
Value:
(dp)->ticks_start = 0; \
(dp)->ticks_end = 0; \
(dp)->ticks_spent = 0; \
(dp)->alproto = 0; \
(dp)->proto_detect_ticks_start = 0; \
(dp)->proto_detect_ticks_end = 0; \
(dp)->proto_detect_ticks_spent = 0; \
}

Definition at line 196 of file util-profiling.h.

◆ PACKET_PROFILING_APP_START

#define PACKET_PROFILING_APP_START (   dp,
  id 
)
Value:
(dp)->ticks_start = UtilCpuGetTicks(); \
(dp)->alproto = (id); \
}

Definition at line 168 of file util-profiling.h.

◆ PACKET_PROFILING_APP_STORE

#define PACKET_PROFILING_APP_STORE (   dp,
 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((dp)->alproto < ALPROTO_MAX) { \
(p)->profile->app[(dp)->alproto].ticks_spent += (dp)->ticks_spent; \
(p)->profile->proto_detect += (dp)->proto_detect_ticks_spent; \
} \
}

Definition at line 207 of file util-profiling.h.

◆ PACKET_PROFILING_COPY_LOCKS

#define PACKET_PROFILING_COPY_LOCKS (   p,
  id 
)

Definition at line 129 of file util-profiling.h.

◆ PACKET_PROFILING_DETECT_END

#define PACKET_PROFILING_DETECT_END (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < PROF_DETECT_SIZE) { \
(p)->profile->detect[(id)].ticks_end = UtilCpuGetTicks();\
if ((p)->profile->detect[(id)].ticks_start != 0 && \
(p)->profile->detect[(id)].ticks_start < (p)->profile->detect[(id)].ticks_end) { \
(p)->profile->detect[(id)].ticks_spent += \
((p)->profile->detect[(id)].ticks_end - (p)->profile->detect[(id)].ticks_start); \
} \
} \
}

Definition at line 222 of file util-profiling.h.

◆ PACKET_PROFILING_DETECT_START

#define PACKET_PROFILING_DETECT_START (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < PROF_DETECT_SIZE) { \
(p)->profile->detect[(id)].ticks_start = UtilCpuGetTicks(); \
} \
}

Definition at line 215 of file util-profiling.h.

◆ PACKET_PROFILING_END

#define PACKET_PROFILING_END (   p)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
(p)->profile->ticks_end = UtilCpuGetTicks(); \
SCProfilingAddPacket((p)); \
}

Definition at line 87 of file util-profiling.h.

◆ PACKET_PROFILING_LOGGER_END

#define PACKET_PROFILING_LOGGER_END (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < LOGGER_SIZE) { \
(p)->profile->logger[(id)].ticks_end = UtilCpuGetTicks();\
if ((p)->profile->logger[(id)].ticks_start != 0 && \
(p)->profile->logger[(id)].ticks_start < (p)->profile->logger[(id)].ticks_end) { \
(p)->profile->logger[(id)].ticks_spent += \
((p)->profile->logger[(id)].ticks_end - (p)->profile->logger[(id)].ticks_start); \
} \
} \
}

Definition at line 241 of file util-profiling.h.

◆ PACKET_PROFILING_LOGGER_START

#define PACKET_PROFILING_LOGGER_START (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < LOGGER_SIZE) { \
(p)->profile->logger[(id)].ticks_start = UtilCpuGetTicks(); \
} \
}

Definition at line 234 of file util-profiling.h.

◆ PACKET_PROFILING_RESET

#define PACKET_PROFILING_RESET (   p)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
SCFree((p)->profile); \
(p)->profile = NULL; \
}

Definition at line 162 of file util-profiling.h.

◆ PACKET_PROFILING_RESET_LOCKS

#define PACKET_PROFILING_RESET_LOCKS

Definition at line 128 of file util-profiling.h.

◆ PACKET_PROFILING_RESTART

#define PACKET_PROFILING_RESTART (   p)
Value:
if ((p)->profile != NULL) \
(p)->profile->ticks_start = UtilCpuGetTicks(); \
}

Definition at line 81 of file util-profiling.h.

◆ PACKET_PROFILING_START

#define PACKET_PROFILING_START (   p)
Value:
(p)->profile = SCProfilePacketStart(); \
if ((p)->profile != NULL) \
(p)->profile->ticks_start = UtilCpuGetTicks(); \
}

Definition at line 74 of file util-profiling.h.

◆ PACKET_PROFILING_TMM_END

#define PACKET_PROFILING_TMM_END (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < TMM_SIZE) { \
PACKET_PROFILING_COPY_LOCKS((p), (id)); \
(p)->profile->tmm[(id)].ticks_end = UtilCpuGetTicks(); \
} \
}

Definition at line 140 of file util-profiling.h.

◆ PACKET_PROFILING_TMM_START

#define PACKET_PROFILING_TMM_START (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < TMM_SIZE) { \
(p)->profile->tmm[(id)].ticks_start = UtilCpuGetTicks();\
PACKET_PROFILING_RESET_LOCKS; \
} \
}

Definition at line 132 of file util-profiling.h.

◆ PREFILTER_PROFILING_ADD_BYTES

#define PREFILTER_PROFILING_ADD_BYTES (   det_ctx,
  bytes 
)
Value:
(det_ctx)->prefilter_bytes += (bytes); \
(det_ctx)->prefilter_bytes_called++

Definition at line 287 of file util-profiling.h.

◆ PREFILTER_PROFILING_END

#define PREFILTER_PROFILING_END (   ctx,
  profile_id 
)
Value:
profile_prefilter_end_ = UtilCpuGetTicks(); \
if (profile_prefilter_end_ > profile_prefilter_start_) \
SCProfilingPrefilterUpdateCounter((ctx), (profile_id), \
(profile_prefilter_end_ - profile_prefilter_start_), (ctx)->prefilter_bytes, \
(ctx)->prefilter_bytes_called); \
profiling_prefilter_entered--; \
}

Definition at line 277 of file util-profiling.h.

◆ PREFILTER_PROFILING_START

#define PREFILTER_PROFILING_START (   det_ctx)
Value:
(det_ctx)->prefilter_bytes = 0; \
(det_ctx)->prefilter_bytes_called = 0; \
uint64_t profile_prefilter_start_ = 0; \
uint64_t profile_prefilter_end_ = 0; \
SCLogError("Re-entered profiling, exiting."); \
abort(); \
} \
profiling_prefilter_entered++; \
profile_prefilter_start_ = UtilCpuGetTicks(); \
}

Definition at line 261 of file util-profiling.h.

◆ RULE_PROFILING_END

#define RULE_PROFILING_END (   a,
  b,
  c,
 
)

Definition at line 423 of file util-profiling.h.

◆ RULE_PROFILING_START

#define RULE_PROFILING_START (   p)

Definition at line 422 of file util-profiling.h.

◆ SGH_PROFILING_RECORD

#define SGH_PROFILING_RECORD (   det_ctx,
  sgh 
)
Value:
SCProfilingSghUpdateCounter((det_ctx), (sgh)); \
}

Definition at line 253 of file util-profiling.h.

Function Documentation

◆ SCProfilePacketStart()

PktProfiling* SCProfilePacketStart ( void  )

Definition at line 1183 of file util-profiling.c.

References SC_ATOMIC_ADD.

◆ SCProfilingAddPacket()

void SCProfilingAddPacket ( Packet )

◆ SCProfilingDestroy()

void SCProfilingDestroy ( void  )

Free resources used by profiling.

Definition at line 270 of file util-profiling.c.

References profiling_packets_enabled.

◆ SCProfilingDump()

void SCProfilingDump ( void  )

Definition at line 296 of file util-profiling.c.

References SCLogPerf, and SCProfilingDumpPacketStats().

Here is the call graph for this function:

◆ SCProfilingInit()

void SCProfilingInit ( void  )

Initialize profiling.

Definition at line 133 of file util-profiling.c.

References ConfGetInt(), and SC_ATOMIC_INIT.

Referenced by PreRunInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCProfilingKeywordDestroyCtx()

void SCProfilingKeywordDestroyCtx ( DetectEngineCtx )

Definition at line 268 of file util-profiling-keywords.c.

References de_ctx.

Referenced by DetectEngineCtxFree().

Here is the caller graph for this function:

◆ SCProfilingKeywordInitCounters()

void SCProfilingKeywordInitCounters ( DetectEngineCtx de_ctx)

Register the keyword profiling counters.

Parameters
de_ctxThe active DetectEngineCtx, used to get at the loaded rules.

Definition at line 365 of file util-profiling-keywords.c.

References DetectEngineCtx_::buffer_type_id, de_ctx, DetectEngineCtx_::profile_keyword_ctx, and profiling_keyword_enabled.

◆ SCProfilingKeywordsGlobalInit()

void SCProfilingKeywordsGlobalInit ( void  )

Definition at line 61 of file util-profiling-keywords.c.

References ConfGetNode(), ConfNodeChildValueIsTrue(), ConfNodeLookupChildValue(), PathIsAbsolute(), profiling_keyword_enabled, and strlcpy().

Referenced by PreRunInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCProfilingKeywordThreadCleanup()

◆ SCProfilingKeywordThreadSetup()

◆ SCProfilingKeywordUpdateCounter()

void SCProfilingKeywordUpdateCounter ( DetectEngineThreadCtx det_ctx,
int  id,
uint64_t  ticks,
int  match 
)

◆ SCProfilingPrefilterDestroyCtx()

void SCProfilingPrefilterDestroyCtx ( DetectEngineCtx )

Definition at line 236 of file util-profiling-prefilter.c.

References de_ctx.

Referenced by DetectEngineCtxFree().

Here is the caller graph for this function:

◆ SCProfilingPrefilterGlobalInit()

void SCProfilingPrefilterGlobalInit ( void  )

Definition at line 61 of file util-profiling-prefilter.c.

References ConfGetNode(), ConfNodeChildValueIsTrue(), ConfNodeLookupChildValue(), PathIsAbsolute(), profiling_prefilter_enabled, and strlcpy().

Referenced by PreRunInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCProfilingPrefilterInitCounters()

void SCProfilingPrefilterInitCounters ( DetectEngineCtx de_ctx)

Register the prefilter profiling counters.

Parameters
de_ctxThe active DetectEngineCtx, used to get at the loaded rules.

Definition at line 300 of file util-profiling-prefilter.c.

References de_ctx, DetectEngineCtx_::prefilter_id, DetectEngineCtx_::profile_prefilter_ctx, and profiling_prefilter_enabled.

◆ SCProfilingPrefilterThreadCleanup()

◆ SCProfilingPrefilterThreadSetup()

◆ SCProfilingPrefilterUpdateCounter()

void SCProfilingPrefilterUpdateCounter ( DetectEngineThreadCtx det_ctx,
int  id,
uint64_t  ticks,
uint64_t  bytes,
uint64_t  bytes_called 
)

◆ SCProfilingPrintPacketProfile()

void SCProfilingPrintPacketProfile ( Packet )

Definition at line 765 of file util-profiling.c.

◆ SCProfilingRegisterTests()

void SCProfilingRegisterTests ( void  )

Definition at line 1393 of file util-profiling.c.

References UtRegisterTest().

Here is the call graph for this function:

◆ SCProfilingSghDestroyCtx()

void SCProfilingSghDestroyCtx ( DetectEngineCtx )

Definition at line 304 of file util-profiling-rulegroups.c.

References de_ctx.

Referenced by DetectEngineCtxFree().

Here is the caller graph for this function:

◆ SCProfilingSghInitCounters()

void SCProfilingSghInitCounters ( DetectEngineCtx de_ctx)

Register the keyword profiling counters.

Parameters
de_ctxThe active DetectEngineCtx, used to get at the loaded rules.

Definition at line 369 of file util-profiling-rulegroups.c.

References de_ctx, DetectEngineCtx_::profile_sgh_ctx, and profiling_sghs_enabled.

◆ SCProfilingSghsGlobalInit()

void SCProfilingSghsGlobalInit ( void  )

Definition at line 64 of file util-profiling-rulegroups.c.

References ConfGetNode(), ConfNodeChildValueIsTrue(), ConfNodeLookupChildValue(), PathIsAbsolute(), profiling_sghs_enabled, and strlcpy().

Referenced by PreRunInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCProfilingSghThreadCleanup()

◆ SCProfilingSghThreadSetup()

◆ SCProfilingSghUpdateCounter()

Variable Documentation

◆ profiling_keyword_enabled

int profiling_keyword_enabled

◆ profiling_keyword_entered

thread_local int profiling_keyword_entered

Definition at line 57 of file util-profiling-keywords.c.

◆ profiling_packets_enabled

int profiling_packets_enabled

Definition at line 94 of file util-profiling.c.

Referenced by SCProfilingDestroy(), and SCProfilingDumpPacketStats().

◆ profiling_prefilter_enabled

int profiling_prefilter_enabled

◆ profiling_prefilter_entered

thread_local int profiling_prefilter_entered

Definition at line 57 of file util-profiling-prefilter.c.

◆ profiling_rules_enabled

int profiling_rules_enabled

◆ profiling_sghs_enabled

int profiling_sghs_enabled
profiling_prefilter_entered
thread_local int profiling_prefilter_entered
Definition: util-profiling-prefilter.c:57
ctx
struct Thresholds ctx
PROF_DETECT_SIZE
@ PROF_DETECT_SIZE
Definition: suricata-common.h:456
SCProfilePacketStart
PktProfiling * SCProfilePacketStart(void)
Definition: util-profiling.c:1183
m
SCMutex m
Definition: flow-hash.h:6
ALPROTO_MAX
@ ALPROTO_MAX
Definition: app-layer-protos.h:76
PktProfiling_::ticks_start
uint64_t ticks_start
Definition: decode.h:346
profiling_packets_enabled
int profiling_packets_enabled
Definition: util-profiling.c:94
UtilCpuGetTicks
uint64_t UtilCpuGetTicks(void)
Definition: util-cpu.c:161
profiling_keyword_entered
thread_local int profiling_keyword_entered
Definition: util-profiling-keywords.c:57
LOGGER_SIZE
@ LOGGER_SIZE
Definition: suricata-common.h:501
profiling_keyword_enabled
int profiling_keyword_enabled
Definition: util-profiling-keywords.c:56
type
uint16_t type
Definition: decode-vlan.c:107
TMM_SIZE
@ TMM_SIZE
Definition: tm-threads-common.h:75
profiling_sghs_enabled
int profiling_sghs_enabled
Definition: util-profiling-rulegroups.c:59
PROFILE_FLOWWORKER_SIZE
@ PROFILE_FLOWWORKER_SIZE
Definition: flow-worker.h:29
profiling_prefilter_enabled
int profiling_prefilter_enabled
Definition: util-profiling-prefilter.c:56