From: Robert Love <rlove@google•com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation•org>,
Shankar Brahadeeswaran <shankoo77@gmail•com>,
Dan Carpenter <dan.carpenter@oracle•com>,
LKML <linux-kernel@vger•kernel.org>,
Bjorn Bringert <bringert@google•com>,
devel <devel@driverdev•osuosl.org>,
Hugh Dickins <hughd@google•com>,
Anjana V Kumar <anjanavk12@gmail•com>,
Dad <akpm@linux-foundation•org>,
linux-next <linux-next@vger•kernel.org>
Subject: [PATCH -next] ashmem: Fix ashmem_shrink deadlock.
Date: Wed, 1 May 2013 09:56:13 -0400 [thread overview]
Message-ID: <1367416573-5430-1-git-send-email-rlove@google.com> (raw)
Don't acquire ashmem_mutex in ashmem_shrink if we've somehow recursed into the
shrinker code from within ashmem. Just bail out, avoiding a deadlock. This is
fine, as ashmem cache pruning is advisory anyhow.
Signed-off-by: Robert Love <rlove@google•com>
---
drivers/staging/android/ashmem.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index e681bdd..82c6768 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -363,7 +363,11 @@ static int ashmem_shrink(struct shrinker *s, struct shrink_control *sc)
if (!sc->nr_to_scan)
return lru_count;
- mutex_lock(&ashmem_mutex);
+ /* avoid recursing into this code from within ashmem itself */
+ if (!mutex_trylock(&ashmem_mutex)) {
+ return -1;
+ }
+
list_for_each_entry_safe(range, next, &ashmem_lru_list, lru) {
loff_t start = range->pgstart * PAGE_SIZE;
loff_t end = (range->pgend + 1) * PAGE_SIZE;
--
1.8.2.1
next reply other threads:[~2013-05-01 13:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-01 13:56 Robert Love [this message]
2013-05-01 15:54 ` [PATCH -next] ashmem: Fix ashmem_shrink deadlock David Rientjes
2013-05-02 18:22 ` David Rientjes
2013-05-02 20:39 ` Greg Kroah-Hartman
2013-05-07 20:52 ` Andrew Morton
2013-05-13 21:42 ` Greg Kroah-Hartman
2013-05-14 3:29 ` Neil Zhang
2013-05-14 3:37 ` Raul Xiong
2013-05-16 8:15 ` Raul Xiong
2013-05-16 13:44 ` Robert Love
2013-05-16 16:45 ` Andrew Morton
2013-05-16 17:08 ` Robert Love
2013-05-16 17:19 ` Andrew Morton
2013-05-16 17:28 ` Robert Love
2013-09-17 5:05 ` Raul Xiong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1367416573-5430-1-git-send-email-rlove@google.com \
--to=rlove@google$(echo .)com \
--cc=akpm@linux-foundation$(echo .)org \
--cc=anjanavk12@gmail$(echo .)com \
--cc=bringert@google$(echo .)com \
--cc=dan.carpenter@oracle$(echo .)com \
--cc=devel@driverdev$(echo .)osuosl.org \
--cc=gregkh@linuxfoundation$(echo .)org \
--cc=hughd@google$(echo .)com \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-next@vger$(echo .)kernel.org \
--cc=shankoo77@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox