Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934014AbdCJVec (ORCPT ); Fri, 10 Mar 2017 16:34:32 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:46802 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932595AbdCJVe0 (ORCPT ); Fri, 10 Mar 2017 16:34:26 -0500 Date: Fri, 10 Mar 2017 13:34:19 -0800 From: Matthew Wilcox To: Alexey Khoroshilov Cc: Vitaly Wool , Andrew Morton , Dan Streetman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: Re: z3fold: suspicious return with spinlock held Message-ID: <20170310213419.GD16328@bombadil.infradead.org> References: <1489180932-13918-1-git-send-email-khoroshilov@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1489180932-13918-1-git-send-email-khoroshilov@ispras.ru> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 890 Lines: 21 On Sat, Mar 11, 2017 at 12:22:12AM +0300, Alexey Khoroshilov wrote: > Hello! > > z3fold_reclaim_page() contains the only return that may > leave the function with pool->lock spinlock held. > > 669 spin_lock(&pool->lock); > 670 if (kref_put(&zhdr->refcount, release_z3fold_page)) { > 671 atomic64_dec(&pool->pages_nr); > 672 return 0; > 673 } > > May be we need spin_unlock(&pool->lock); just before return? I would tend to agree. sparse warns about this, and also about two other locking problems ... which I'm not sure are really problems so much as missing annotations? mm/z3fold.c:467:35: warning: context imbalance in 'z3fold_alloc' - unexpected unlock mm/z3fold.c:519:26: warning: context imbalance in 'z3fold_free' - different lock contexts for basic block mm/z3fold.c:581:12: warning: context imbalance in 'z3fold_reclaim_page' - different lock contexts for basic block