Re: [BUG] staging: android: ashmem: Deadlock during ashmem_shrink
From: Robert Love
Date: Thu Apr 25 2013 - 11:05:58 EST
On Thu, Apr 25, 2013 at 9:54 AM, Shankar Brahadeeswaran
> Also, there are other places in the code where ashmem_mutex is held and memory
> allocation functions are called, ex:- range_alloc, calls kmem_cache_zalloc
> Since ashmem_shrink holds the ashmem_mutex, any where from ashmem driver
> if a memory allocation function is called with the ashmem_mutex held
> && if there is a low memory condition that leads to shrinkers being called
> we'll hit the deadlock.
The usual way this is solved is by checking the gfp_mask in the
shrinker code and bailing out (like we do now) for certain masks. So
e.g. the kmem_cache_zalloc in range_alloc is fixed by changing the
mask to GFP_FS.
> I'm trying to see if the ashmem_shrink should really hold the ashmem_mutex,
> but looks like its necessary.
Yes, it needs to hold ashmem_mutex.
There's no reason we have to run ashmem_shrink, though. See attached (untested).
Description: Binary data