Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp2020411ybm; Sun, 31 May 2020 06:07:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDXiSKvebmQ4pB5bP6K6ZAKzGHQdJfJjbAHStUntHD5HklG5QS5KjvZC+TtoVRCEj39jqn X-Received: by 2002:a50:9f85:: with SMTP id c5mr17170497edf.72.1590930458719; Sun, 31 May 2020 06:07:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590930458; cv=none; d=google.com; s=arc-20160816; b=monRb8QEI32yUj6EFGpVDfOpPpEz7Yqsw7Xy9kdgVNI+AnplktmxxiYjtyfMCWaqqN 529QXzk4Nu0kFpd7LL4XkWtRmw9vOLtAe6rEpeHhWwa3cvEn/pRD3eV4bEOiTSGEkRTk +NGY3L1iy70v7wPTNu+zeLrEUp4TUMuMPLfI4CNm0S2heXRIZxghNzsNBDMAhMv5Qj8e 6tR/gp3wGXXYrs+SBHU1ifrwzgQjv6u0y5DSlnupfYPJ1nHajsGlYByTWPiuin9c6MkI RPgsv/po6AOWlghJVQL0gRIg30RRfOlvRuqeIx+BlxwrEJihJ1HANMOwgqpH5UKUuORi W4ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=BqhV+NqZNeQJy9937H6t2fNsaGUaVeO+uIzbSmUO5Ek=; b=anm+W/1wdhO9rv2kr6wDYROInSRKVHUjL1+maKTMDGqTfGf9L32oPcF2BQ6/uI2v/8 ys5xW63l6MQaWp45RBFHSNe7s4ADH6/2Emt6uENM2fzPFUlSujWQeNcvg8lhvEirS/Ya qM8TMDQc1p/g97B5gNF/CizSR+J3fos97AY7yp97pBoLgDJohj3yoc90s+8lirqN0F3y 1EsQOh7KSsMkUIg+KN01fGyueD1kMCCqVcq2V1+N4gvLLAqZFnGMtIJ8J176HcoioxVE nWeQdrP4xkBdy1Idx/B0R33r46Y4rjX8obl/GbxYF0OuJCvF3Wvu9vJ0rhZSBSl/Nyt+ A7Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZdoyKIUQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si9123262eja.51.2020.05.31.06.07.14; Sun, 31 May 2020 06:07:38 -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=pass header.i=@gmail.com header.s=20161025 header.b=ZdoyKIUQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727879AbgEaND0 (ORCPT + 99 others); Sun, 31 May 2020 09:03:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbgEaNDZ (ORCPT ); Sun, 31 May 2020 09:03:25 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 846ECC061A0E for ; Sun, 31 May 2020 06:03:25 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id c71so8178856wmd.5 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=O4xQJisrS8zzu7tW/XwJYTaIu4caZJJX/qsD3/GKq756EoqBuun0wVYMgQvGyUBXiS nCNJUElRh+v0ElbwE3uj0FmW8eEF8QaCVeyaGa2AauKxYBTceSPeVS3t2IUpliJEq5wf NZDD39pdkeBQT2iOHdjk8d/TyKCYWY8Z9iJFly16jmOylkLnTH/XgAJcqrxgO/KkNRVo 6LXok/mC4LlmKODeVr4M8I0oM6xndlofVLfmVzX89vS8+WkEccquhVZpQlIrn+FS/2Aj YDVz8IZPuI6GA3vmgvbRl/PgNn9mSA+tHcuhZ8BxnOj9tox4WUHb/bZaYicVxWh45hXi 9NdQ== X-Gm-Message-State: AOAM530oXbDlaFI9EPM/tGCE+40niztm6294PVYBJ5mOycytYcq57S38 wuhESqbIo0l+fiisD0XYQ8hKguHKXYMo3n/Doa0= 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > >