counters: remove ThreadVars from Avg counter API

pull/14398/head
Victor Julien 11 months ago
parent 379b8ac5a6
commit adebfcd4a5

@ -237,9 +237,9 @@ void StatsCounterMaxUpdateI64(StatsThreadContext *stats, StatsCounterMaxId id, i
}
}
void StatsCounterAvgAddI64(ThreadVars *tv, StatsCounterAvgId id, int64_t x)
void StatsCounterAvgAddI64(StatsThreadContext *stats, StatsCounterAvgId id, int64_t x)
{
StatsPrivateThreadContext *pca = &tv->stats.priv;
StatsPrivateThreadContext *pca = &stats->priv;
#if defined(UNITTESTS) || defined(FUZZ)
if (pca->initialized == 0)
return;

@ -145,7 +145,7 @@ void StatsIncr(struct ThreadVars_ *, StatsCounterId);
void StatsDecr(struct ThreadVars_ *, StatsCounterId);
void StatsCounterMaxUpdateI64(StatsThreadContext *, StatsCounterMaxId id, int64_t x);
void StatsCounterAvgAddI64(struct ThreadVars_ *tv, StatsCounterAvgId id, int64_t x);
void StatsCounterAvgAddI64(StatsThreadContext *, StatsCounterAvgId id, int64_t x);
/* utility functions */
uint64_t StatsGetLocalCounterValue(struct ThreadVars_ *, StatsCounterId);

@ -778,7 +778,7 @@ void DecodeUpdatePacketCounters(ThreadVars *tv,
StatsIncr(tv, dtv->counter_pkts);
//StatsIncr(tv, dtv->counter_pkts_per_sec);
StatsAddUI64(tv, dtv->counter_bytes, GET_PKT_LEN(p));
StatsCounterAvgAddI64(tv, dtv->counter_avg_pkt_size, GET_PKT_LEN(p));
StatsCounterAvgAddI64(&tv->stats, dtv->counter_avg_pkt_size, GET_PKT_LEN(p));
StatsCounterMaxUpdateI64(&tv->stats, dtv->counter_max_pkt_size, GET_PKT_LEN(p));
}

@ -601,7 +601,7 @@ static inline void DetectRunPrefilterPkt(ThreadVars *tv, const DetectEngineCtx *
#ifdef PROFILING
if (tv) {
StatsCounterAvgAddI64(
tv, det_ctx->counter_mpm_list, (int64_t)det_ctx->pmq.rule_id_array_cnt);
&tv->stats, det_ctx->counter_mpm_list, (int64_t)det_ctx->pmq.rule_id_array_cnt);
}
#endif
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_PF_SORT2);
@ -665,7 +665,7 @@ static inline uint8_t DetectRulePacketRules(ThreadVars *const tv,
SigIntId match_cnt = det_ctx->match_array_cnt;
#ifdef PROFILING
if (tv) {
StatsCounterAvgAddI64(tv, det_ctx->counter_match_list, (int64_t)match_cnt);
StatsCounterAvgAddI64(&tv->stats, det_ctx->counter_match_list, (int64_t)match_cnt);
}
#endif
Signature **match_array = det_ctx->match_array;

@ -639,8 +639,8 @@ static inline Flow *FlowSpareSync(ThreadVars *tv, FlowLookupStruct *fls,
#endif
if (spare_sync) {
if (f != NULL) {
StatsCounterAvgAddI64(
tv, fls->dtv->counter_flow_spare_sync_avg, fls->spare_queue.len + 1);
StatsCounterAvgAddI64(&tv->stats, fls->dtv->counter_flow_spare_sync_avg,
fls->spare_queue.len + 1);
if (fls->spare_queue.len < 99) {
/* When a new flow pool is fetched it has 100 flows in sync,
* so there should be 99 left if we're in full sync.

@ -1113,7 +1113,7 @@ static TmEcode FlowRecycler(ThreadVars *th_v, void *thread_data)
SC_ATOMIC_ADD(flowrec_busy,1);
FlowQueuePrivate list = FlowQueueExtractPrivate(&flow_recycle_q);
StatsCounterAvgAddI64(th_v, ftd->counter_queue_avg, (int64_t)list.len);
StatsCounterAvgAddI64(&th_v->stats, ftd->counter_queue_avg, (int64_t)list.len);
StatsCounterMaxUpdateI64(&th_v->stats, ftd->counter_queue_max, (int64_t)list.len);
const int bail = (TmThreadsCheckFlag(th_v, THV_KILL));

@ -851,7 +851,7 @@ static inline int AFPReadFromRingWaitForPacket(AFPThreadVars *ptv)
break;
}
if (busy_loop_iter) {
StatsCounterAvgAddI64(ptv->tv, ptv->afpacket_spin, busy_loop_iter);
StatsCounterAvgAddI64(&ptv->tv->stats, ptv->afpacket_spin, busy_loop_iter);
}
return AFP_READ_OK;
}

Loading…
Cancel
Save