From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932282AbcINFOU convert rfc822-to-8bit (ORCPT ); Wed, 14 Sep 2016 01:14:20 -0400 Received: from mga02.intel.com ([134.134.136.20]:3002 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750789AbcINFOJ (ORCPT ); Wed, 14 Sep 2016 01:14:09 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,332,1470726000"; d="scan'208";a="8149959" From: "Dilger, Andreas" To: Greg KH CC: Nayeemahmed Badebade , "devel@driverdev.osuosl.org" , "Linux Kernel Mailing List" , "Drokin, Oleg" , James Simmons , "Lustre Development List" Subject: Re: [PATCH] staging: lustre: lustre/ldlm: Fixed sparse warnings Thread-Topic: [PATCH] staging: lustre: lustre/ldlm: Fixed sparse warnings Thread-Index: AQHSDkbOaWlA2bSvo0i9HkA138ishw== Date: Wed, 14 Sep 2016 05:14:02 +0000 Message-ID: <47AECAA7-59D7-41DB-9A85-A23ACF6A7B1F@intel.com> References: <1473434435-27025-1-git-send-email-itachi.opsrc@gmail.com> <20160912102747.GA13621@kroah.com> In-Reply-To: <20160912102747.GA13621@kroah.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.254.60.215] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sep 12, 2016, at 04:27, Greg KH wrote: > > On Fri, Sep 09, 2016 at 08:50:35PM +0530, Nayeemahmed Badebade wrote: >> Added __acquires / __releases sparse locking annotations >> to lock_res_and_lock and unlock_res_and_lock functions in >> l_lock.c, to fix below sparse warnings: >> >> l_lock.c:47:22: warning: context imbalance in 'lock_res_and_lock' - wrong count at exit >> l_lock.c:62:6: warning: context imbalance in 'unlock_res_and_lock' - unexpected unlock >> >> Signed-off-by: Nayeemahmed Badebade >> --- >> drivers/staging/lustre/lustre/ldlm/l_lock.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c b/drivers/staging/lustre/lustre/ldlm/l_lock.c >> index ea8840c..c4b9612 100644 >> --- a/drivers/staging/lustre/lustre/ldlm/l_lock.c >> +++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c >> @@ -45,6 +45,8 @@ >> * being an atomic operation. >> */ >> struct ldlm_resource *lock_res_and_lock(struct ldlm_lock *lock) >> + __acquires(&lock->l_lock) >> + __acquires(lock->l_resource) > > Hm, these are tricky, I don't want to take this type of change without > an ack from the lustre developers... The "__acquires(&lock->l_lock)" line here looks correct, along with the corresponding "__releases(&lock->l_lock)" at unlock_res_and_lock(). The problem, however, is that "l_resource" is not a lock, but rather a struct. The call to "lock_res(lock->l_resource)" is actually locking "lr_lock" internally. It would be better to add "__acquires(&res->lr_lock)" at lock_res() and "__releases(&res->lr_lock)" at unlock_res(). That will also forestall any other warnings about an imbalance with lock_res()/unlock_res() or their callsites. Cheers, Andreas