Merge in SNORT/snort3 from ~MMATIRKO/snort3:mem_counts_master to master
Squashed commit of the following:
commit
9a5d8dabaf88dadbe29cd01b54602b5631b1a9bd
Author: Russ Combs <rucombs@cisco.com>
Date: Wed Mar 15 14:22:22 2023 -0400
memory: add extra jemalloc counts for tracking
commit
1c078c5fa8c4fd0a99469677269d92f7b7837891
Author: Russ Combs <rucombs@cisco.com>
Date: Tue Mar 14 22:24:37 2023 -0400
memory: use jemalloc stats.mapped for process total
void print_stats(ControlConn*) override;
+ void get_aux_counts(uint64_t&, uint64_t&, uint64_t&, uint64_t&) override;
};
static size_t stats_mib[2], mib_len = 2;
void JemallocInterface::main_init()
{
- mallctlnametomib("stats.allocated", stats_mib, &mib_len);
+ mallctlnametomib("stats.mapped", stats_mib, &mib_len);
}
void JemallocInterface::thread_init()
malloc_stats_print(log_jem_stats, nullptr, nullptr);
}
+void JemallocInterface::get_aux_counts(uint64_t& all, uint64_t& act, uint64_t& res, uint64_t& ret)
+{
+ size_t sz = sizeof(all);
+
+ mallctl("stats.allocated", (void*)&all, &sz, nullptr, 0);
+ mallctl("stats.active", (void*)&act, &sz, nullptr, 0);
+ mallctl("stats.resident", (void*)&res, &sz, nullptr, 0);
+ mallctl("stats.retained", (void*)&ret, &sz, nullptr, 0);
+}
+
//--------------------------------------------------------------------------
#else // disabled interface
//--------------------------------------------------------------------------
virtual void get_thread_allocs(uint64_t& alloc, uint64_t& dealloc) = 0;
virtual void print_stats(ControlConn*) { }
+ virtual void get_aux_counts(uint64_t& app_all, uint64_t& active, uint64_t& resident, uint64_t& retained)
+ { app_all = active = resident = retained = 0; }
+
static HeapInterface* get_instance();
protected:
mc.cur_in_use = total;
mc.epochs++;
+
+ // for reporting / tracking only
+ uint64_t all, act, res, ret;
+ heap->get_aux_counts(all, act, res, ret);
+
+ mc.app_all = all;
+ mc.active = act;
+ mc.resident = res;
+ mc.retained = ret;
}
// -----------------------------------------------------------------------------
PegCount reap_aborts;
PegCount reap_decrease;
PegCount reap_increase;
+ // reporting only
+ PegCount app_all;
+ PegCount active;
+ PegCount resident;
+ PegCount retained;
};
typedef bool (*PruneHandler)();
{ CountType::NOW, "reap_aborts", "abort pruning before target due to process under limit" },
{ CountType::NOW, "reap_decrease", "total amount of the decrease in thread memory while process over limit" },
{ CountType::NOW, "reap_increase", "total amount of the increase in thread memory while process over limit" },
+ { CountType::NOW, "app_all", "total bytes allocated by application" },
+ { CountType::NOW, "active", "total bytes allocated in active pages" },
+ { CountType::NOW, "resident", "maximum bytes physically resident" },
+ { CountType::NOW, "retained", "total bytes not returned to OS" },
+
{ CountType::END, nullptr, nullptr }
};