From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB5D8C55181 for ; Wed, 22 Apr 2020 02:18:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6E0E6206D4 for ; Wed, 22 Apr 2020 02:18:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ognTxkwz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E0E6206D4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2494E8E0006; Tue, 21 Apr 2020 22:18:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 220B48E0003; Tue, 21 Apr 2020 22:18:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15E3E8E0006; Tue, 21 Apr 2020 22:18:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0172.hostedemail.com [216.40.44.172]) by kanga.kvack.org (Postfix) with ESMTP id F3A378E0003 for ; Tue, 21 Apr 2020 22:18:54 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B66E0181AEF07 for ; Wed, 22 Apr 2020 02:18:54 +0000 (UTC) X-FDA: 76733882988.19.clam69_87faf70462521 X-HE-Tag: clam69_87faf70462521 X-Filterd-Recvd-Size: 3593 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Wed, 22 Apr 2020 02:18:54 +0000 (UTC) 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: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.