From b0eba82135bae9a28d7a916c4f54fd43a86f7159 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 12 Apr 2025 11:23:53 -0700 Subject: libvmon: track active threads count per process This introduces vmon_proc_t.n_current_threads, a counter reflecting the currently non-stale number of threads in an is_threaded process. You could get this by walking the threads linked list and filtering out the is_stale entries, but in preparation of showing this count in the charts hierarchy I'm caching the incrementally maintained count so the list doesn't need to be walked repeatedly. Note it's important to suppress the is_stale nodes from the count, so the count isn't being decremented when stale nodes get finally removed from the list - instead when nodes transition to being stale. The count shown in charts should reflect the number of thread rows seen at the same time (when --no-threads isn't in use) --- src/libvmon/vmon.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/libvmon/vmon.h') diff --git a/src/libvmon/vmon.h b/src/libvmon/vmon.h index f1042c9..4f17d12 100644 --- a/src/libvmon/vmon.h +++ b/src/libvmon/vmon.h @@ -232,6 +232,7 @@ typedef struct _vmon_proc_t { list_head_t children; /* head of the children of this process, empty when no children */ list_head_t siblings; /* node in siblings list */ list_head_t threads; /* head or node for the threads list, empty when process has no threads */ + unsigned n_current_threads; /* count of non-stale nodes in the threads list */ struct _vmon_proc_t *parent; /* reference to the parent */ -- cgit v1.2.3