Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934286AbdCJWJG (ORCPT ); Fri, 10 Mar 2017 17:09:06 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36643 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933631AbdCJWI6 (ORCPT ); Fri, 10 Mar 2017 17:08:58 -0500 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: z3fold: suspicious return with spinlock held From: vitalywool@gmail.com X-Mailer: iPhone Mail (14D27) In-Reply-To: <82e268d4-22fa-3e33-8988-a3a367fae7b1@ispras.ru> Date: Fri, 10 Mar 2017 23:08:53 +0100 Cc: Matthew Wilcox , Andrew Morton , Dan Streetman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Message-Id: <2E74B250-1EE0-483A-ACA0-143C4F1ECD44@gmail.com> References: <1489180932-13918-1-git-send-email-khoroshilov@ispras.ru> <20170310213419.GD16328@bombadil.infradead.org> <82e268d4-22fa-3e33-8988-a3a367fae7b1@ispras.ru> To: Alexey Khoroshilov Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v2AM9AZs014978 Content-Length: 1362 Lines: 37 Hi Alexey, > 10 mars 2017 kl. 22:54 skrev Alexey Khoroshilov : > >> 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? Looks so, thanks for the pointer. I'm currently commuting but will check it thoroughly tomorrow for sure. ~vitaly >> >> 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