Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp225089ybz; Tue, 21 Apr 2020 19:21:02 -0700 (PDT) X-Google-Smtp-Source: APiQypIUj2gTORFsatyEILQeGzdY47NZJoTPvZo8j1rc7OgDti7fhtxNkYHl/y6xnEx8r+FJH/7k X-Received: by 2002:a17:906:9718:: with SMTP id k24mr5817237ejx.229.1587522062786; Tue, 21 Apr 2020 19:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587522062; cv=none; d=google.com; s=arc-20160816; b=wdb3+jHrM8HO8nBI7anawUVLGVZFygcjgcR4Zgfm0yL532U+LrdeXhvvbufHo9Gp1A awWzzop40eHOSRPmtaGMFdbcZw7+sZEgNkgAA2qsvee9VqG0ZcL6+Fbi5eheBGINI7GQ bFrGeqrIm4v2ChZ10f1y7EmSvpB3NmDneNfbx3ixxCwiOTbQadOmhkWvmj1yRaWQh/uZ LBb0znWWzlCE5dMrTWhIxkyUudMh+Q3VKk3ckkbtrtkq+/UDeryyvcyqsLyJ1OL+Rvqq sz2pWjLLgUqy+EC3OiiEwEGnfgZ7qv9ki0JCY4Cw8AyHx/NV2TNjP2G66+Mh4cCZd84q WzIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=huampyiQ/nfH+0rWduVv/3eKAYSafHdbdxfLLYXUAX8=; b=u9szJIjcWB6lN0oU33wKSvC/aQUeomflYnvVosOH7hNZuMEqpoN9llV8NWdvwN77S7 3PG41dXIy6uXoIZkl7JKtJw10cbgmp41zCRi7gLXImzz2z0jkH3CoLmUBjdgVb3nDiTo DYql/4/3DEgGASwMTz+37oyJ48Spk4+HWB+WfvvmGb7duHFMnpqo4AUDtIpVLZXLszrw 4CEZSH3TVEMcMXth1mMvgTkD59gAvrx5d6Vsd02192d7jKD6dYum4HUDJ2wAuRzVr3h5 dIIVV+Fd8Ggn1WqxojURzVFUQceiAw6t7U6U5MU9M6XFd3CCpY3AUtSmf94KUw6/yQXa WpQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ognTxkwz; 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 dn14si3620963ejc.261.2020.04.21.19.20.36; Tue, 21 Apr 2020 19:21:02 -0700 (PDT) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ognTxkwz; 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 S1726379AbgDVCSy (ORCPT + 99 others); Tue, 21 Apr 2020 22:18:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgDVCSy (ORCPT ); Tue, 21 Apr 2020 22:18:54 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E88E7C0610D6 for ; Tue, 21 Apr 2020 19:18:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=huampyiQ/nfH+0rWduVv/3eKAYSafHdbdxfLLYXUAX8=; b=ognTxkwzauShK1Y06l8uXWZW2Z aN2LnetxIUAr6zpPQDdcWn5A7gC0vSkRMgUIClWSnfLQt15emgforT9g23jHpygmGDCZ8oiK+O5o1 rJHcfts830zd+R+KBYvma+DlOQVDZDuOp11PInp46f8XH5DmN8u0OidGNhvvtDQ1wTZif3Bd3luJM HkMZjCWpwmbMJRgBInbiEf27TKwNWxxSljiOvLfQcQYrLGfbSGZde4J6Y699zIqkxwaVCwLYJ+S0n 9Gqv9G5sWnRWIpBLi3AH3VKHra/vKPEw6CmHYPM6f6sS5coAHW6uMPs9CHCk+E63XyL2YPVHQUdC6 ywX5ZlMQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jR4yQ-0005y7-MS; Wed, 22 Apr 2020 02:18:50 +0000 Date: Tue, 21 Apr 2020 19:18:50 -0700 From: Matthew Wilcox To: Michel Lespinasse Cc: Andrew Morton , linux-mm , LKML , Peter Zijlstra , Laurent Dufour , Vlastimil Babka , Liam Howlett , Jerome Glisse , Davidlohr Bueso , David Rientjes , Hugh Dickins , Ying Han , Jason Gunthorpe , Daniel Jordan Subject: Re: [PATCH v5 09/10] mmap locking API: add mmap_assert_locked Message-ID: <20200422021850.GS5820@bombadil.infradead.org> References: <20200422001422.232330-1-walken@google.com> <20200422001422.232330-10-walken@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 21, 2020 at 07:10:39PM -0700, Michel Lespinasse wrote: > On Tue, Apr 21, 2020 at 5:14 PM Michel Lespinasse wrote: > > +static inline void mmap_assert_locked(struct mm_struct *mm) > > +{ > > + if (IS_ENABLED(CONFIG_LOCKDEP) && debug_locks) > > + VM_BUG_ON_MM(!lockdep_is_held(&mm->mmap_sem), mm); > > + else > > + VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_sem), mm); > > +} > > Turns out this function definition does not work for !CONFIG_LOCKDEP > as lockdep_is_held is not defined in that case. Oops, sorry. It only defines #define lockdep_is_held_type(l, r) (1) #define lockdep_assert_held(l) do { (void)(l); } while (0) #define lockdep_assert_held_write(l) do { (void)(l); } while (0) #define lockdep_assert_held_read(l) do { (void)(l); } while (0) #define lockdep_assert_held_once(l) do { (void)(l); } while (0) which seems like an oversight, but not one that you should be fixing. > The following should work instead: > > static inline void mmap_assert_locked(struct mm_struct *mm) > { > #ifdef CONFIG_LOCKDEP > if (debug_locks) { > VM_BUG_ON_MM(!lockdep_is_held(&mm->mmap_lock), mm); > return; > } > #endif > VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_lock), mm); > } Yes, I agree.