Atoptool / atop

System and process monitor for Linux
GNU General Public License v2.0
799 stars 111 forks source link

Calibrate the value of nthr for each process #190

Closed ShirleyFei closed 2 years ago

ShirleyFei commented 2 years ago

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

Atoptool commented 2 years ago

The calibration code has been modified, because for every multi-threaded process one thread was counted too many.