Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754804AbbEUIQN (ORCPT ); Thu, 21 May 2015 04:16:13 -0400 Received: from mail-wg0-f52.google.com ([74.125.82.52]:35431 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754066AbbEUIPm (ORCPT ); Thu, 21 May 2015 04:15:42 -0400 Date: Thu, 21 May 2015 10:15:34 +0200 From: AdrianRemonda To: Dan Carpenter Cc: "open list:STAGING SUBSYSTEM" , "moderated list:STAGING - LUSTRE..." , Andreas Dilger , Greg Donald , open list , Oleg Drokin , Julia Lawall , Greg Kroah-Hartman , Joe Perches Subject: Re: [PATCH 4/4] Staging: lustre: sparse lock warning fix Message-ID: <20150521081534.GA13975@debian> References: <1431974091-26363-1-git-send-email-adrianremonda@gmail.com> <1431974091-26363-2-git-send-email-adrianremonda@gmail.com> <1431974091-26363-3-git-send-email-adrianremonda@gmail.com> <1431974091-26363-4-git-send-email-adrianremonda@gmail.com> <1431974091-26363-5-git-send-email-adrianremonda@gmail.com> <20150518212115.GN14154@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150518212115.GN14154@mwanda> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1599 Lines: 44 On Tue, May 19, 2015 at 12:21:15AM +0300, Dan Carpenter wrote: > On Mon, May 18, 2015 at 08:34:51PM +0200, Adrian Remonda wrote: > > Fixed sparse warning: context imbalance in 'nrs_resource_put_safe' - > > 'different lock contexts for basic block' by releasing the lock on each > > iteration of the for loop. > > > > That changelog doesn't sound correct at all. That's not a correct > motivation or explanation. > > I reviewed the patch and it's likely going to cause dead locks. The code > is trying to take the spinlock for the first pointer in the array and > release it at the end. Now it takes the first pointer's spinlock a > bunch of times (dead lock) and releases it once (will not happen because > we are already dead). > > Hello Dan, thanks for the comments. The code would end up looking as next, I don't undertand where the deadlock would be. I know the older code would work, I just changed it to keep the lock locked the less time as possible. for (i = 0; i < NRS_RES_MAX; i++) { if (pols[i] == NULL) continue; if (nrs == NULL) { nrs = pols[i]->pol_nrs; } spin_lock(&nrs->nrs_lock); nrs_policy_put_locked(pols[i]); spin_unlock(&nrs->nrs_lock); } best regards, Adrian -- 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/