Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3210183ybx; Sun, 3 Nov 2019 13:24:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxwrCP4LmdN7hx7ishZ8nRDc4Up2aUOJcaEloGlQK6WP1pyy4TttXVIvdOBwwHwtn6p7AYg X-Received: by 2002:a17:906:b7c4:: with SMTP id fy4mr21180990ejb.120.1572816258837; Sun, 03 Nov 2019 13:24:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572816258; cv=none; d=google.com; s=arc-20160816; b=FftON4BL3YTnj/zJEE2mssFbkSiOzLmBDLNeDmMzEvlqaawOeMsJwLSvLdG6CEzHD6 Yvq04hE1pDEzyUo/IPvejcKiQMlFzQZUStYqhSxDrK+zkxJ4IXUDnA7eryJlfObnT5Ey W4HQS4zKmETLDa2gy5HHhdho9xK0LGRYn8L74JiQmWnvXUfkzeVdUqW1jYb1y+oziBtf WaNaxXYs2eNaImSXYJ5aA1ZGoYy4x4okq7bq9viRThZ8WpYZjQq6CsYjYhJIbDATDLKh BzvpF5yVKgWnB2OkLRz0y7Quac5KDfg7fLx6HFHjBKCvhfafNDtlkHNE7FblxkL37yIB PJRg== 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=LhpBvPrZELtAUQMy6bjxFv5Hb6pi3TX++tJGx6mahjM=; b=uflCBjLHbrbwYEAn3GtUMB9CjnfOkKim+hZDnxt/VbxsaB3YIgWeCdFSzJ0RrrOkT8 ccYK9aSJM7WvDyfnwbexINv6K/brEUxOP2AI0ZEa3mwpyxhpVT0X8zzCAgpxd5BYK3xM 7/sdRSztYZmheNiCHtWqlX6RYGVN79xu8q7cyoxxWnxOlaZ8XLEDkUMO/TNHCR7lzSXc XNUixtMCPW8Xw7L7OPCPzBUOgVd86zwamjVHyB+84qaXNuyICVH8sDDsjJ33qfIjXL1w rrrCqu1hp/BGFm3fz0uRlAd2rSTAfKcgUPtB5uVjazDOFSUGO/hqX6zd6BHXcxv/kcba IKNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=c5t7HOOt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k24si10414283ejz.417.2019.11.03.13.23.55; Sun, 03 Nov 2019 13:24:18 -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=@nvidia.com header.s=n1 header.b=c5t7HOOt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728920AbfKCVUc (ORCPT + 99 others); Sun, 3 Nov 2019 16:20:32 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:17507 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728332AbfKCVSV (ORCPT ); Sun, 3 Nov 2019 16:18:21 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Sun, 03 Nov 2019 13:18:25 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Sun, 03 Nov 2019 13:18:19 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Sun, 03 Nov 2019 13:18:19 -0800 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sun, 3 Nov 2019 21:18:19 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Sun, 3 Nov 2019 21:18:19 +0000 Received: from blueforge.nvidia.com (Not Verified[10.110.48.28]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Sun, 03 Nov 2019 13:18:18 -0800 From: John Hubbard To: Andrew Morton CC: Al Viro , Alex Williamson , Benjamin Herrenschmidt , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Christoph Hellwig , Dan Williams , Daniel Vetter , Dave Chinner , David Airlie , "David S . Miller" , Ira Weiny , Jan Kara , Jason Gunthorpe , Jens Axboe , Jonathan Corbet , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Magnus Karlsson , Mauro Carvalho Chehab , Michael Ellerman , Michal Hocko , Mike Kravetz , Paul Mackerras , Shuah Khan , Vlastimil Babka , , , , , , , , , , , , , LKML , John Hubbard Subject: [PATCH v2 18/18] mm/gup: remove support for gup(FOLL_LONGTERM) Date: Sun, 3 Nov 2019 13:18:13 -0800 Message-ID: <20191103211813.213227-19-jhubbard@nvidia.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191103211813.213227-1-jhubbard@nvidia.com> References: <20191103211813.213227-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=1572815905; bh=LhpBvPrZELtAUQMy6bjxFv5Hb6pi3TX++tJGx6mahjM=; 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=c5t7HOOtcA6T3DL6EnWGaqdMn3bnk0Sst6NLwaZXKVSSdUxVIcj0Ds96Kind5ogBw OpePkjaGMnFUaJkwUo2GqHJ623qdpJkHe6Pv8fmsp3C1ijehkUj+K+K7czY6MqFduD 7Ka60Lv0qRDRUigYpz+ayEQGmqYsI0+wSZWMlNf1Qory9cMhkcbH0Y9aFCKfgv23AH MwEJKHVQyq8VYfAIMozi5LR5/7Zg0r+WQDkSbptLzVgajtcRmjQoK5fYoPsogQUxdL Z55SfQc9JYW9f7WlgOVSQkJp+PxRSXl++vSDmWNTvAnuc0vH80MVKrZm8LB2a+Pg7q hzeY5OLedn/Rw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that all other kernel callers of get_user_pages(FOLL_LONGTERM) have been converted to pin_longterm_pages(), lock it down: 1) Add an assertion to get_user_pages(), preventing callers from passing FOLL_LONGTERM (in addition to the existing assertion that prevents FOLL_PIN). 2) Remove the associated GUP_LONGTERM_BENCHMARK test. Signed-off-by: John Hubbard --- mm/gup.c | 8 ++++---- mm/gup_benchmark.c | 9 +-------- tools/testing/selftests/vm/gup_benchmark.c | 7 ++----- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index c9727e65fad3..317f7602495d 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1732,11 +1732,11 @@ long get_user_pages(unsigned long start, unsigned l= ong nr_pages, struct vm_area_struct **vmas) { /* - * FOLL_PIN must only be set internally by the pin_user_page*() and - * pin_longterm_*() APIs, never directly by the caller, so enforce that - * with an assertion: + * FOLL_PIN and FOLL_LONGTERM must only be set internally by the + * pin_user_page*() and pin_longterm_*() APIs, never directly by the + * caller, so enforce that with an assertion: */ - if (WARN_ON_ONCE(gup_flags & FOLL_PIN)) + if (WARN_ON_ONCE(gup_flags & (FOLL_PIN | FOLL_LONGTERM))) return -EINVAL; =20 return __gup_longterm_locked(current, current->mm, start, nr_pages, diff --git a/mm/gup_benchmark.c b/mm/gup_benchmark.c index 2bb0f5df4803..de6941855b7e 100644 --- a/mm/gup_benchmark.c +++ b/mm/gup_benchmark.c @@ -6,7 +6,7 @@ #include =20 #define GUP_FAST_BENCHMARK _IOWR('g', 1, struct gup_benchmark) -#define GUP_LONGTERM_BENCHMARK _IOWR('g', 2, struct gup_benchmark) +/* Command 2 has been deleted. */ #define GUP_BENCHMARK _IOWR('g', 3, struct gup_benchmark) #define PIN_FAST_BENCHMARK _IOWR('g', 4, struct gup_benchmark) #define PIN_LONGTERM_BENCHMARK _IOWR('g', 5, struct gup_benchmark) @@ -28,7 +28,6 @@ static void put_back_pages(int cmd, struct page **pages, = unsigned long nr_pages) =20 switch (cmd) { case GUP_FAST_BENCHMARK: - case GUP_LONGTERM_BENCHMARK: case GUP_BENCHMARK: for (i =3D 0; i < nr_pages; i++) put_page(pages[i]); @@ -94,11 +93,6 @@ static int __gup_benchmark_ioctl(unsigned int cmd, nr =3D get_user_pages_fast(addr, nr, gup->flags & 1, pages + i); break; - case GUP_LONGTERM_BENCHMARK: - nr =3D get_user_pages(addr, nr, - (gup->flags & 1) | FOLL_LONGTERM, - pages + i, NULL); - break; case GUP_BENCHMARK: nr =3D get_user_pages(addr, nr, gup->flags & 1, pages + i, NULL); @@ -157,7 +151,6 @@ static long gup_benchmark_ioctl(struct file *filep, uns= igned int cmd, =20 switch (cmd) { case GUP_FAST_BENCHMARK: - case GUP_LONGTERM_BENCHMARK: case GUP_BENCHMARK: case PIN_FAST_BENCHMARK: case PIN_LONGTERM_BENCHMARK: diff --git a/tools/testing/selftests/vm/gup_benchmark.c b/tools/testing/sel= ftests/vm/gup_benchmark.c index c5c934c0f402..5ef3cf8f3da5 100644 --- a/tools/testing/selftests/vm/gup_benchmark.c +++ b/tools/testing/selftests/vm/gup_benchmark.c @@ -15,7 +15,7 @@ #define PAGE_SIZE sysconf(_SC_PAGESIZE) =20 #define GUP_FAST_BENCHMARK _IOWR('g', 1, struct gup_benchmark) -#define GUP_LONGTERM_BENCHMARK _IOWR('g', 2, struct gup_benchmark) +/* Command 2 has been deleted. */ #define GUP_BENCHMARK _IOWR('g', 3, struct gup_benchmark) =20 /* @@ -46,7 +46,7 @@ int main(int argc, char **argv) char *file =3D "/dev/zero"; char *p; =20 - while ((opt =3D getopt(argc, argv, "m:r:n:f:abctTLUuwSH")) !=3D -1) { + while ((opt =3D getopt(argc, argv, "m:r:n:f:abctTUuwSH")) !=3D -1) { switch (opt) { case 'a': cmd =3D PIN_FAST_BENCHMARK; @@ -72,9 +72,6 @@ int main(int argc, char **argv) case 'T': thp =3D 0; break; - case 'L': - cmd =3D GUP_LONGTERM_BENCHMARK; - break; case 'U': cmd =3D GUP_BENCHMARK; break; --=20 2.23.0