From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raul Xiong Subject: Re: [PATCH -next] ashmem: Fix ashmem_shrink deadlock. Date: Thu, 16 May 2013 16:15:49 +0800 Message-ID: References: <1367416573-5430-1-git-send-email-rlove@google.com> <20130513214216.GA23743@kroah.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from mail-ie0-f169.google.com ([209.85.223.169]:56301 "EHLO mail-ie0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755310Ab3EPIPu (ORCPT ); Thu, 16 May 2013 04:15:50 -0400 In-Reply-To: Sender: linux-next-owner@vger.kernel.org List-ID: To: Neil Zhang Cc: Greg Kroah-Hartman , Robert Love , Shankar Brahadeeswaran , Dan Carpenter , LKML , Bjorn Bringert , devel , Hugh Dickins , Anjana V Kumar , Dad , linux-next 2013/5/14 Raul Xiong > > 2013/5/14 Neil Zhang : > > 2013/5/14 Greg Kroah-Hartman : > >> On Wed, May 01, 2013 at 09:56:13AM -0400, Robert Love wrote: > >>> 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 > >>> --- > >>> drivers/staging/android/ashmem.c | 6 +++++- > >>> 1 file changed, 5 insertions(+), 1 deletion(-) > >> > >> Based on Andrew's review comments, I'll drop this from my queue and wait > >> for a "better" fix for this. > >> > >> thanks, > >> > >> greg k-h > >> -- > >> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > >> the body of a message to majordomo@vger.kernel.org > >> More majordomo info at http://vger.kernel.org/majordomo-info.html > >> Please read the FAQ at http://www.tux.org/lkml/ > > > > We found the similar issue these days. > > Add RaulXiong to paste the call stack. > > > > Best Regards, > > Neil Zhang > > Hi all, > I just encountered this deadlock during some stress test and it can be > described clearly by below function stack. Please check and suggest a > formal fix for it. > > [] (__schedule) from [] > [] (schedule_preempt_disabled) from [] > [] (__mutex_lock_slowpath) from [] > [] (mutex_lock) from [] > [] (ashmem_shrink) from [] > [] (shrink_slab) from [] > [] (try_to_free_pages) from [] > [] (__alloc_pages_nodemask) from [] > [] (new_slab) from [] > [] (__slab_alloc.isra.46.constprop.52) from [] > [] (kmem_cache_alloc) from [] > [] (shmem_alloc_inode) from [] > [] (alloc_inode) from [] > [] (new_inode_pseudo) from [] > [] (new_inode) from [] > [] (shmem_get_inode) from [] > [] (shmem_file_setup) from [] > [] (ashmem_mmap) from [] > [] (mmap_region) from [] > [] (sys_mmap_pgoff) from [] > > Thanks, > Raul Xiong Hi Andrew, Greg, Any feedback? The issue happens in such sequence: ashmem_mmap acquired ashmem_mutex --> ashmem_mutex:shmem_file_setup called kmem_cache_alloc --> shrink due to low memory --> ashmem_shrink tries to acquire the same ashmem_mutex -- it blocks here. I think this reports the bug clearly. Please have a look. Thanks, Raul Xiong