Fix blockable memory allocation under rcu_read_lock in psi monitors

psi_fop_poll calls poll_wait which makes a blockable allocation. This
generates the following warning:

[   22.339969] c0    898 BUG: sleeping function called from invalid context at mm/slab.h:393
[   22.339972] c0    898 in_atomic(): 0, irqs_disabled(): 0, pid: 898, name: lmkd
[   22.339979] c0    898 ------------[ cut here ]------------
[   22.339981] c0    898 kernel BUG at kernel/sched/core.c:8448!
[   22.339986] c0    898 ------------[ cut here ]------------
[   22.339987] c0    898 kernel BUG at kernel/sched/core.c:8448!
[   22.339989] c0    898 Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
[   22.339996] c0    898 Modules linked in:
[   22.340001] c0    898 CPU: 0 PID: 898 Comm: lmkd Not tainted 4.9.153-gae6c134c27aa-dirty_audio-g3dce958 #1
[   22.340002] c0    898 Hardware name: <redacted>
[   22.340004] c0    898 task: fffffff3a6696000 task.stack: fffffff3977b4000
[   22.340016] c0    898 PC is at ___might_sleep+0x104/0x10c
[   22.340019] c0    898 LR is at ___might_sleep+0xdc/0x10c
...
[   22.340201] c0    898 [<ffffff9f4bceaf2c>] ___might_sleep+0x104/0x10c
[   22.340203] c0    898 [<ffffff9f4bceae14>] __might_sleep+0x24/0x38
[   22.340209] c0    898 [<ffffff9f4be26d1c>] kmem_cache_alloc+0x60/0x338
[   22.340213] c0    898 [<ffffff9f4be9684c>] ep_ptable_queue_proc+0x38/0xc8
[   22.340219] c0    898 [<ffffff9f4bd18218>] psi_fop_poll+0x7c/0xbc

Fix this by using refcount during poll_wait and trigger destruction. This prevents trigger
from being destroyed during poll_wait call.

Bug: 124796537
Change-Id: Ib7feb96990f1cd96f1ab0e0720010ffa442c25d9
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
4 files changed