From 379b8ac5a62033c063f1b59b9df86c159f4569fb Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 27 Nov 2025 11:10:37 +0100 Subject: [PATCH] counters: remove ThreadVars from Max counter API --- src/counters.c | 6 +++--- src/counters.h | 2 +- src/decode.c | 2 +- src/flow-manager.c | 9 +++++---- src/flow-worker.c | 2 +- src/util-macset.c | 6 +++--- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/counters.c b/src/counters.c index 377bf41a7c..7c64df767b 100644 --- a/src/counters.c +++ b/src/counters.c @@ -217,13 +217,13 @@ void StatsSetUI64(ThreadVars *tv, StatsCounterId id, uint64_t x) /** * \brief update the value of the localmax counter * - * \param tv ThreadVars holding the private counter structure + * \param stats per thread counter structure * \param id Index of the local counter in the counter array * \param x The value to set for the counter */ -void StatsCounterMaxUpdateI64(ThreadVars *tv, StatsCounterMaxId id, int64_t x) +void StatsCounterMaxUpdateI64(StatsThreadContext *stats, StatsCounterMaxId 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 a68960d910..3cbc87a42a 100644 --- a/src/counters.h +++ b/src/counters.h @@ -144,7 +144,7 @@ void StatsSetUI64(struct ThreadVars_ *, StatsCounterId, uint64_t); void StatsIncr(struct ThreadVars_ *, StatsCounterId); void StatsDecr(struct ThreadVars_ *, StatsCounterId); -void StatsCounterMaxUpdateI64(struct ThreadVars_ *tv, StatsCounterMaxId id, int64_t x); +void StatsCounterMaxUpdateI64(StatsThreadContext *, StatsCounterMaxId id, int64_t x); void StatsCounterAvgAddI64(struct ThreadVars_ *tv, StatsCounterAvgId id, int64_t x); /* utility functions */ diff --git a/src/decode.c b/src/decode.c index a8db5d22db..b9c1b62c83 100644 --- a/src/decode.c +++ b/src/decode.c @@ -779,7 +779,7 @@ void DecodeUpdatePacketCounters(ThreadVars *tv, //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)); - StatsCounterMaxUpdateI64(tv, dtv->counter_max_pkt_size, GET_PKT_LEN(p)); + StatsCounterMaxUpdateI64(&tv->stats, dtv->counter_max_pkt_size, GET_PKT_LEN(p)); } /** diff --git a/src/flow-manager.c b/src/flow-manager.c index 26f04da23c..d1b8aedbe9 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -716,7 +716,8 @@ static void FlowCountersUpdate( StatsAddUI64(th_v, ftd->cnt.flow_bypassed_pkts, (uint64_t)counters->bypassed_pkts); StatsAddUI64(th_v, ftd->cnt.flow_bypassed_bytes, (uint64_t)counters->bypassed_bytes); - StatsCounterMaxUpdateI64(th_v, ftd->cnt.flow_mgr_rows_maxlen, (int64_t)counters->rows_maxlen); + StatsCounterMaxUpdateI64( + &th_v->stats, ftd->cnt.flow_mgr_rows_maxlen, (int64_t)counters->rows_maxlen); } static TmEcode FlowManagerThreadInit(ThreadVars *t, const void *initdata, void **data) @@ -832,7 +833,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data) uint32_t mp = MemcapsGetPressure() * 100; if (ftd->instance == 0) { StatsSetUI64(th_v, ftd->cnt.memcap_pressure, mp); - StatsCounterMaxUpdateI64(th_v, ftd->cnt.memcap_pressure_max, (int64_t)mp); + StatsCounterMaxUpdateI64(&th_v->stats, ftd->cnt.memcap_pressure_max, (int64_t)mp); } GetWorkUnitSizing(rows, mp, false, &sleep_per_wu, &rows_per_wu, &rows_sec); StatsSetUI64(th_v, ftd->cnt.flow_mgr_rows_sec, rows_sec); @@ -936,7 +937,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data) mp = MemcapsGetPressure() * 100; if (ftd->instance == 0) { StatsSetUI64(th_v, ftd->cnt.memcap_pressure, mp); - StatsCounterMaxUpdateI64(th_v, ftd->cnt.memcap_pressure_max, (int64_t)mp); + StatsCounterMaxUpdateI64(&th_v->stats, ftd->cnt.memcap_pressure_max, (int64_t)mp); } GetWorkUnitSizing(rows, mp, emerg, &sleep_per_wu, &rows_per_wu, &rows_sec); if (pmp != mp) { @@ -1113,7 +1114,7 @@ static TmEcode FlowRecycler(ThreadVars *th_v, void *thread_data) FlowQueuePrivate list = FlowQueueExtractPrivate(&flow_recycle_q); StatsCounterAvgAddI64(th_v, ftd->counter_queue_avg, (int64_t)list.len); - StatsCounterMaxUpdateI64(th_v, ftd->counter_queue_max, (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/flow-worker.c b/src/flow-worker.c index 23c6165c7a..6fd02e436e 100644 --- a/src/flow-worker.c +++ b/src/flow-worker.c @@ -485,7 +485,7 @@ static inline void FlowWorkerProcessInjectedFlows( if (injected.len > 0) { StatsAddUI64(tv, fw->cnt.flows_injected, (uint64_t)injected.len); if (p->pkt_src == PKT_SRC_WIRE) - StatsCounterMaxUpdateI64(tv, fw->cnt.flows_injected_max, (int64_t)injected.len); + StatsCounterMaxUpdateI64(&tv->stats, fw->cnt.flows_injected_max, (int64_t)injected.len); /* move to local queue so we can process over the course of multiple packets */ FlowQueuePrivateAppendPrivate(&fw->fls.work_queue, &injected); diff --git a/src/util-macset.c b/src/util-macset.c index 61736744b8..03e5d806d6 100644 --- a/src/util-macset.c +++ b/src/util-macset.c @@ -125,7 +125,7 @@ static inline void MacUpdateEntry( memcpy(ms->singles[side], addr, sizeof(MacAddr)); ms->state[side] = SINGLE_MAC; if (tv != NULL) - StatsCounterMaxUpdateI64(tv, ctr, 1); + StatsCounterMaxUpdateI64(&tv->stats, ctr, 1); break; case SINGLE_MAC: if (unlikely(memcmp(addr, ms->singles[side], sizeof(MacAddr)) != 0)) { @@ -146,7 +146,7 @@ static inline void MacUpdateEntry( memcpy(ms->buf[side] + 1, addr, sizeof(MacAddr)); ms->last[side] = 2; if (tv != NULL) - StatsCounterMaxUpdateI64(tv, ctr, 2); + StatsCounterMaxUpdateI64(&tv->stats, ctr, 2); ms->state[side] = MULTI_MAC; } break; @@ -174,7 +174,7 @@ static inline void MacUpdateEntry( memcpy(ms->buf[side] + ms->last[side], addr, sizeof(MacAddr)); ms->last[side]++; if (tv != NULL) - StatsCounterMaxUpdateI64(tv, ctr, (int64_t)ms->last[side]); + StatsCounterMaxUpdateI64(&tv->stats, ctr, (int64_t)ms->last[side]); break; } }