Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3039598imj; Mon, 11 Feb 2019 12:46:01 -0800 (PST) X-Google-Smtp-Source: AHgI3IaSF0/giAsHQO3m3YKFKB5JpHoGPgqrkud25pUhew0t+rXlw4AKCuRXltQxJJmXT2zBsS+g X-Received: by 2002:a63:4c4e:: with SMTP id m14mr107519pgl.173.1549917961529; Mon, 11 Feb 2019 12:46:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549917961; cv=none; d=google.com; s=arc-20160816; b=U5dBP59nLWcKgcKKRSLwR+tQ/FjIakaMap0sLZb9Qsz22umHYhOLwp/w96J4a0VWQ8 c+SYPOKlMnbEY7U3F9FVCX6KEynRwEGPNreI812XoYXk5Gy6jQ1/HiyQuenAZ2XDadJx LzyYMxWupk/q63uJ2TUmRiIKdjrab0t04IJXAARr5qBd8xvkGFAfCwyCwv1VMwcxep3Q PlHtqJ0RwrGiBDSmQfnNySSyQauFYdVNIENnBGpRp9OB3fUhM6bTNIVcXPpA3a7chyTI f3OJejhmsEmTh8wu2AcXqKT3g5vvY1saazIPM2K3ZxgCtenO4XIA72YIIaI5l09TtHct EMYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=P7ipRFd0lGsbjldrU5cPVYjS4TXNP1GlOAkJ0yUCCXI=; b=aNpnocIcewXnAhXHlj74/Y877vB8s4np6skenH4wdSD70P+bCKpcN7vgbq3wqgxyJB q42aZRLKDiPwi1xkRd9dBhAh6/A3vCY+d84sF0QPVhlmxolOXQ3qyXKeaScKbFKx8hvZ OAxlRybnhyaV25AAFXWVlqRqMQlBCxUeYHD2cxEdr7BXAfUilBT/LJqO48X0tRMfGJ0N 9GJ72GlG5h6h7V4Ae1gkTbRzjaC3s8LoklvtCHRxcqCsoJ8hmTNe7ZvoptabUXyGw0+P Q/cg8FSsv+xL5Jr/GOyOWdraAwfcBpFJR8dOPvKHHx48W1BYqKMBF6MRmOpglElnx88d LlPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=lEHdGLTD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72si11203064plb.224.2019.02.11.12.45.45; Mon, 11 Feb 2019 12:46:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=lEHdGLTD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727499AbfBKUjT (ORCPT + 99 others); Mon, 11 Feb 2019 15:39:19 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43464 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727356AbfBKUjS (ORCPT ); Mon, 11 Feb 2019 15:39:18 -0500 Received: by mail-pf1-f194.google.com with SMTP id q17so103747pfh.10 for ; Mon, 11 Feb 2019 12:39:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=P7ipRFd0lGsbjldrU5cPVYjS4TXNP1GlOAkJ0yUCCXI=; b=lEHdGLTDe+z9XOLq92061yRszuQ30L0Ah2rmiBbRpewl+TcyLhd4uxI4utvOvqyaI2 aj7uUuX092yr34YJFyYkt43rtb2Dkfumt2dbyWXGRWWzWz+mQH0n4KTPptuX0vmorWcU 1W/+eazIscUyvxqV3K5ydoWP/wMD9KxZf9OYLLotNpA6ZOOGTYWv10ulE12tdrSoJjen a+l3YkwfqqnVqdLyeRlfhC2S4LulZqlNGf3+NZZS6ipLnh30ZGDMnZJfMHV+zx8QMtqX yAp75P/0zxF3T+6bl4zNzfa24iMzHvsrXSC5noAUxB++IktCPa99pDvyTnh8U3xFfhyM eZ6Q== 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:user-agent; bh=P7ipRFd0lGsbjldrU5cPVYjS4TXNP1GlOAkJ0yUCCXI=; b=rQ/vlTgUWJPj+Pj7Gf8fVOzBhyhjq0L0wuZmujb1yq36AfLWuE99sPt68i11rnhbYq +xEfITbmR6GMYcEYa+BN6OGVvBN4kdJrihBTSxaFP64gikxoysQ3n3nDXKt1FsvkLdMn Wht/lQfRfMT3/Xdux05IkVy4s2DTCcd/3jRRiOaI3OBp+DGTnligjSNXA7rFMG5NBeGj V6HWX0ArspR/WPBlto/xxOOs5DpSksJTHWwuqC7w7aAMMNvwe80C0QZDr8z+Mj/IsHjw 04jjOhajYapL2Oyn5KoGamaOwSyQufLf5nsOTn2TSu/Lk4qHQ7nV025woDNP1dZGau0H 6MEA== X-Gm-Message-State: AHQUAubHsuf/0btrtp1f3gLOK/GpIPWR9PU23g3FB1IRAyFqdlSXz0pf o33OmeEl7+NiUSUNS9BAlxndtQ== X-Received: by 2002:a63:eb49:: with SMTP id b9mr115173pgk.196.1549917557390; Mon, 11 Feb 2019 12:39:17 -0800 (PST) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id b13sm22468326pfj.66.2019.02.11.12.39.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Feb 2019 12:39:16 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1gtIMG-0000kK-7Q; Mon, 11 Feb 2019 13:39:16 -0700 Date: Mon, 11 Feb 2019 13:39:16 -0700 From: Jason Gunthorpe To: ira.weiny@intel.com Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Daniel Borkmann , Davidlohr Bueso , netdev@vger.kernel.org, Mike Marciniszyn , Dennis Dalessandro , Doug Ledford , Andrew Morton , "Kirill A. Shutemov" , Dan Williams Subject: Re: [PATCH 2/3] mm/gup: Introduce get_user_pages_fast_longterm() Message-ID: <20190211203916.GA2771@ziepe.ca> References: <20190211201643.7599-1-ira.weiny@intel.com> <20190211201643.7599-3-ira.weiny@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190211201643.7599-3-ira.weiny@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 11, 2019 at 12:16:42PM -0800, ira.weiny@intel.com wrote: > From: Ira Weiny > > Users of get_user_pages_fast are not protected against mapping > pages within FS DAX. Introduce a call which protects them. > > We do this by checking for DEVMAP pages during the fast walk and > falling back to the longterm gup call to check for FS DAX if needed. > > Signed-off-by: Ira Weiny > include/linux/mm.h | 8 ++++ > mm/gup.c | 102 +++++++++++++++++++++++++++++++++++---------- > 2 files changed, 88 insertions(+), 22 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 80bb6408fe73..8f831c823630 100644 > +++ b/include/linux/mm.h > @@ -1540,6 +1540,8 @@ long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages, > long get_user_pages_longterm(unsigned long start, unsigned long nr_pages, > unsigned int gup_flags, struct page **pages, > struct vm_area_struct **vmas); > +int get_user_pages_fast_longterm(unsigned long start, int nr_pages, bool write, > + struct page **pages); > #else > static inline long get_user_pages_longterm(unsigned long start, > unsigned long nr_pages, unsigned int gup_flags, > @@ -1547,6 +1549,11 @@ static inline long get_user_pages_longterm(unsigned long start, > { > return get_user_pages(start, nr_pages, gup_flags, pages, vmas); > } > +static inline int get_user_pages_fast_longterm(unsigned long start, int nr_pages, > + bool write, struct page **pages) > +{ > + return get_user_pages_fast(start, nr_pages, write, pages); > +} > #endif /* CONFIG_FS_DAX */ > > int get_user_pages_fast(unsigned long start, int nr_pages, int write, > @@ -2615,6 +2622,7 @@ struct page *follow_page(struct vm_area_struct *vma, unsigned long address, > #define FOLL_REMOTE 0x2000 /* we are working on non-current tsk/mm */ > #define FOLL_COW 0x4000 /* internal GUP flag */ > #define FOLL_ANON 0x8000 /* don't do file mappings */ > +#define FOLL_LONGTERM 0x10000 /* mapping is intended for a long term pin */ If we are adding a new flag, maybe we should get rid of the 'longterm' entry points and just rely on the callers to pass the flag? Jason