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=-3.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,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 12E48C433E0 for ; Tue, 19 May 2020 15:32:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C888E2075F for ; Tue, 19 May 2020 15:32:56 +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="rqp3GCwX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C888E2075F 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 5702980005; Tue, 19 May 2020 11:32:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 51FF2900002; Tue, 19 May 2020 11:32:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 435F680005; Tue, 19 May 2020 11:32:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id 2B3BD900002 for ; Tue, 19 May 2020 11:32:56 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E2331181AEF1F for ; Tue, 19 May 2020 15:32:55 +0000 (UTC) X-FDA: 76833861510.23.sort89_36a9f2bbcb861 X-HE-Tag: sort89_36a9f2bbcb861 X-Filterd-Recvd-Size: 4878 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Tue, 19 May 2020 15:32:55 +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-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 In-Reply-To: <7c540ac9-ba44-7187-5dc2-60b4c761e91c@linux.ibm.com> Content-Transfer-Encoding: quoted-printable 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, May 19, 2020 at 03:20:40PM +0200, Laurent Dufour wrote: > Le 19/05/2020 =E0 15:10, Michel Lespinasse a =E9crit=A0: > > On Mon, May 18, 2020 at 03:45:22PM +0200, Laurent Dufour wrote: > > > Le 24/04/2020 =E0 03:39, Michel Lespinasse a =E9crit=A0: > > > > 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 fut= ure. > > > >=20 > > > > 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(stru= ct etnaviv_gem_object *etnaviv_obj) > > > > struct etnaviv_gem_userptr *userptr =3D &etnaviv_obj->userptr= ; > > > > int ret, pinned =3D 0, npages =3D etnaviv_obj->base.size >> P= AGE_SHIFT; > > > > - might_lock_read(¤t->mm->mmap_sem); > > > > + might_lock_read(¤t->mm->mmap_lock); > > >=20 > > > Why not a mm_might_lock_read() new API to hide the mmap_lock, and a= dd it to > > > the previous patch? > >=20 > > 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... >=20 > 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 se= ries. 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 pat= h 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 lo= ng start, int nr_pages, FOLL_FORCE | FOLL_PIN | FOLL_GET))= ) return -EINVAL; =20 + might_lock_read(¤t->mm->mmap_lock); start =3D untagged_addr(start) & PAGE_MASK; addr =3D start; len =3D (unsigned long) nr_pages << PAGE_SHIFT;