Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp797506ybr; Fri, 22 May 2020 21:01:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztryCti2ZzsLkUpYKM8vvt0eSVZgYdoy3GhcvdpiNEKRnPg8U7+fbPeEb+1Ljk//4edYOW X-Received: by 2002:aa7:d999:: with SMTP id u25mr5709746eds.339.1590206491296; Fri, 22 May 2020 21:01:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590206491; cv=none; d=google.com; s=arc-20160816; b=THbFKPe6hUxYSEXzAvbrwYBkN1KnTafMPe77Wt0+3cCZZ5+llutHH7VVyoUUq1PmMx 36wTJ80Hu57JR0sUQXxVLhQyAjTrRogRxmjtL/u3DtzMWSzdHw5hqSb+lEI7K4Y/NRhx yBGfBRwjwAYdajL6XjhgswRutaOe2u9EfFgErs2QFJZ8RqkO9lS22Nk/HJw0bZmZ6FeF Zao8Z/XeItYxKFlE10KyKGDvi7RwwfMQ649oDlYlAXzDP1PBedXYGZu0wWGSvpX+BgVm zhmm8AwH1HusXZGkX50BKF0F/3fz2apBJlWWdI2YHWocrWBlfbybP8yZPJirah8judwR PDlg== 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:message-id:date:subject:cc:to:from; bh=IUi0GpOpORIfa8wCBq2zBkJfP/EEDe3USpDV5HpfHqc=; b=SWU3LFvhGLlaSRLRY++R22iSqrYlZ8Yh8p3kF7qsM7Wpxkt5ulod19Fmedj1QNedtS 3VjB5/S91zaQFbu7yNK6HfkKY9g5/GDNuaR+MGKbdrRbhJrRnhBlZFCL4I+UBjG+00kn FM++B7qk1kaVUdsOodQijdRfCrlD534YjEQzssncYa0YIGiUrmuAAXQgPHWitVNhYT0o VFgNx2OteN8Xwnp51+cmArKJLgxb8dR2Xc0gNCnl4c8rR9RT9h0uRg199yIkdZFpa86G 5j8chKXLSJg26d5uGDKyy0Cgcym98h5KMr4YxtnF0+uxiZEqEqOplHaHA3qT6oxvFpsv nPGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b="FaPlam/S"; 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 f19si5590010edx.127.2020.05.22.21.01.07; Fri, 22 May 2020 21:01:31 -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="FaPlam/S"; 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 S2387574AbgEWD7M (ORCPT + 99 others); Fri, 22 May 2020 23:59:12 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:14781 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387559AbgEWD7L (ORCPT ); Fri, 22 May 2020 23:59:11 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 22 May 2020 20:56:45 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 22 May 2020 20:59:11 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 22 May 2020 20:59:11 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sat, 23 May 2020 03:59:11 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Sat, 23 May 2020 03:59:11 +0000 Received: from sandstorm.nvidia.com (Not Verified[10.2.52.1]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Fri, 22 May 2020 20:59:11 -0700 From: John Hubbard To: LKML CC: John Hubbard , Mike Marshall , Martin Brandenburg , , Subject: [PATCH v2] orangefs: convert get_user_pages() --> pin_user_pages() Date: Fri, 22 May 2020 20:59:09 -0700 Message-ID: <20200523035909.418683-1-jhubbard@nvidia.com> X-Mailer: git-send-email 2.26.2 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=1590206205; bh=IUi0GpOpORIfa8wCBq2zBkJfP/EEDe3USpDV5HpfHqc=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: MIME-Version:X-NVConfidentiality:Content-Transfer-Encoding: Content-Type; b=FaPlam/S9EqBdtcSpbgQ+XxTdqJLQQznCtA49glUta2sbL6t/offvbJPDLT436xPN 5H6NB6RA74NGNEVbDuUozp+1XD29LzgK1RkXieQsCpR4jETKKhIWEEB5o9F7Nbx/qS 2nqPrOtYZxWq2cmcVj1sKwEudIBbQXU/s4dYHBmRZRXFZnfW56GYiOhfs5AcXRIE5N 8mGmX/CosJ9w1jeDqO8TxkzwFzjfwAVGm70WJQwaLUW6oC2s6Xzy/vR7Pr1TxCM+z7 IkaCrdF6bX5bD21RThH0czCqw5VeHmZ8yAn0BMlt9fCT+qUaV44R2u9NGBzQ5DjW2f L1FbLm2dNS9/w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This code was using get_user_pages*(), in a "Case 1" scenario (Direct IO), using the categorization from [1]. That means that it's time to convert the get_user_pages*() + put_page() calls to pin_user_pages*() + unpin_user_pages() calls. There is some helpful background in [2]: basically, this is a small part of fixing a long-standing disconnect between pinning pages, and file systems' use of those pages. [1] Documentation/core-api/pin_user_pages.rst [2] "Explicit pinning of user-space pages": https://lwn.net/Articles/807108/ Cc: Mike Marshall Cc: Martin Brandenburg Cc: devel@lists.orangefs.org Cc: linux-fsdevel@vger.kernel.org Signed-off-by: John Hubbard --- Hi, Note that I have only compile-tested this patch, although that does also include cross-compiling for a few other arches. Changes since v1 [3]: correct the commit description, so that it refers to "Case 1" instead of "Case 2". [3] https://lore.kernel.org/r/20200518060139.2828423-1-jhubbard@nvidia.com thanks, John Hubbard NVIDIA fs/orangefs/orangefs-bufmap.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c index 2bb916d68576..538e839590ef 100644 --- a/fs/orangefs/orangefs-bufmap.c +++ b/fs/orangefs/orangefs-bufmap.c @@ -168,10 +168,7 @@ static DEFINE_SPINLOCK(orangefs_bufmap_lock); static void orangefs_bufmap_unmap(struct orangefs_bufmap *bufmap) { - int i; - - for (i =3D 0; i < bufmap->page_count; i++) - put_page(bufmap->page_array[i]); + unpin_user_pages(bufmap->page_array, bufmap->page_count); } =20 static void @@ -268,7 +265,7 @@ orangefs_bufmap_map(struct orangefs_bufmap *bufmap, int offset =3D 0, ret, i; =20 /* map the pages */ - ret =3D get_user_pages_fast((unsigned long)user_desc->ptr, + ret =3D pin_user_pages_fast((unsigned long)user_desc->ptr, bufmap->page_count, FOLL_WRITE, bufmap->page_array); =20 if (ret < 0) @@ -280,7 +277,7 @@ orangefs_bufmap_map(struct orangefs_bufmap *bufmap, =20 for (i =3D 0; i < ret; i++) { SetPageError(bufmap->page_array[i]); - put_page(bufmap->page_array[i]); + unpin_user_page(bufmap->page_array[i]); } return -ENOMEM; } --=20 2.26.2