ANDROID: uid_sys_stats: avoid double accounting of dying threads
When a thread is being killed process_notifier() is called to record
the final accounting of the thread. But after that uid_cputime_show()
and add_uid_io_stats() can be called before the dying thread is
removed from the parent's thread_group resulting in double accounting.
This can cause the user and system time for a given UID to move
backwards in /proc/uid_cputime/show_uid_stat. That gives negative delta
times in KernelCpuUidUserSysTimeReader.readDeltaImpl() and it logs
an error:
"Negative user/sys time delta for UID=..."
One consequence of which was incorrectly calculated power consumptions
in BatteryStats.
With this change we avoid the double accounting by ignoring the thread
if it has the PF_EXITING flag set.
Bug: 144366911
Change-Id: I6b929e8f558cd81ce1c00481c8b550d24877aa2c
Signed-off-by: Rickard Möller <rickard.moller@sony.com>
1 file changed