From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754543AbeAQQds (ORCPT ); Wed, 17 Jan 2018 11:33:48 -0500 Received: from merlin.infradead.org ([205.233.59.134]:34964 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754375AbeAQQdq (ORCPT ); Wed, 17 Jan 2018 11:33:46 -0500 Date: Wed, 17 Jan 2018 17:33:10 +0100 From: Peter Zijlstra To: Matthew Wilcox Cc: Ingo Molnar , "David S. Miller" , Matthew Wilcox , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/3] lockdep: Allow checking a read-only lock Message-ID: <20180117163310.GB2249@hirez.programming.kicks-ass.net> References: <20180117151414.23686-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180117151414.23686-1-willy@infradead.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 17, 2018 at 07:14:11AM -0800, Matthew Wilcox wrote: > From: Matthew Wilcox > > I am not for one moment suggesting that the concept of a read-only lock > makes sense. You can't sensibly put one in ROM or in read-only mappings. > What does make sense is some APIs want to specify a const pointer to > indicate that they do not modify the object being pointed to. One example > we have of this today is in the networking stack; tcp_md5_do_lookup takes > a const struct sock * argument and wants to ensure that the caller either > took the socket lock or the rcu lock. > > At the moment, tcp_md5_do_lookup() is actually lying to its callers; > lockdep_sock_is_held() casts away the constness of the pointer because > lockdep actually does modify the lock when checking whether it's held > (under rare and unnecessary conditions). > > Fix this situation by (patch 1) only assigning a lock key on registration, > not on check, (patch 2) marking the pointers in the lockdep check path > as const and (patch 3) converting a few of the callers to themselves > be const, removing the nasty hack in lockdep_sock_is_held(). > Seems OK. Acked-by: Peter Zijlstra (Intel) Ingo can you make that happen?