Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp77419ybz; Thu, 23 Apr 2020 18:46:58 -0700 (PDT) X-Google-Smtp-Source: APiQypKgkclSYr5fIMtvrGEryECQdJBTd1W1iZ/lTkEkfPIvuQbIYFqpc4nZuWy5cGn/ybk9O0Fu X-Received: by 2002:aa7:c3c2:: with SMTP id l2mr5324923edr.362.1587692818124; Thu, 23 Apr 2020 18:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587692818; cv=none; d=google.com; s=arc-20160816; b=S8iuXn0kwE3J30c1SXuIiki+/N8pXrQAr5dce/5IXmfihOmKr/G0hcgXOKpYYnu5UZ DBo3o8czRpdUeJtr5yaHY9VVE7u95YwILPKTIc5Q2GvWVMpzZclPp7gjT59txcgMKlXf PbJKWJ500bxR8y49yXS47iPCMfY4/aua0NBFh47b5NEKDcYchTARj2fgujFTYqgNmYrZ uxhbe+55BO+egmDhY7mo4OqHvW95KflSeUdmDEbSbtUe3DSF8UHNIW205SVRNCpynfet JyW/ltI2vAgrX8Ie1WUEPr+lmlM+RTjplzW2SMGeRflcPPXmXe5WPvWx8oQzU7xWCua7 RcDA== 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=pSqeJ5EgdhEUYq/5PiKiFsCIJkBQmBkYz7RsM9vACbM=; b=Qgg1/qL9eHSgBK3li56CR6VRQx+a/j+DoDfdr8akzv276dqYNrmIoAiMX2YvaZLQ9O lz3mRnSMqk8UjcroZmydhEgSIhkX4wAMtmQvX9E65pPt/swDD2wzzVFH0z+Rx8sGCw2I td4bBKI5nll5bVC/V0wXrXHR8WQT0ZVXiMyb4VwH08nYC736CuLXWl80r9X8p/3MbB1U oltDw7TvIkMtrMmjJqn2qaJ7Cr5+6wWEw8/2vQaiUalPYeHXqXZ+OcJnJmI4qZu7gAtU V0BejOYI1BYLikKHEo4WvzFDdFTYlXsmGPloiHbrrFUrqSUJbyhEDjHOxS2iyksAPx3M kq0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=udSdbqxp; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k17si2176426ejj.219.2020.04.23.18.46.34; Thu, 23 Apr 2020 18:46:58 -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=pass header.i=@google.com header.s=20161025 header.b=udSdbqxp; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726021AbgDXBo5 (ORCPT + 99 others); Thu, 23 Apr 2020 21:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725884AbgDXBo5 (ORCPT ); Thu, 23 Apr 2020 21:44:57 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9623C09B042 for ; Thu, 23 Apr 2020 18:44:55 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id 145so3987936pfw.13 for ; Thu, 23 Apr 2020 18:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=pSqeJ5EgdhEUYq/5PiKiFsCIJkBQmBkYz7RsM9vACbM=; b=udSdbqxp70VPrgUbVyag1+rsW6qg2OpecWf95x9vJnJGSlkyevj1rJu43WToLgr1AD DQQtHOHEejtogMj2p9q+K870sYiE4hHXHGvLScCVyEHsSQl6VzrPXei4pRtFQ80AVMD3 5B6Tkoa/GGyG7tgTgFe/JCTFgXYBesFkOyDjmPli2FiJ620J3AutzVCcNM45g74q2cyn DNl22Tvg/tt6CsdYgQn+IxLmYuwBlvvzzV/Gyl3TAgJHUHWNrRbqZgty3dM+YKAE6Wtf rZmQ1VLywDKf0exbZwkVX0cWujaZDop9TA9KdBb3u0fk7okRI+TqfWdsZ5WjpavuoRoP ciVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=pSqeJ5EgdhEUYq/5PiKiFsCIJkBQmBkYz7RsM9vACbM=; b=oPsxCEmJEw0OieedP0PyjMEV0jCi7RI9GpsFxVfWN0St3Pr5e1uQ7zWT6dpXhaoXKQ ul3y8QWbFgOmOsAx+qUGuGc7ftJWZwjL/SntIR8urpvmoocaCu+bHu+XTL0yjOoikRg9 mqPs0MUlBHFbE4Ds9kmloVptRE8YMae5ZzO+dSuB68LVavOLKioLwDKn0rF4a+OAyUKw V4tZeAHDehDXqs3F5lyuLgIv3O3nxOyyMTLW2OmFKe6xuZhxrq6BbNTD2aEj6T657EAM LoUDuMGAfjKiFQek2CP4CyczqOnDs6HpA6tbHxQogRroA3QYSgwk7eBf9g9sAVE5mMNZ OMGg== X-Gm-Message-State: AGi0PuYI86+3ZfLmr+a8hCw9wW3bXnLyzR2Rl73LUEDrPZr8LrnFM2Gh XFdHGy7l3vFF3rq/BawRZZF/OQ== X-Received: by 2002:a63:f64d:: with SMTP id u13mr6625326pgj.151.1587692694955; Thu, 23 Apr 2020 18:44:54 -0700 (PDT) Received: from google.com ([2620:15c:2cd:202:2523:d194:de3b:636f]) by smtp.gmail.com with ESMTPSA id c3sm3864956pfa.160.2020.04.23.18.44.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 18:44:53 -0700 (PDT) Date: Thu, 23 Apr 2020 18:44:51 -0700 From: Michel Lespinasse To: Matthew Wilcox 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: <20200424014451.GD158937@google.com> References: <20200422001422.232330-1-walken@google.com> <20200422001422.232330-10-walken@google.com> <20200422021850.GS5820@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200422021850.GS5820@bombadil.infradead.org> 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:18:50PM -0700, Matthew Wilcox wrote: > 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. Sent an updated version of this (also integrating your feedback on patch 10/10) Please look for it under subject: [PATCH v5.5 09/10] mmap locking API: add mmap_assert_locked() and mmap_assert_write_locked() -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies.