Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4139620pxb; Tue, 10 Nov 2020 08:51:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfzC0dDQ2ocd9VG9sZC3A3WrewPyNRQJdqucWbuNmbqN8Z2SZN72X6GNGcIYiQqMd/DMLJ X-Received: by 2002:a17:906:76d3:: with SMTP id q19mr20508137ejn.162.1605027092194; Tue, 10 Nov 2020 08:51:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605027092; cv=none; d=google.com; s=arc-20160816; b=YRo7us8tTPdaz94O3mXLT2GECCvD78QkNLL1k1JGHRDtY0nbXS6JD/TDS0G2+Ffpby TTFEislzUxTFSExobbhCr97WvNUIX8nJB/htvlwZD4lO4mGLz5mKy4BVfwNHXuYWdaNW +6mkvQ0kzK+AGaQlaUN3lZIbpTJoyuafnRboVvib/uItDuklzPQO1EtyFPvTrKbXYNnO NVVT/Ly1/d4vvRZItdlIQtJ9jvuhzzMadFaGRK/ShiFLZFOX/qA2daYv/lrAtS15Kkzr fVaXEhjhqrwATuBH7Pin1yMryja7nqYVkc/Ngp6wTP4v0A7SALtqekY6usIxDfzfKF8n 4TTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hdMMQUz3nXcemNcGh9uBePlGg+AV9ZP3u4MKFuh3gXg=; b=JqlhPd7ATIpWTp69Qp0JHIkMB+/gKL7kOGXxqERBHBnmW6XE829MLXZn6jV2FAhcl7 cNHFvg/oypUKYnvH94I6PAMThD+iSsKBqez9j+UwzJupoe1OR1ERnza7iHYCvkvkZUop lylEWS946fm6sR4XXoGQB8jNgp2V6xpyXp3IppVfii3e0rq0GhGo6Dq4YGaBhCz3eKSb XYs3+S0j07mMe2W7JKwTUS8FMAE+KrqCtCvLi0gAo1ED7ecRqTOkMI5VbffKwEyHR/4p BtYAq+4CT/y/m7X8gS4TCAxfeZ3EZS9ufH3CmmPLJIoe9/aERvzhxzaou4b7bBIMZufX HlgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=g0Wd7bmA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g23si9927982edr.322.2020.11.10.08.51.04; Tue, 10 Nov 2020 08:51:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=g0Wd7bmA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728272AbgKJQtj (ORCPT + 99 others); Tue, 10 Nov 2020 11:49:39 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:59476 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726152AbgKJQtj (ORCPT ); Tue, 10 Nov 2020 11:49:39 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AAGhn3l139108; Tue, 10 Nov 2020 16:49:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=hdMMQUz3nXcemNcGh9uBePlGg+AV9ZP3u4MKFuh3gXg=; b=g0Wd7bmAEhcqx9rXBOM8U2zElOPtdE+h7p4Xg+Ns4tcjE73KJfw2rLXUsF9Z9vFXB79a PyjKbmRKRSHt5MI4kRiXO4vO5RyV6wDoyfotAuVoQ6lzPyMcmROoyKKaymjtvSgYyv0n 74LSZe9JNCCxI2w5jeOQWqZzjvOm8MVIB4zW9ZpB34kYFZUhRrpO6vY6HW9n9e3jk7wi EV9kClaZocABM/e3QXkvNkzmw1SLb0D/LJV+EEQv4EoFPsw6qZghxFgpMSMy6lheU70U pIGAupBSjpuaedHa/URboibreFbhrcDDBqKk2STojEQj+o+Qmh9boV1BIiWSqCpb6SzF 6w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 34nkhkvkmy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Nov 2020 16:49:24 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AAGk91n087025; Tue, 10 Nov 2020 16:49:24 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 34p5gx6r5g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Nov 2020 16:49:24 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0AAGnLsq008053; Tue, 10 Nov 2020 16:49:21 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 08:49:21 -0800 Date: Tue, 10 Nov 2020 08:49:19 -0800 From: "Darrick J. Wong" To: Boqun Feng Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Filipe Manana , Peter Zijlstra , Jan Kara , David Sterba , Nikolay Borisov , Alexander Viro , Ingo Molnar Subject: Re: [RFC] fs: Avoid to use lockdep information if it's turned off Message-ID: <20201110164919.GC9685@magnolia> References: <20201110013739.686731-1-boqun.feng@gmail.com> <20201110014925.GB9685@magnolia> <20201110054016.GC286534@boqun-archlinux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201110054016.GC286534@boqun-archlinux> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100119 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 malwarescore=0 adultscore=0 clxscore=1015 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011100119 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 10, 2020 at 01:40:16PM +0800, Boqun Feng wrote: > On Mon, Nov 09, 2020 at 05:49:25PM -0800, Darrick J. Wong wrote: > > On Tue, Nov 10, 2020 at 09:37:37AM +0800, Boqun Feng wrote: > > > Filipe Manana reported a warning followed by task hanging after attempts > > > to freeze a filesystem[1]. The problem happened in a LOCKDEP=y kernel, > > > and percpu_rwsem_is_held() provided incorrect results when > > > debug_locks == 0. Although the behavior is caused by commit 4d004099a668 > > > ("lockdep: Fix lockdep recursion"): after that lock_is_held() and its > > > friends always return true if debug_locks == 0. However, one could argue > > > > ...the silent trylock conversion with no checking of the return value is > > completely broken. I already sent a patch to tear all this out: > > > > https://lore.kernel.org/linux-fsdevel/160494580419.772573.9286165021627298770.stgit@magnolia/T/#t > > > > Thanks! That looks good to me. I'm all for removing that piece of code. > > While we are at it, I have to ask, when you hit the original problem > (warning after trylock in __start_sb_write()), did you see any lockdep > splat happened previously? Yes. Every time I hit this there had been a lockdep splat earlier in the fstests run, along with lockdep declaring that it was going offline. --D > Or just like Filipe, you hit that without > seeing any lockdep splat happened before? Thanks! I'm trying to track > down the silent lockdep turn-off. > > Regards, > Boqun > > > --D > > > > > that querying the lock holding information regardless if the lockdep > > > turn-off status is inappropriate in the first place. Therefore instead > > > of reverting lock_is_held() and its friends to the previous semantics, > > > add the explicit checking in fs code to avoid use the lock holding > > > information if lockdpe is turned off. And since the original problem > > > also happened with a silent lockdep turn-off, put a warning if > > > debug_locks is 0, which will help us spot the silent lockdep turn-offs. > > > > > > [1]: https://lore.kernel.org/lkml/a5cf643b-842f-7a60-73c7-85d738a9276f@suse.com/ > > > > > > Reported-by: Filipe Manana > > > Fixes: 4d004099a668 ("lockdep: Fix lockdep recursion") > > > Signed-off-by: Boqun Feng > > > Cc: Peter Zijlstra > > > Cc: Jan Kara > > > Cc: David Sterba > > > Cc: Nikolay Borisov > > > Cc: "Darrick J. Wong" > > > --- > > > Hi Filipe, > > > > > > I use the slightly different approach to fix this problem, and I think > > > it should have the similar effect with my previous fix[2], except that > > > you will hit a warning if the problem happens now. The warning is added > > > on purpose because I don't want to miss a silent lockdep turn-off. > > > > > > Could you and other fs folks give this a try? > > > > > > Regards, > > > Boqun > > > > > > [2]: https://lore.kernel.org/lkml/20201103140828.GA2713762@boqun-archlinux/ > > > > > > fs/super.c | 11 +++++++++++ > > > 1 file changed, 11 insertions(+) > > > > > > diff --git a/fs/super.c b/fs/super.c > > > index a51c2083cd6b..1803c8d999e9 100644 > > > --- a/fs/super.c > > > +++ b/fs/super.c > > > @@ -1659,12 +1659,23 @@ int __sb_start_write(struct super_block *sb, int level, bool wait) > > > * twice in some cases, which is OK only because we already hold a > > > * freeze protection also on higher level. Due to these cases we have > > > * to use wait == F (trylock mode) which must not fail. > > > + * > > > + * Note: lockdep can only prove correct information if debug_locks != 0 > > > */ > > > if (wait) { > > > int i; > > > > > > for (i = 0; i < level - 1; i++) > > > if (percpu_rwsem_is_held(sb->s_writers.rw_sem + i)) { > > > + /* > > > + * XXX: the WARN_ON_ONCE() here is to help > > > + * track down silent lockdep turn-off, i.e. > > > + * this warning is triggered, but no lockdep > > > + * splat is reported. > > > + */ > > > + if (WARN_ON_ONCE(!debug_locks)) > > > + break; > > > + > > > force_trylock = true; > > > break; > > > } > > > -- > > > 2.29.2 > > >