Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3177330pxb; Mon, 16 Nov 2020 07:43:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVfVv9iuFeiT5MpwY3Ri8kAuXl+3Gs4agTZSlLE0hG5LyLLq/ZLTW87IfqaTMlwG9acGF1 X-Received: by 2002:a05:6402:947:: with SMTP id h7mr16343983edz.85.1605541391252; Mon, 16 Nov 2020 07:43:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605541391; cv=none; d=google.com; s=arc-20160816; b=KznTOL1HFjFg3o+zkKlC0gouabrJoHxptiIQwTJd9/vfoNlNIsk8BRLWF+tgBwWGoF Y0sn0IUhHiaf6S0HP7UlQKj+95LFdEXAayNMoqaMvaLYWAJPiS0HdThHvlne5T8xZRer zMioWukePPDxBcQpKb8aMNqgCuP1+Dnanz04pDqVDKqX90yupAv4wy5LonE3irkqptxh DuP+NnSY3ZFu5IV1I+dQ71N38wuNzCa93P4pMxMV1oyqUi3ERHyLzrMvd9bbxxwgopWI 6dMtdGV04M+D11MnfwDVphDWd2tTpO3NDuV/qfrh1BJKel6A1GHk7szM/wkSIx63TmpA JUYg== 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=ZvJKDfOtqFnHfu8dG1Qx2vAP9wnn1FoMYrFjYwCAmxY=; b=Moz9SqEHwJsrL1JfoEWMC7J8qM1+xX+KQjXc5xYvUzpc00+bDqLuMTBmFuZoufKHLg h4C6orOzXrCQ/Wh1NVfIX6iQshIwD2QB+l91MlL22YRLn/WMfk25Xe9Vd8kbh4W7JYvO JhbsEXxGToEW1FhVoFzgTBbzuhdRLE7qrOBBCAxi1TmAfS9XLtmwoHiUx3EwaM2zIaSW zjmZiM27ciZpC4cGh3zL00ImCzEsjr1iHcf+N/lsCITG+TOxdDHrC4olU8LWOlrNe10n Gg3dRAFVu1CRNYzYb4cmMRZHwOgopHK6U3gqR2HjxSOuv+hfr4j7EtMtOcuO/493yUGL zhDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=jT8VyzPP; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rv18si11484482ejb.320.2020.11.16.07.42.45; Mon, 16 Nov 2020 07:43:11 -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=@infradead.org header.s=casper.20170209 header.b=jT8VyzPP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731353AbgKPPhu (ORCPT + 99 others); Mon, 16 Nov 2020 10:37:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730415AbgKPPht (ORCPT ); Mon, 16 Nov 2020 10:37:49 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E094C0613CF for ; Mon, 16 Nov 2020 07:37:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ZvJKDfOtqFnHfu8dG1Qx2vAP9wnn1FoMYrFjYwCAmxY=; b=jT8VyzPPTRzr4VD2Qzzzsx262p YdZtMp7j6mrObT0JnAnIjbPSQMh5PIoh3wDtYudi3l8roCVLpO9s+y8XXwZ1SJ+ghsdynMv85XZpD R8bWESd6RhTIo6ACf6qIawQVMrm57kCjqS165rQy3CjPqsk+RgapdhVZIE6YXBC1pIdGHAjhYQQ3b xeEXrqjt4WJQw2iMEIfttIUqHBa6yoCjsTuZeRFWE//PG9HfeVuAScl48+4ZtktlUkvYBc+GCZEAq Ci9eub6KQ5hxf0KZN+OEVxG6Z3zbQCuNfN8bPPKqQN8+3jo8GR84fVxuD+XBJc7hIEsIUYwXzL5tp cJnHMvfQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kegZN-0000iW-CT; Mon, 16 Nov 2020 15:37:29 +0000 Date: Mon, 16 Nov 2020 15:37:29 +0000 From: Matthew Wilcox To: Byungchul Park Cc: Steven Rostedt , Thomas Gleixner , Ingo Molnar , torvalds@linux-foundation.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, linux-kernel@vger.kernel.org, joel@joelfernandes.org, alexander.levin@microsoft.com, daniel.vetter@ffwll.ch, chris@chris-wilson.co.uk, duyuyang@gmail.com, johannes.berg@intel.com, tj@kernel.org, tytso@mit.edu, david@fromorbit.com, amir73il@gmail.com, bfields@fieldses.org, gregkh@linuxfoundation.org, kernel-team@lge.com Subject: Re: [RFC] Are you good with Lockdep? Message-ID: <20201116153729.GC29991@casper.infradead.org> References: <20201111050559.GA24438@X58A-UD3R> <20201111105441.GA78848@gmail.com> <20201111093609.1bd2b637@gandalf.local.home> <87d00jo55p.fsf@nanos.tec.linutronix.de> <20201112081030.GB14554@X58A-UD3R> <20201112092612.00a19239@gandalf.local.home> <20201112145251.GB17076@casper.infradead.org> <20201116085757.GB26078@X58A-UD3R> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201116085757.GB26078@X58A-UD3R> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 16, 2020 at 05:57:57PM +0900, Byungchul Park wrote: > On Thu, Nov 12, 2020 at 02:52:51PM +0000, Matthew Wilcox wrote: > > On Thu, Nov 12, 2020 at 09:26:12AM -0500, Steven Rostedt wrote: > > > > FYI, roughly Lockdep is doing: > > > > > > > > 1. Dependency check > > > > 2. Lock usage correctness check (including RCU) > > > > 3. IRQ related usage correctness check with IRQFLAGS > > > > > > > > 2 and 3 should be there forever which is subtle and have gotten matured. > > > > But 1 is not. I've been talking about 1. But again, it's not about > > > > replacing it right away but having both for a while. I'm gonna try my > > > > best to make it better. > > > > > > And I believe lockdep does handle 1. Perhaps show some tangible use case > > > that you want to cover that you do not believe that lockdep can handle. If > > > lockdep cannot handle it, it will show us where lockdep is lacking. If it > > > can handle it, it will educate you on other ways that lockdep can be > > > helpful in your development ;-) > > > > Something I believe lockdep is missing is a way to annotate "This lock > > will be released by a softirq". If we had lockdep for lock_page(), this > > would be a great case to show off. The filesystem locks the page, then > > submits it to a device driver. On completion, the filesystem's bio > > completion handler will be called in softirq context and unlock the page. > > > > So if the filesystem has another lock which is acquired by the completion > > handler. we could get an ABBA deadlock that lockdep would be unable to see. > > > > There are other similar things; if you look at the remaining semaphore > > users in the kernel, you'll see the general pattern is that they're > > acquired in process context and then released in interrupt context. > > If we had a way to transfer ownership of the semaphore to a generic > > "interrupt context", they could become mutexes and lockdep could check > > that nothing else will cause a deadlock. > > Yes. Those are exactly what Cross-release feature solves. Those problems > can be achieved with Cross-release. But even with Cross-release, we > still cannot solve the problem of (1) readlock handling (2) and false > positives preventing further reporting. It's not just about lockdep for semaphores. Mutexes will spin if the current owner is still running, so to convert an interrupt-released semaphore to a mutex, we need a way to mark the mutex as being released by the new owner. I really don't think you want to report subsequent lockdep splats.