summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinchan Kim <minchan@google.com>2021-09-27 14:29:32 -0700
committerMinchan Kim <minchan@google.com>2021-09-28 08:52:03 -0700
commitf4860f239a4db4a63338df1e6915dc7ce8068d0c (patch)
tree796532c656e853786c6d272c2bd6ed0665d5208c
parentaec9b53c82d630542757cbbb7a86b89ac45d3a88 (diff)
downloadgpu-f4860f239a4db4a63338df1e6915dc7ce8068d0c.tar.gz
mali_kbase: bail out shrinking if the lock is contended
If the mmu_lock is contended for a long time in shrinking process under kswapd context(e.g., lock holder was cpu.share limited so it took 100ms to release the lock), kswapd is stuck on the lock. It's not good because it causes more memory pressure in the system. This patch makes the shrinking functino aware of kswapd context to bail out if it's the case for kswapd to proceed reclaiming with other reclaimable memory. Bug: 201414237 Signed-off-by: Minchan Kim <minchan@google.com> Change-Id: Id9e08873def1cf63022937b88af45531d76e2d96
-rw-r--r--mali_kbase/mmu/mali_kbase_mmu.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/mali_kbase/mmu/mali_kbase_mmu.c b/mali_kbase/mmu/mali_kbase_mmu.c
index d296956..e9f8b12 100644
--- a/mali_kbase/mmu/mali_kbase_mmu.c
+++ b/mali_kbase/mmu/mali_kbase_mmu.c
@@ -1746,7 +1746,17 @@ int kbase_mmu_teardown_pages(struct kbase_device *kbdev,
return 0;
}
- rt_mutex_lock(&mmut->mmu_lock);
+ if (!rt_mutex_trylock(&mmut->mmu_lock)) {
+ /*
+ * Sometimes, mmu_lock takes long time to be released.
+ * In that case, kswapd is stuck until it can hold
+ * the lock. Instead, just bail out here so kswapd
+ * could reclaim other pages.
+ */
+ if (current_is_kswapd())
+ return -EBUSY;
+ rt_mutex_lock(&mmut->mmu_lock);
+ }
mmu_mode = kbdev->mmu_mode;