Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756151Ab3C2N7n (ORCPT ); Fri, 29 Mar 2013 09:59:43 -0400 Received: from mail-ia0-f178.google.com ([209.85.210.178]:40994 "EHLO mail-ia0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754215Ab3C2N7l (ORCPT ); Fri, 29 Mar 2013 09:59:41 -0400 MIME-Version: 1.0 In-Reply-To: <20130329095558.5fffd95f@annuminas.surriel.com> References: <1363809337-29718-1-git-send-email-riel@surriel.com> <5150B1C2.8090607@oracle.com> <20130325163844.042a45ba@annuminas.surriel.com> <1364303965.5053.29.camel@laptop> <1364308023.5053.40.camel@laptop> <5151BC78.3030306@surriel.com> <1364373750.5053.54.camel@laptop> <20130328162337.3003ccd4@cuia.bos.redhat.com> <20130329095558.5fffd95f@annuminas.surriel.com> Date: Fri, 29 Mar 2013 06:59:41 -0700 Message-ID: Subject: Re: [PATCH v3 -mm -next] ipc,sem: fix lockdep false positive From: Michel Lespinasse To: Rik van Riel Cc: Peter Zijlstra , Sasha Levin , torvalds@linux-foundation.org, davidlohr.bueso@hp.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, hhuang@redhat.com, jason.low2@hp.com, lwoodman@redhat.com, chegu_vinod@hp.com, Dave Jones , benisty.e@gmail.com, Ingo Molnar Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1546 Lines: 40 On Fri, Mar 29, 2013 at 6:55 AM, Rik van Riel wrote: > On Thu, 28 Mar 2013 19:50:47 -0700 > Michel Lespinasse wrote: > >> This is IMO where the spin_unlock_wait(&sma->sem_perm.lock) would >> belong - right before the goto again. > > Here is the slightly more optimistic (and probably more readable) > version of the patch: > > ---8<--- > Unfortunately the locking scheme originally proposed has false positives > with lockdep. This can be fixed by changing the code to only ever take > one lock, and making sure that other relevant locks are not locked, before > entering a critical section. > > For the "global lock" case, this is done by taking the sem_array lock, > and then (potentially) waiting for all the semaphore's spinlocks to be > unlocked. > > For the "local lock" case, we wait on the sem_array's lock to be free, > before taking the semaphore local lock. To prevent races, we need to > check again after we have taken the local lock. > > Suggested-by: Peter Zijlstra > Reported-by: Sasha Levin > Signed-off-by: Rik van Riel Looks good. Reviewed-by: Michel Lespinasse -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies. -- 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/