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=-6.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 C0210C433E0 for ; Sun, 31 May 2020 13:03:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7EF96206F1 for ; Sun, 31 May 2020 13:03:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZdoyKIUQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EF96206F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 202DF80007; Sun, 31 May 2020 09:03:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B64F8E0003; Sun, 31 May 2020 09:03:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C87C80007; Sun, 31 May 2020 09:03:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id E62938E0003 for ; Sun, 31 May 2020 09:03:25 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A5DC98B4BB for ; Sun, 31 May 2020 13:03:25 +0000 (UTC) X-FDA: 76877030370.30.curve84_1de3e212df705 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 8E297180B3C85 for ; Sun, 31 May 2020 13:03:25 +0000 (UTC) X-HE-Tag: curve84_1de3e212df705 X-Filterd-Recvd-Size: 5592 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Sun, 31 May 2020 13:03:25 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id u13so8225106wml.1 for ; Sun, 31 May 2020 06:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BqhV+NqZNeQJy9937H6t2fNsaGUaVeO+uIzbSmUO5Ek=; b=ZdoyKIUQ6bcXIf1i6U4D+OAZlSfSrJNiPoMSOihkOAV7j3NcygRhNyaVSJezcTOo3D f+qVVkKojLorSAUDNc8ULzuj13GZmrmEJVssVqarWQscJCnQBX96HcqBCj6xnfvMieiV 4t/DoVi5ez44ie2MCnraH6uHCJykNeEt+McehD0k6A2qrcpsVT84w0sN3vP8sMeAfcXf /Qk3wAT3OJGX6VLKSJSQ3uzQKrHHJfWpd+uq7gKJutLrk3vzV8XyElv5zMVpuUQSXgVR AgpTSrUw0tCR53bDMF8jtQwTvWZPmLAKGSavyrgy1k1P9N2qAFpCHIgKV0wCjaotPlpO sI2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BqhV+NqZNeQJy9937H6t2fNsaGUaVeO+uIzbSmUO5Ek=; b=V/aKnSRvx/B8MDJZ0AvYorH1VTXXY0c03jeRsOQen1v/8ymTRI7uh84AXCxr85N4/X 5oNaq76awZcEd1H2POFgyp7+mf79JH3dHtrHXMPREvOTQpQ/sSYiHpwRnsvs64O8izML QU7LqymqFNEnlqdLXbsnKrgt8Sdc4zZvjHeJFV3DzaiMBHg+ALNXlBkvZA2sGEchCb4A HVsthiGfN2tCWkGnbhYMTl0m2/mbgFGFGmbgFTVNKWfDp/NjM6nJtpG42YFvlZDQQxM6 O78wOwljzQ1pkGAGg+SFTxJDntGYi00DE3u8w0SBiaJXHwXjIXT3vGOKcX0UVSelnM52 akjg== X-Gm-Message-State: AOAM531oHeXcuCK76CKWQ8AYeuwxVLYRqS3eDsiX46Dzu4Ww6BTo6ekq 8cGkij2Fpo8tTz0uxaeTKshy+/k2Sl9adI36yg41FqK+ND8= X-Google-Smtp-Source: ABdhPJyNmQucopa1ZwtxV6TDL6Cfs17/jBM8pu98SVjDcwNIJ5V7kCklaKZ2TDvVGxS9N9qym5HI6MNxnmUufw9zy9g= X-Received: by 2002:a7b:c090:: with SMTP id r16mr18302534wmh.105.1590930204261; Sun, 31 May 2020 06:03:24 -0700 (PDT) MIME-Version: 1.0 References: <20200527223243.884385-1-jhubbard@nvidia.com> <20200527223243.884385-2-jhubbard@nvidia.com> In-Reply-To: <20200527223243.884385-2-jhubbard@nvidia.com> From: Pankaj Gupta Date: Sun, 31 May 2020 15:03:13 +0200 Message-ID: Subject: Re: [PATCH 1/2] mm/gup: introduce pin_user_pages_locked() To: John Hubbard Cc: Andrew Morton , LKML , Linux MM Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 8E297180B3C85 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: Acked-by: Pankaj Gupta On Thu, 28 May 2020 at 00:32, John Hubbard wrote: > > Introduce pin_user_pages_locked(), which is nearly identical to > get_user_pages_locked() except that it sets FOLL_PIN and rejects > FOLL_GET. > > Signed-off-by: John Hubbard > --- > include/linux/mm.h | 2 ++ > mm/gup.c | 30 ++++++++++++++++++++++++++++++ > 2 files changed, 32 insertions(+) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 98be7289d7e9..d16951087c93 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1700,6 +1700,8 @@ long pin_user_pages(unsigned long start, unsigned long nr_pages, > struct vm_area_struct **vmas); > long get_user_pages_locked(unsigned long start, unsigned long nr_pages, > unsigned int gup_flags, struct page **pages, int *locked); > +long pin_user_pages_locked(unsigned long start, unsigned long nr_pages, > + unsigned int gup_flags, struct page **pages, int *locked); > long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages, > struct page **pages, unsigned int gup_flags); > long pin_user_pages_unlocked(unsigned long start, unsigned long nr_pages, > diff --git a/mm/gup.c b/mm/gup.c > index 2f0a0b497c23..17418a949067 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -2992,3 +2992,33 @@ long pin_user_pages_unlocked(unsigned long start, unsigned long nr_pages, > return get_user_pages_unlocked(start, nr_pages, pages, gup_flags); > } > EXPORT_SYMBOL(pin_user_pages_unlocked); > + > +/* > + * pin_user_pages_locked() is the FOLL_PIN variant of get_user_pages_locked(). > + * Behavior is the same, except that this one sets FOLL_PIN and rejects > + * FOLL_GET. > + */ > +long pin_user_pages_locked(unsigned long start, unsigned long nr_pages, > + unsigned int gup_flags, struct page **pages, > + int *locked) > +{ > + /* > + * FIXME: Current FOLL_LONGTERM behavior is incompatible with > + * FAULT_FLAG_ALLOW_RETRY because of the FS DAX check requirement on > + * vmas. As there are no users of this flag in this call we simply > + * disallow this option for now. > + */ > + if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM)) > + return -EINVAL; > + > + /* FOLL_GET and FOLL_PIN are mutually exclusive. */ > + if (WARN_ON_ONCE(gup_flags & FOLL_GET)) > + return -EINVAL; > + > + gup_flags |= FOLL_PIN; > + return __get_user_pages_locked(current, current->mm, start, nr_pages, > + pages, NULL, locked, > + gup_flags | FOLL_TOUCH); > +} > +EXPORT_SYMBOL(pin_user_pages_locked); > + > -- > 2.26.2 > >