Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2344231ybk; Sun, 17 May 2020 18:24:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeWtyP4K8S71R2a/DmBtZITwonWHqbxamGS+zcxmHPxuuCaCqHPfmHQupb0CwCJHwWYJVk X-Received: by 2002:a50:fc83:: with SMTP id f3mr8737765edq.138.1589765065192; Sun, 17 May 2020 18:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589765065; cv=none; d=google.com; s=arc-20160816; b=HL4RKe3ne3+EZtjhs+MCw43kCYMg8i2XP0OLmSGv52Baxx+1zprqlvssLuR1Tgu3NT LsbeMJHg/rceP+fHBul0779m9J9UfmNgFU1TZkUHUwX0YkipDbtOjGtC3YiXPGyDKnN1 9s2ZjziTzBC0LRXB7mO+wEZSklY9HliSQVWxsrEEUl48TGhOrR754faWkUAyvAB1ksu1 1J/e/SnXl5mOMPx7NpVeuhnkeLpJlE+i77Y4sjGb1OTzlGjcdgbOem73nbP7zXvGJ6fD 1mY9x2XbhicWUX3HrUei1mROxfKQc88MDl2aYuozphftDmJm+57SHE6jYHLCr156DYLU onSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=+Bd2dKwO1m4xCknqEnntHu5ZR7ZzO/a9Yy+seiDwYQk=; b=vyNizL3zeuy2/PS/5wg4sdlqIeeWuHU6BAjlixViITsHGu8FYrdLYIsM6Kpzbg+Qas NeLI5g61vzb3fe69YDxwznvVU3zKbdk3vsAAS7pA6IyUuCBGhuzchPiTuGy4o3qm3oyl G3tZf+KKrgJMXoMMVS9Ee/mjPwK6PAMwSRl1YN5Gns2L4b5t6vdV5K/4LLnrCx7gQ0Ke q6cRp3HXKbNE++3DyTVYsjdSsb93WBXCkPL5MCezLEMlAWPTTyUunXdyyVzoUUxTktTG w8TypbDhzE/QA40idle5wAZRFMUcSkB24v/PWe1p1wM07HlI2XuhpC15xGJQcRIZGzqd d4og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=qe8apbDx; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l25si5573909eji.408.2020.05.17.18.23.43; Sun, 17 May 2020 18:24:25 -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=@nvidia.com header.s=n1 header.b=qe8apbDx; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727066AbgERBWE (ORCPT + 99 others); Sun, 17 May 2020 21:22:04 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:17142 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727003AbgERBWB (ORCPT ); Sun, 17 May 2020 21:22:01 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Sun, 17 May 2020 18:19:38 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Sun, 17 May 2020 18:21:59 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Sun, 17 May 2020 18:21:59 -0700 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 18 May 2020 01:21:59 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 18 May 2020 01:21:59 +0000 Received: from sandstorm.nvidia.com (Not Verified[10.2.48.175]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Sun, 17 May 2020 18:21:59 -0700 From: John Hubbard To: Andrew Morton CC: Andy Walls , Mauro Carvalho Chehab , , LKML , , John Hubbard Subject: [PATCH 1/2] mm/gup: introduce pin_user_pages_unlocked Date: Sun, 17 May 2020 18:21:56 -0700 Message-ID: <20200518012157.1178336-2-jhubbard@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518012157.1178336-1-jhubbard@nvidia.com> References: <20200518012157.1178336-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1589764778; bh=+Bd2dKwO1m4xCknqEnntHu5ZR7ZzO/a9Yy+seiDwYQk=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=qe8apbDxfUOL34853vKL5Pm+EM2eEzJsyeg7TK3MuFDBhyRG+KGRXrfIauwl9kbnd EmVvRzb6mGS5pB2ULYsghn/hyU+gebu4Pp5pnV2Wts3D8L9LcSKErKF2UKsYujF2Nm ckthj0MxtSyWUcabjdBEafMngtKanymPa8HEh9J77CLEDvdtTJsstct6wlz7pqEEfW nYhEvXxAUiyGKHHIZ7F8RGZVsseT35PmooJKRPSH+h6gO9FK3ql5Ci8niH2a0WVQL4 hH0G2nciKNm0jpEWVSZ+/uOKp3kNxLfdba5Pg7NwIKXwTNJnon+5wJ2U81Xci+1kzL bMPhYFJb+cIXw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce pin_user_pages_unlocked(), which is nearly identical to the get_user_pages_unlocked() that it wraps, except that it sets FOLL_PIN and rejects FOLL_GET. Signed-off-by: John Hubbard --- include/linux/mm.h | 2 ++ mm/gup.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 5a323422d783..a5594ac9ebe3 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1702,6 +1702,8 @@ long get_user_pages_locked(unsigned long start, unsig= ned 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, + struct page **pages, unsigned int gup_flags); =20 int get_user_pages_fast(unsigned long start, int nr_pages, unsigned int gup_flags, struct page **pages); diff --git a/mm/gup.c b/mm/gup.c index 87a6a59fe667..50cd9323efff 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2939,3 +2939,20 @@ long pin_user_pages(unsigned long start, unsigned lo= ng nr_pages, pages, vmas, gup_flags); } EXPORT_SYMBOL(pin_user_pages); + +/* + * pin_user_pages_unlocked() is the FOLL_PIN variant of + * get_user_pages_unlocked(). Behavior is the same, except that this one s= ets + * FOLL_PIN and rejects FOLL_GET. + */ +long pin_user_pages_unlocked(unsigned long start, unsigned long nr_pages, + struct page **pages, unsigned int gup_flags) +{ + /* FOLL_GET and FOLL_PIN are mutually exclusive. */ + if (WARN_ON_ONCE(gup_flags & FOLL_GET)) + return -EINVAL; + + gup_flags |=3D FOLL_PIN; + return get_user_pages_unlocked(start, nr_pages, pages, gup_flags); +} +EXPORT_SYMBOL(pin_user_pages_unlocked); base-commit: b9bbe6ed63b2b9f2c9ee5cbd0f2c946a2723f4ce prerequisite-patch-id: 0496235d2f0b29f75b9835e63a6923ddad6d0260 prerequisite-patch-id: 2711b9393a74cd0e1fcf48befea3618f7bb1ca9e prerequisite-patch-id: 95e2521748b3058710fb2a161b2c76389644665b prerequisite-patch-id: eeae300399f69db2cd61535b40c1f1ee1929195a prerequisite-patch-id: 9ed26cdb071ab084a204c85a08986806d6bae877 --=20 2.26.2