[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAG6tG3yQVhANm1eHx3W3Hacp8t5Bh=pF9dQbHc3rSVs5n0WR9g@mail.gmail.com>
Date: Thu, 16 May 2013 13:28:52 -0400
From: Robert Love <rlove@...gle.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Raul Xiong <raulxiong@...il.com>,
Neil Zhang <glacier1980@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Shankar Brahadeeswaran <shankoo77@...il.com>,
Dan Carpenter <dan.carpenter@...cle.com>,
LKML <linux-kernel@...r.kernel.org>,
Bjorn Bringert <bringert@...gle.com>,
devel <devel@...verdev.osuosl.org>,
Hugh Dickins <hughd@...gle.com>,
Anjana V Kumar <anjanavk12@...il.com>,
linux-next <linux-next@...r.kernel.org>
Subject: Re: [PATCH -next] ashmem: Fix ashmem_shrink deadlock.
On Thu, May 16, 2013 at 1:19 PM, Andrew Morton
<akpm@...ux-foundation.org> wrote:
> On Thu, 16 May 2013 13:08:17 -0400 Robert Love <rlove@...gle.com> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists