In current code, we firstly get one process's thread number by
reading "Threads:" from /proc/pid/status; then secondly load each
thread's info into devtstat->taskall by traversing each tid under
/proc/pid/task/. Here, information inconsistency occurs if some
processes frequently creates or deletes threads. For example:
$cat /proc/6/status |grep Threads; sleep 0.1; ls /proc/6/task/ | wc -l
Threads: 70
71
To fix this, calibrate the value of nthr after iterating each
process's threads: re-record the number of threads and assign
to each process's nthr again.
In current code, we firstly get one process's thread number by reading "Threads:" from /proc/pid/status; then secondly load each thread's info into devtstat->taskall by traversing each tid under /proc/pid/task/. Here, information inconsistency occurs if some processes frequently creates or deletes threads. For example: $cat /proc/6/status |grep Threads; sleep 0.1; ls /proc/6/task/ | wc -l Threads: 70 71
To fix this, calibrate the value of nthr after iterating each process's threads: re-record the number of threads and assign to each process's nthr again.
Signed-off-by: Fei Li lifei.shirley@bytedance.com