diff options
Diffstat (limited to 'src/libvmon')
-rw-r--r-- | src/libvmon/defs/proc_wants.def | 4 | ||||
-rw-r--r-- | src/libvmon/vmon.c | 10 | ||||
-rw-r--r-- | src/libvmon/vmon.h | 3 |
3 files changed, 15 insertions, 2 deletions
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) 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; } diff --git a/src/libvmon/vmon.h b/src/libvmon/vmon.h index cf9ea09..f1042c9 100644 --- a/src/libvmon/vmon.h +++ b/src/libvmon/vmon.h @@ -18,6 +18,9 @@ typedef enum _vmon_flags_t { VMON_FLAG_PROC_ARRAY = 1L, /* maintain a process array (useful if you need to do things like implement top(1) */ VMON_FLAG_PROC_ALL = 1L << 1, /* monitor all the processes in the system (XXX this has some follow_children implications...) */ VMON_FLAG_2PASS = 1L << 2, /* perform all sampling/wants in a first pass, then invoke all callbacks in second in vmon_sample(), important if your callbacks are layout-sensitive (vwm) */ + VMON_FLAG_NEGLECT_THREADS = 1L << 3, /* only actually sample processes, even if we're following threads + * (for situations where you still want to monitor children of threads, but don't care about per-thread monitoring) + */ } vmon_flags_t; /* store ids, used as indices into the stores array, and shift offsets for the wants mask */ |