Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp945591pxy; Fri, 30 Apr 2021 22:23:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwh8lMKgPWdfE1x4KJzV+mRDpUpWCJCt/i4hqjk0Iah9p3UYfs/V7bzI/c+AX4kdNSp1JTa X-Received: by 2002:aa7:dd96:: with SMTP id g22mr9991133edv.222.1619846609823; Fri, 30 Apr 2021 22:23:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619846609; cv=none; d=google.com; s=arc-20160816; b=Wuqzkg9gwjEQ+/ATcFw1KfL8xng/2cAvl9rTNU0Jc4dwDaL1+11M/nfhBzJ4jDv7q6 qgdvEuxyXo5llRtEwDeIodScViHU139xPaDuOO43Z0iSl5vaCWZ5eiithovekNzSLT6/ KR3wMxAxjOHhWOvS7/H2XcwkXrVy3GSEFPrQzPWR8oXbCFQRM5ehS02QOvkmZ0xax+mh P+rdfv0qqKQt7zN0V17sZvjsKwMcaIXioIEEy+N528SyXLUUvrbtWQV/Ulae0xftwgmq j5qOUe03uwcaM33GXzrD2nEH6CvVj69w6mkYfAr0Z9TgK0RebSJkdSUF1eO0FSPf76hZ b7GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=y5NDAMNkqEQN+DhaIS4czZiHJbkGLVl9eO9bf3NbPes=; b=UrHoUkqxkjmw+UKVgmvlQlR344fPXQBSFu1Hegeb2ukJTAp3N55cymngb1nLJFR7sJ TUOa9BxSb00Ao/D9b5Nes9N5ctA0ktV6Kxnn9UdCTLLUyZl15UtUeJTc8yaJV3BEJMbh Z3fEi6Zxduq8yMpEF/PwcfJIN7UNBt3YwasKd7bnkppBEKMwT40r+5WSbQM2tQ8Cg283 guj1j9lr9E0TffLgQ0PYBWu497tKbIMt8e66lhEWWMJBudna9pRzrb9iIYoz3iRgbMbI W2SIzp5eHSLTvgcJkwsft8rxikCgbCOE7EjS48blLI0YTgz5UJmWoxfbf+Gh5O/601ss sc1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org header.b=d26776rJ; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-14-rsa header.b=J2N9FzB4; 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=NONE sp=NONE dis=NONE) header.from=lespinasse.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qq6si5216435ejb.221.2021.04.30.22.22.53; Fri, 30 Apr 2021 22:23:29 -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=neutral (no key) header.i=@lespinasse.org header.b=d26776rJ; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-14-rsa header.b=J2N9FzB4; 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=NONE sp=NONE dis=NONE) header.from=lespinasse.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229640AbhEAFOU (ORCPT + 99 others); Sat, 1 May 2021 01:14:20 -0400 Received: from server.lespinasse.org ([63.205.204.226]:38817 "EHLO server.lespinasse.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbhEAFOT (ORCPT ); Sat, 1 May 2021 01:14:19 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-14-ed; t=1619846010; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from; bh=y5NDAMNkqEQN+DhaIS4czZiHJbkGLVl9eO9bf3NbPes=; b=d26776rJ7CxLjaYFLa39ODat8Cb2o45ViKsb9LZHM/qVaC2LiL4y7mGErDo4zpHsOoDLo T7RjmfCbqlcUbvZAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-14-rsa; t=1619846010; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from; bh=y5NDAMNkqEQN+DhaIS4czZiHJbkGLVl9eO9bf3NbPes=; b=J2N9FzB4wMBqJXqsTSk+YJm0WKiz+StpiFOA3Q59lYNrNNWBwjP15sLL/PZUp6uhNROY9 PKBXHL5hoPJ3S/OyIKAQZM52pbZAA+J1ydTwLQl3mDynHDwk9zmYb+zvP2AknPL9/mGs7ie JAjTbp0REjFl7rctEh9C/AyZyDT2xwKC/jOqnX09ijjIs1V4daIauq07JgA7NOxDlXzgm8W 7DCQixl2vcjP8VDy3R+2MjRHPce/RDMl7AdfIc1UyUHVGlOXEobA4z2D+WebNfgEmcf8qSQ 9uIrdSnjxqIIYwOOyLTs27+IsxVYroeoF1WclQ45epZURRNNr3m3xV6rIWCg== Received: by server.lespinasse.org (Postfix, from userid 1000) id 4E71D160324; Fri, 30 Apr 2021 22:13:30 -0700 (PDT) Date: Fri, 30 Apr 2021 22:13:30 -0700 From: Michel Lespinasse To: Liam Howlett Cc: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton , Song Liu , Davidlohr Bueso , "Paul E . McKenney" , Matthew Wilcox , Laurent Dufour , David Rientjes , Axel Rasmussen , Suren Baghdasaryan , Vlastimil Babka , Rik van Riel , Peter Zijlstra , Michel Lespinasse Subject: Re: [PATCH 38/94] mm/gup: Add mm_populate_vma() for use when the vma is known Message-ID: <20210501051330.GC5188@lespinasse.org> References: <20210428153542.2814175-1-Liam.Howlett@Oracle.com> <20210428153542.2814175-39-Liam.Howlett@Oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210428153542.2814175-39-Liam.Howlett@Oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 28, 2021 at 03:36:08PM +0000, Liam Howlett wrote: > When a vma is known, avoid calling mm_populate to search for the vma to > populate. > > Signed-off-by: Liam R. Howlett > --- > mm/gup.c | 20 ++++++++++++++++++++ > mm/internal.h | 4 ++++ > 2 files changed, 24 insertions(+) > > diff --git a/mm/gup.c b/mm/gup.c > index c3a17b189064..48fe98ab0729 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -1468,6 +1468,26 @@ long populate_vma_page_range(struct vm_area_struct *vma, > NULL, NULL, locked); > } > > +/* > + * mm_populate_vma() - Populate a single range in a single vma. > + * @vma: The vma to populate. > + * @start: The start address to populate > + * @end: The end address to stop populating > + * > + * Note: Ignores errors. > + */ > +void mm_populate_vma(struct vm_area_struct *vma, unsigned long start, > + unsigned long end) > +{ > + struct mm_struct *mm = current->mm; > + int locked = 1; > + > + mmap_read_lock(mm); > + populate_vma_page_range(vma, start, end, &locked); > + if (locked) > + mmap_read_unlock(mm); > +} > + This seems like a nonsensical API at first glance - VMAs that are found in the vma tree might be modified, merged, split, or freed at any time if the mmap lock is not held, so the API can not be safely used. I think this applies to maple tree vmas just as much as it did for rbtree vmas ? -- Michel "walken" Lespinasse