diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2024-11-30 14:16:21 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2024-11-30 14:16:21 -0800 |
commit | 0e04a75e828f8a336d361303e68775d2603945e4 (patch) | |
tree | c93b752768014d27d21325d724fe7908d485e17c | |
parent | 73367b12eda9bed587882ad8ec9cc6875a4c2bbc (diff) |
libvmon: assume stale threads in a stale process
The charts code in vwm/vmon assumes stale descendants of a stale
node, but there seems to be some theoretical potential for that
to not hold true.
Let's be more agressive about ensuring that's the case. The
current code already does this style propagation for stale
processes, but not for threads. It seems like it'd be weird to
have this happen, but maybe there's edge cases where you have a
parent process exit with grandchildren threads surviving until
a later sample, creating opportunity for a inconsistency.
-rw-r--r-- | src/libvmon/vmon.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libvmon/vmon.c b/src/libvmon/vmon.c index 4396b11..4ce0974 100644 --- a/src/libvmon/vmon.c +++ b/src/libvmon/vmon.c @@ -548,6 +548,22 @@ static int proc_follow_threads(vmon_t *vmon, vmon_proc_t *proc, vmon_proc_follow vmon_proc_unmonitor(vmon, tmp, NULL, NULL); } + /* If proc is stale, assume all the threads are stale as well. In vwm/charts.c we assume all descendants of a stale node + * are implicitly stale, so let's ensure that's a consistent assumumption WRT libvmon's maintenance of the hierarchy. + * The readdir below seems like it would't find any threads of a stale process, but maybe there's some potential for a race there, + * particularly since we reuse an open reference on the task_dir. + * This reflects a similar implicit is_stale propagation in follow_children. + */ + if (proc->is_stale) { + list_for_each_entry(tmp, &proc->threads, threads) + tmp->is_stale = 1; + + /* FIXME: the changes count seems to be unused here, so this currently always returns SAMPLE_UNCHANGED, and + * it's unclear to me if that was intentional or just never finished. + */ + return SAMPLE_UNCHANGED; + } + start = &proc->threads; while ((dentry = readdir((*store)->task_dir))) { int tid; |