From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753129AbdJGRHH (ORCPT ); Sat, 7 Oct 2017 13:07:07 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:54198 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751373AbdJGRHG (ORCPT ); Sat, 7 Oct 2017 13:07:06 -0400 Date: Sat, 7 Oct 2017 18:06:51 +0100 From: Al Viro To: Vladimir Davydov Cc: Michal Hocko , Jia-Ju Bai , torbjorn.lindh@gopta.se, rgooch@atnf.csiro.au, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [BUG] fs/super: a possible sleep-in-atomic bug in put_super Message-ID: <20171007170651.GR21978@ZenIV.linux.org.uk> References: <06badf5e-292d-ef63-7499-6888dec1b9b0@163.com> <20171006090604.m5oxcyb2xtllpmpu@dhcp22.suse.cz> <20171007115640.w3m6vxxrglcbeutl@esperanza> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171007115640.w3m6vxxrglcbeutl@esperanza> User-Agent: Mutt/1.9.0 (2017-09-02) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 07, 2017 at 02:56:40PM +0300, Vladimir Davydov wrote: > Hello, > > On Fri, Oct 06, 2017 at 11:06:04AM +0200, Michal Hocko wrote: > > On Fri 06-10-17 16:59:18, Jia-Ju Bai wrote: > > > According to fs/super.c, the kernel may sleep under a spinlock. > > > The function call path is: > > > put_super (acquire the spinlock) > > > __put_super > > > destroy_super > > > list_lru_destroy > > > list_lru_unregister > > > mutex_lock --> may sleep > > > memcg_get_cache_ids > > > down_read --> may sleep > > > > > > This bug is found by my static analysis tool and my code review. > > This is false-positive: by the time we get to destroy_super(), the lru > lists have already been destroyed - see deactivate_locked_super() - so > list_lru_destroy() will retrun right away without attempting to take any > locks. That's why there's no lockdep warnings regarding this issue. > > I think we can move list_lru_destroy() to destroy_super_work() to > suppress this warning. Not sure if it's really worth the trouble though. It's a bit trickier than that (callers of destroy_super() prior to superblock getting reachable via shared data structures do not have that lru_list_destroy() a no-op, but they are not called under spinlocks). Locking in mm/list_lru.c looks excessive, but then I'm not well familiar with that code.