From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raul Xiong Subject: Re: [PATCH -next] ashmem: Fix ashmem_shrink deadlock. Date: Tue, 17 Sep 2013 13:05:29 +0800 Message-ID: References: <1367416573-5430-1-git-send-email-rlove@google.com> <20130513214216.GA23743@kroah.com> <20130516094559.4d2c9212.akpm@linux-foundation.org> <20130516101907.d102dd91.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from mail-qa0-f44.google.com ([209.85.216.44]:65060 "EHLO mail-qa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751555Ab3IQFFa (ORCPT ); Tue, 17 Sep 2013 01:05:30 -0400 In-Reply-To: Sender: linux-next-owner@vger.kernel.org List-ID: To: Robert Love Cc: Andrew Morton , Neil Zhang , Greg Kroah-Hartman , Shankar Brahadeeswaran , Dan Carpenter , LKML , Bjorn Bringert , devel , Hugh Dickins , Anjana V Kumar , linux-next 2013/5/17 Robert Love : > On Thu, May 16, 2013 at 1:19 PM, Andrew Morton > wrote: >> On Thu, 16 May 2013 13:08:17 -0400 Robert Love wrote: >>> This problem seems a rare proper use of mutex_trylock. >> >> Not really. The need for a trylock is often an indication that a >> subsystem has a locking misdesign. That is indeed the case here. > > It is exactly the same as PF_MEMALLOC. We've got an effectively > asynchronous event (shrinking) that can occur while you are holding > locks requisite to that shrinking. Given that the shrinkage is best > effort, a trylock actually communicates the intent pretty well: "If > possible, grab this lock and shrink." > > I think the idiomatic fix is to introduce a GFP_SHMEM but that seems > overkill. Lots of the GFP flags are really just preventing recursing > into the shrinkage code and it seems ill-designed that we require > developers to know where they might end up. But we can disagree. :) > >> Well, it's not exactly a ton of work, but adding a per-ashmem_area lock >> to protect ->file would rather be putting lipstick on a pig. I suppose >> we can put the trylock in there and run away, but it wouldn't hurt to >> drop in a big fat comment somewhere explaining that the driver should be >> migrated to a per-object locking scheme. > > Unfortunately I think ashmem_shrink would need to grab the per-object > lock too; it needs to update the ranges. I'm sure we could re-design > this but I don't think it is as easy as simply pushing the locking > into the objects. > > Robert Hi all, I am wondering if this is fixed in latest kernel? We are continuously seeing this deadlock issue. Best Regards, Raul