Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ANDROID: uid_sys_stats: Use a single work for deferred updates
uid_sys_stats tries to acquire a lock when any task exits to do some bookkeeping in common data structure. If the lock is contended, it allocates and schedules a work to do the work later to avoid task exit latency. In a stress test which creates many tasks exiting, the workqueue can be overwhelmed by the number of works being scheduled and allocates more worker threads to handle queue. The growth of the number of threads is effectively unbounded and can exhaust the process table. This causes denial of service to userspace trying to fork(). Instead of allocating a new work each, create a linked list of the update stats deferred work and have a single work to drain the linked list. The linked list is implemented using an atomic_long_t. Bug: 294468796 Fixes: 5586278c0fe6 ("ANDROID: uid_sys_stats: defer process_notifier work if uid_lock is contended") Signed-off-by: Elliot Berman <quic_eberman@quicinc.com> (cherry picked from https://android-review.googlesource.com/q/commit:8e86825eecfaaa582ab51a0924b469d2d2adc743) Merged-In: I15f20f4f69ea66a452bdf815c4ef3a0da3edfd36 Change-Id: I15f20f4f69ea66a452bdf815c4ef3a0da3edfd36
- Loading branch information