Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934100AbdCJVyv (ORCPT ); Fri, 10 Mar 2017 16:54:51 -0500 Received: from mail.ispras.ru ([83.149.199.45]:35026 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932705AbdCJVyp (ORCPT ); Fri, 10 Mar 2017 16:54:45 -0500 Subject: Re: z3fold: suspicious return with spinlock held To: Matthew Wilcox References: <1489180932-13918-1-git-send-email-khoroshilov@ispras.ru> <20170310213419.GD16328@bombadil.infradead.org> Cc: Vitaly Wool , Andrew Morton , Dan Streetman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org From: Alexey Khoroshilov Message-ID: <82e268d4-22fa-3e33-8988-a3a367fae7b1@ispras.ru> Date: Sat, 11 Mar 2017 00:54:26 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170310213419.GD16328@bombadil.infradead.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1098 Lines: 29 On 11.03.2017 00:34, Matthew Wilcox wrote: > 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 > I also do not see problems in z3fold_alloc() and z3fold_free(). But I am unaware of sparse annotations that can help here. -- Alexey