From adebfcd4a5faa90b17f2fd3d8c7450257b64a0c0 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 27 Nov 2025 11:16:10 +0100 Subject: [PATCH] counters: remove ThreadVars from Avg counter API --- src/counters.c | 4 ++-- src/counters.h | 2 +- src/decode.c | 2 +- src/detect.c | 4 ++-- src/flow-hash.c | 4 ++-- src/flow-manager.c | 2 +- src/source-af-packet.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/counters.c b/src/counters.c index 7c64df767b..2ca8619f17 100644 --- a/src/counters.c +++ b/src/counters.c @@ -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; diff --git a/src/counters.h b/src/counters.h index 3cbc87a42a..969a631223 100644 --- a/src/counters.h +++ b/src/counters.h @@ -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); diff --git a/src/decode.c b/src/decode.c index b9c1b62c83..78b325fe4c 100644 --- a/src/decode.c +++ b/src/decode.c @@ -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)); } diff --git a/src/detect.c b/src/detect.c index 3ca07b1b13..b9f9bc3296 100644 --- a/src/detect.c +++ b/src/detect.c @@ -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; diff --git a/src/flow-hash.c b/src/flow-hash.c index 76595d47f5..e78de4a953 100644 --- a/src/flow-hash.c +++ b/src/flow-hash.c @@ -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. diff --git a/src/flow-manager.c b/src/flow-manager.c index d1b8aedbe9..78596e4826 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -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)); diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 25366034f3..23f7229d4f 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -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; }