From d68b2deb370fc474f3b2adc8e4e1e37d385e2893 Mon Sep 17 00:00:00 2001
From: Vito Caputo <vcaputo@pengaru.com>
Date: Fri, 11 Apr 2025 15:01:55 -0700
Subject: libvmon: introduce VMON_FLAG_NEGLECT_THREADS flag

--hide-threads needs a way to tell libvmon to both follow threads
and neglect to actually sample them.

Note this will still allocate the vmon_proc_t for every thread,
but conserves in the open proc files department by not
opening/reading everything other than the children proc file for
threads - regardless of what other proc wants have been specified.

So front-ends still need to traverse threads of processes, and if
they want to collapse the children of threads as if they're all
children of the threads' parent, that's up to the front-end to do
so.  In the vwm/vmon case, that's a detail for charts.c to
handle, when --hide-threads is in effect.  It will have to render
the children of threads as if they're children of the threads'
parent, to hide this clusterfuck from what's visible to the user.
---
 src/libvmon/defs/proc_wants.def | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'src/libvmon/defs/proc_wants.def')

diff --git a/src/libvmon/defs/proc_wants.def b/src/libvmon/defs/proc_wants.def
index f08f08c..a3c3cd7 100644
--- a/src/libvmon/defs/proc_wants.def
+++ b/src/libvmon/defs/proc_wants.def
@@ -2,6 +2,10 @@
 
 /* the available per-process wants, the order here matters, put wants which affect the sampling hierarchy first */
 /* otherwise they will change the hierarchy after samples have been collected, leaving newly introduced nodes with uninitialized sample stores after return from vmon_sample() */
+/* also PROC_FOLLOW_THREADS must be the last thing before the sampling wants, because those get skipped
+ * if VMON_FLAG_NEGLECT_THREADS is set even when following threaads, and that's done by skipping wants
+ * greater than VMON_FLAG_NEGLECT_THREADS for threads at sample time.
+ */
 
 /*	  sym,				name,				internal fulfilllment function */
 vmon_want(PROC_FOLLOW_CHILDREN,		proc_follow_children,		proc_follow_children)
-- 
cgit v1.2.3

