Commit fb706469 authored by T.J. Mercier's avatar T.J. Mercier Committed by Martin Liu
Browse files

BACKPORT: ANDROID: dma-buf: heaps: replace mutex lock with spinlock



We should use spinlock to protect page pool's critical section as
1. The critical section is short, using spinlock is more efficient.
2. Spinlock could protect priority inversion. Ex. Low priority
   thread (dmabuf-deferred) hold the page lock but get scheduled
   out under heavy loading. Then the other high priority threads
   need to wait for dmabuf-deferred to release the lock. It causes
   long allocation latency and possible UI jank.

Also, we could move NR_KERNEL_MISC_RECLAIMABLE stat out of the
critical section to make it shorter as mod_node_page_state can
handle concurrent access cases.

Conflicts:
	drivers/dma-buf/heaps/page_pool.h
	drivers/dma-buf/heaps/page_pool.c

1. The android13-5.10 KMI is frozen, and the modification to struct
   dmabuf_page_pool in the original patch would break the KMI.
   Instead we wrap dmabuf_page_pool allocations in a struct
   dmabuf_page_pool_with_spinlock which also contains a spinlock
   replacement for dmabuf_page_pool's mutex.

   No callers should attempt to acquire dmabuf_page_pool's mutex on this
   branch, so it is locked immediately after initialization and never
   unlocked.

(cherry picked from commit 060e38dc)
Bug: 245454030
Bug: 261146598
Change-Id: I15f349f9e893621f71ca79f1de037de184c33edf
Signed-off-by: default avatarT.J. Mercier <tjmercier@google.com>
(cherry picked from commit fabb0f22)
parent 82277d39
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment