diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2025-04-11 15:01:55 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2025-04-11 18:26:03 -0700 |
commit | d68b2deb370fc474f3b2adc8e4e1e37d385e2893 (patch) | |
tree | 9988edffe7eb665711cfff558e5cfb750ca887f1 /src/libvmon/vmon.c | |
parent | 98d6a06b8050082c2f45ebaf027c2bf324d4dc8a (diff) |
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.
Diffstat (limited to 'src/libvmon/vmon.c')
-rw-r--r-- | src/libvmon/vmon.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libvmon/vmon.c b/src/libvmon/vmon.c index 618f224..b9565dd 100644 --- a/src/libvmon/vmon.c +++ b/src/libvmon/vmon.c @@ -1445,8 +1445,14 @@ static void sample(vmon_t *vmon, vmon_proc_t *proc) proc->activity = 0; for (i = 0, cur = 1; wants; cur <<= 1, i++) { if (wants & cur) { - if (vmon->proc_funcs[i](vmon, proc, &proc->stores[i]) == SAMPLE_CHANGED) - proc->activity |= cur; + /* XXX: this is a bit awkward, but in constrained environments you might want to only follow threads while + * suppressing their sampling of the other WANT_PROC* data. To achieve that you specify VMON_FLAG_NEGLECT_THREADS + * in combination with VMON_WANT_PROC_FOLLOW_THREADS. The following line is what makes that actually work. + * This also adds another ordering dependency in proc_wants.def + */ + if (!proc->is_thread || !(vmon->flags & VMON_FLAG_NEGLECT_THREADS) || cur <= VMON_WANT_PROC_FOLLOW_THREADS) + if (vmon->proc_funcs[i](vmon, proc, &proc->stores[i]) == SAMPLE_CHANGED) + proc->activity |= cur; wants &= ~cur; } |