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=-8.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable 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 56A4CC169C4 for ; Mon, 11 Feb 2019 20:39:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 239DE218A4 for ; Mon, 11 Feb 2019 20:39:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="lEHdGLTD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727460AbfBKUjT (ORCPT ); Mon, 11 Feb 2019 15:39:19 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42507 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726243AbfBKUjS (ORCPT ); Mon, 11 Feb 2019 15:39:18 -0500 Received: by mail-pf1-f196.google.com with SMTP id n74so105506pfi.9 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=mKGVya2fjxXOIx2aaE79M6759x1nX06yJvh3y7Fpxve91XwsASwHwu/fXRMhFpRDcl P601Paaw0B/2NtwVm0lHu52bimEgiDI/i1lGJzzD/7MpxLwwu2DNpGMZwEiva0Cgc2fg y84X3ruoPbVFSpcGtmtK7mY4H7vNV4wVdu3g4rj9AWWt2G6O3o83+Nd/Km6dTRhYiQy/ DODMwLOQxL6rm3Hwb3I+qZnHxYGV+L0kULTAG9uzVuGCkniRWelFwAochzpuyD5ywuil Hn4Mfbif6Bx9RNoRVb4Pt5cuX42WonZJ8f6it88CyCRYnwYdc9E5xpbm2+4dnKkWi4sT iB7Q== X-Gm-Message-State: AHQUAubMQwqcGmsyMIqO0utfSBkx7xjQxdaKrPUB+5LSYIqeh9+FMQ41 SnfFHgMxwvswgRXHj5V8BWe+nA== X-Google-Smtp-Source: AHgI3IbMSgV+Og1cgwCH3tEJ/kPJXOw9ltVSJm+RBFJMVVHZk30d9/NcXwyU987scjvfQpHKM+tRtw== 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: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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