Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756506AbdLOVPb (ORCPT ); Fri, 15 Dec 2017 16:15:31 -0500 Received: from imap.thunk.org ([74.207.234.97]:51408 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755802AbdLOVP2 (ORCPT ); Fri, 15 Dec 2017 16:15:28 -0500 Date: Fri, 15 Dec 2017 16:15:01 -0500 From: "Theodore Ts'o" To: Byungchul Park Cc: Ingo Molnar , Thomas Gleixner , Peter Zijlstra , david@fromorbit.com, willy@infradead.org, Linus Torvalds , Amir Goldstein , byungchul.park@lge.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, oleg@redhat.com Subject: Re: [PATCH] locking/lockdep: Remove the cross-release locking checks Message-ID: <20171215211501.v6x6o2ft4khqgbgy@thunk.org> Mail-Followup-To: Theodore Ts'o , Byungchul Park , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , david@fromorbit.com, willy@infradead.org, Linus Torvalds , Amir Goldstein , byungchul.park@lge.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, oleg@redhat.com References: <20171213104617.7lffucjhaa6xb7lp@gmail.com> <20171215062428.5dyv7wjbzn2ggxvz@thunk.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2115 Lines: 40 On Fri, Dec 15, 2017 at 05:39:25PM +0900, Byungchul Park wrote: > > All locks should belong to one class if each path of acquisition > can be switchable each other within the class at any time. > Otherwise, they should belong to a different class. OK, so let's go back to my case of a Network Block Device with a local file system mounted on it, which is then exported via NFS. So an incoming TCP packet can go into the NFS server subsystem, then be processed by local disk file system, which then does an I/O operation to the NBD device, which results in an TCP packet being sent out. Then the response will come back over TCP, into the NBD block layer, then into the local disk file system, and that will result in an outgoing response to the TCP connection for the NFS protocol. In order to avoid cross release problems, all locks associated with the incoming TCP connection will need to be classified as belonging to a different class as the outgoing TCP connection. Correct? One solution might be to put every single TCP connection into a separate class --- but that will explode the number of lock classes which Lockdep will need to track, and there is a limited number of lock classes (set at compile time) that Lockdep can track. So if that doesn't work, we will have to put something ugly which manually makes certain TCP connections "magic" and require them to be put into a separate class than all other TCP connections, which will get collapsed into a single class. Basically, any TCP connection which is either originated by the kernel, or passed in from userspace into the kernel and used by some kernel subsystem, will have to be assigned its own lockdep class. If the TCP connection gets closed, we don't need to track that lockdep class any more. (Or if a device mapper device is torn down, we similarly don't need any unique lockdep classes created for that device mapper device.) Is there a way to tell lockdep that a set of lockdep classes can be released so we can recover the kernel memory to be used to track some new TCP connection or some new device mapper device? - Ted