[BUG] staging: android: ashmem: Deadlock during ashmem_shrink

Robert Love rlove at google.com
Thu Apr 25 15:05:53 UTC 2013


On Thu, Apr 25, 2013 at 9:54 AM, Shankar Brahadeeswaran
<shankoo77 at gmail.com> wrote:

> 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).

      Robert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ashmem-lock-fix-rlove-2.patch
Type: application/octet-stream
Size: 739 bytes
Desc: not available
URL: <http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/attachments/20130425/efa9144c/attachment.obj>


More information about the devel mailing list