Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3603371ybk; Tue, 19 May 2020 08:34:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwh0lwFtbYjZVC2FTZgByr8gnrixrst7BFS6ttrnect/FQgMyFl7ovgf+dTidnjqdxGhEIn X-Received: by 2002:a17:906:edd3:: with SMTP id sb19mr5870387ejb.39.1589902491077; Tue, 19 May 2020 08:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589902491; cv=none; d=google.com; s=arc-20160816; b=sz6zxGBYrnDhyyFHCt6wktly3+E563wXiW0XEBUawsTB6NMd1S7xsQaQit+ylgKPlG 9JQA8OBxp0eOzXZjS/Ip8H4FfIzMsVbxb1VI/vs1uyRjM9eafNSzcCIVoFG4UmgBtbAa AYhEBkfwgfhTFPEDZggHg5BRaavP0XCzWOjXJvxbzW39kcWq/bzvSEoH+UtvYbXsV9Ua rhPeS6xV8d2rWBKAys/yocwun9LVJlUAQ3aSmDz1wVprFW31xfygSQLbkgEePLGMpzc/ y7KpcRwYndvm4Zyc3O9Yr+KhE8p58TtW50gJy0hoCZGIda9ogblgxiXy5Cw0coZ9l/g3 b4jw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3Xn2vlHyiuSMza94Q4JCwVe0wgbzIeAHHFRAxO0Poak=; b=HPzCh3k/BKhE3TQCEzG8jnBObSr+/NMjWX0reF+5DMXMp6O7jgjBB3Ypp46G9FLdRz 0PGmdSl/OrS0URP9HpZ2lp9hdx/6ri2pZTxDGbusrlUGqje7MnXFwWKlmV1+g48jXqP3 RHR0HwNchjCBDIKMWyjTq/JHO91pUtdu3MAzwu+K0ppBbRWE/P3V9eQiMHNnQpOfDFId JyoCaWvEsFkzaH+7241WSsFbPxdIB1S3H+2Ar9bvQ0clJ0kgHOtofpJIXa3uQWhhgwl7 BkY6NNGqvUCinKJedCednnm8vuaaYXdbazYh+1Zp5LC0KYEO9H4BCy0LY7QJmiQDDIgF mVdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=rqp3GCwX; 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 qx12si72962ejb.340.2020.05.19.08.34.28; Tue, 19 May 2020 08:34:51 -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=rqp3GCwX; 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 S1729233AbgESPdA (ORCPT + 99 others); Tue, 19 May 2020 11:33:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728778AbgESPc7 (ORCPT ); Tue, 19 May 2020 11:32:59 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FF88C08C5C1 for ; Tue, 19 May 2020 08:32:56 -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-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=3Xn2vlHyiuSMza94Q4JCwVe0wgbzIeAHHFRAxO0Poak=; b=rqp3GCwXLRoiSgDjVGsREzzqh2 wsY53WRYBdnlRC/E1aZ/xzONTz5Cvr4/EKbfmuAbuVrshZxFIA74mEGtbnGXF2+0M6zk5HgIQ4ytW XqjjwqJLZUXMTd/5o3j77KRxZVUi4BCmomW86BmnTvbhW5zvaA3DGJM8KgEVnasgN3kcEcwBAWIH9 kGJX+8elPI7V5Ptg8Z1paawPRqH7K4/EJZ5PCvm5wJ+CdmCzNNk9eHc9PgaL8Zyzm/J76IEG/o6Qd ziQeEr/9rhLGICHGKhShkMI0jcWvZkGVzxqaNLdPL0bvqHCbvfWxtBsiSK/BO/V7Ni32xPQH/g4PB o7R1b8Ww==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jb4Ee-00067B-0U; Tue, 19 May 2020 15:32:52 +0000 Date: Tue, 19 May 2020 08:32:51 -0700 From: Matthew Wilcox To: Laurent Dufour Cc: Michel Lespinasse , Andrew Morton , linux-mm , LKML , Peter Zijlstra , Vlastimil Babka , Liam Howlett , Jerome Glisse , Davidlohr Bueso , David Rientjes , Hugh Dickins , Ying Han , Jason Gunthorpe , Daniel Jordan , John Hubbard Subject: Re: [PATCH v5.5 10/10] mmap locking API: rename mmap_sem to mmap_lock Message-ID: <20200519153251.GY16070@bombadil.infradead.org> References: <20200422001422.232330-1-walken@google.com> <20200422001422.232330-11-walken@google.com> <20200422015829.GR5820@bombadil.infradead.org> <20200423015917.GA13910@bombadil.infradead.org> <20200424012612.GA158937@google.com> <20200424013958.GC158937@google.com> <20200519131009.GD189720@google.com> <7c540ac9-ba44-7187-5dc2-60b4c761e91c@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7c540ac9-ba44-7187-5dc2-60b4c761e91c@linux.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 19, 2020 at 03:20:40PM +0200, Laurent Dufour wrote: > Le 19/05/2020 ? 15:10, Michel Lespinasse a ?crit?: > > On Mon, May 18, 2020 at 03:45:22PM +0200, Laurent Dufour wrote: > > > Le 24/04/2020 ? 03:39, Michel Lespinasse a ?crit?: > > > > Rename the mmap_sem field to mmap_lock. Any new uses of this lock > > > > should now go through the new mmap locking api. The mmap_lock is > > > > still implemented as a rwsem, though this could change in the future. > > > > > > > > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c > > > > index dc9ef302f517..701f3995f621 100644 > > > > --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c > > > > +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c > > > > @@ -661,7 +661,7 @@ static int etnaviv_gem_userptr_get_pages(struct etnaviv_gem_object *etnaviv_obj) > > > > struct etnaviv_gem_userptr *userptr = &etnaviv_obj->userptr; > > > > int ret, pinned = 0, npages = etnaviv_obj->base.size >> PAGE_SHIFT; > > > > - might_lock_read(¤t->mm->mmap_sem); > > > > + might_lock_read(¤t->mm->mmap_lock); > > > > > > Why not a mm_might_lock_read() new API to hide the mmap_lock, and add it to > > > the previous patch? > > > > I'm not sure why this is needed - we may rework the lock to be > > something else than rwsem, but might_lock_read should still apply to > > it and make sense ? I'm not sure what the extra API would bring... > > I guess at one time the API would become might_lock_read_a_range(), isn't it? > Furthermore this would hiding the lock's name which the goal of this series. I think this assertion should be deleted from this driver. It's there in case get_user_pages_fast() takes the mmap sem. It would make sense to have this assertion in get_user_pages_fast() in case we take the fast path which doesn't acquire the mmap_sem. Something like this: +++ b/mm/gup.c @@ -2754,6 +2754,7 @@ static int internal_get_user_pages_fast(unsigned long start, int nr_pages, FOLL_FORCE | FOLL_PIN | FOLL_GET))) return -EINVAL; + might_lock_read(¤t->mm->mmap_lock); start = untagged_addr(start) & PAGE_MASK; addr = start; len = (unsigned long) nr_pages << PAGE_SHIFT;