summaryrefslogtreecommitdiff
path: root/accel-pppd/cli/std_cmd.c
diff options
context:
space:
mode:
authorDenys Fedoryshchenko <denys.f@collabora.com>2026-04-29 15:29:20 +0300
committerDenys Fedoryshchenko <denys.f@collabora.com>2026-05-04 03:09:49 +0300
commite5fe0eaa1fc6b1109db784e818e360159d8dd2ac (patch)
tree8171a65c511849b941fbf492514cb5c89918b4e4 /accel-pppd/cli/std_cmd.c
parentd6383d69813cf2244f31d8116176733ffbbeaceb (diff)
downloadaccel-ppp-e5fe0eaa1fc6b1109db784e818e360159d8dd2ac.tar.gz
accel-ppp-e5fe0eaa1fc6b1109db784e818e360159d8dd2ac.zip
triton: encapsulate statistics counters
Group the Triton core statistics in struct triton_stat_t and keep the storage private to triton.c instead of exporting the writable triton_stat object through triton.h. This keeps ownership inside the Triton core while preserving the existing CLI and ACCEL-PPP-MIB counter semantics. Route counter updates through triton_stat_*() helpers. Thread, context, md handler, timer, mempool, CPU, and start-time update paths no longer open-code direct triton_stat mutations; the update policy now lives beside the Triton-owned storage and uses relaxed atomic operations for the simple counters. Make the CLI show-stat path render from a local snapshot and update statCore SNMP readers to use triton_stat_start_time() and triton_stat_cpu(). Out-of-tree modules that accessed the exported triton_stat object directly must switch to the new accessors, because triton_stat is no longer part of the public ABI. Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
Diffstat (limited to 'accel-pppd/cli/std_cmd.c')
-rw-r--r--accel-pppd/cli/std_cmd.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/accel-pppd/cli/std_cmd.c b/accel-pppd/cli/std_cmd.c
index 9e7bf557..951b10da 100644
--- a/accel-pppd/cli/std_cmd.c
+++ b/accel-pppd/cli/std_cmd.c
@@ -30,6 +30,9 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt,
#ifdef MEMDEBUG
struct mallinfo mi = mallinfo();
#endif
+ struct triton_stat_t stat;
+
+ triton_stat_get(&stat);
sprintf(statm_fname, "/proc/%i/statm", getpid());
f = fopen(statm_fname, "r");
@@ -39,14 +42,14 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt,
}
clock_gettime(CLOCK_MONOTONIC, &ts);
- dt = ts.tv_sec - triton_stat.start_time;
+ dt = ts.tv_sec - stat.start_time;
day = dt / (60 * 60 * 24);
dt %= 60 * 60 * 24;
hour = dt / (60 * 60);
dt %= 60 * 60;
cli_sendv(client, "uptime: %i.%02i:%02lu:%02lu\r\n", day, hour, dt / 60, dt % 60);
- cli_sendv(client, "cpu: %i%%\r\n", triton_stat.cpu);
+ cli_sendv(client, "cpu: %i%%\r\n", stat.cpu);
#ifdef MEMDEBUG
cli_send(client, "memory:\r\n");
cli_sendv(client, " rss/virt: %lu/%lu kB\r\n", vmrss * page_size_kb, vmsize * page_size_kb);
@@ -58,17 +61,17 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt,
cli_sendv(client, "mem(rss/virt): %lu/%lu kB\r\n", vmrss * page_size_kb, vmsize * page_size_kb);
#endif
cli_send(client, "core:\r\n");
- cli_sendv(client, " mempool_allocated: %" PRIu64 "\r\n", triton_stat.mempool_allocated);
- cli_sendv(client, " mempool_available: %" PRIu64 "\r\n", triton_stat.mempool_available);
- cli_sendv(client, " thread_count: %u\r\n", triton_stat.thread_count);
- cli_sendv(client, " thread_active: %u\r\n", triton_stat.thread_active);
- cli_sendv(client, " context_count: %u\r\n", triton_stat.context_count);
- cli_sendv(client, " context_sleeping: %u\r\n", triton_stat.context_sleeping);
- cli_sendv(client, " context_pending: %u\r\n", triton_stat.context_pending);
- cli_sendv(client, " md_handler_count: %u\r\n", triton_stat.md_handler_count);
- cli_sendv(client, " md_handler_pending: %u\r\n", triton_stat.md_handler_pending);
- cli_sendv(client, " timer_count: %u\r\n", triton_stat.timer_count);
- cli_sendv(client, " timer_pending: %u\r\n", triton_stat.timer_pending);
+ cli_sendv(client, " mempool_allocated: %" PRIu64 "\r\n", stat.mempool_allocated);
+ cli_sendv(client, " mempool_available: %" PRIu64 "\r\n", stat.mempool_available);
+ cli_sendv(client, " thread_count: %u\r\n", stat.thread_count);
+ cli_sendv(client, " thread_active: %u\r\n", stat.thread_active);
+ cli_sendv(client, " context_count: %u\r\n", stat.context_count);
+ cli_sendv(client, " context_sleeping: %u\r\n", stat.context_sleeping);
+ cli_sendv(client, " context_pending: %u\r\n", stat.context_pending);
+ cli_sendv(client, " md_handler_count: %u\r\n", stat.md_handler_count);
+ cli_sendv(client, " md_handler_pending: %u\r\n", stat.md_handler_pending);
+ cli_sendv(client, " timer_count: %u\r\n", stat.timer_count);
+ cli_sendv(client, " timer_pending: %u\r\n", stat.timer_pending);
//===========
{