Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2468361ybk; Sun, 17 May 2020 23:05:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI0OS7u8KOpxOAH7DSF/5cyvz4bUi+ElKXOOwXqVnsrxFES9eJtfmU66lAwtksmJk9EnDg X-Received: by 2002:a50:a7e4:: with SMTP id i91mr11815958edc.381.1589781955761; Sun, 17 May 2020 23:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589781955; cv=none; d=google.com; s=arc-20160816; b=mlzFrPBQ8X6Nq2Is+5NpiZM77l/ZdpKVEQzVdlHXxg74yedQu87/mhpu2/1/z8kwWg 24r8r0dZaQYjTW8m7MNzP8iMA5X0Gngk+zPq8cQetwOvEdZmdtEqdtNTqZ3qEQ2lfac9 eZDEg7maxXbZ5M+edmOBhqOPWmPVh34eCf584Ir/gxmxZSvfF7I9o/Dw1u8jOvuhO4QE Gi/yWxe1xA8/M1+fdUbJHRLKLCKrdVLsAz07Crkka1vFWIzHcPhlkXywTiM16XDM9Nal 9oqpIGdBuesd3crLsSdL7XCGUrzfBtqcRX9zcXCcDaxqg5llzPQb+GrFIQJpTDSERBC4 VQfw== 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=L/5D60XFGdPvaS3NAfsHyW+VMUpnFlIrCbHG4lt9M0U=; b=oGfCcrKxbydPobuubijWsb9ss+x9HNYXnhvRCCH533vO7g27Cf+dCyvaLSRn1eSOSd fpx5gzRYM2ANXQQeY75y/yPXDJBYGld91KD9vzFh/fn9OaSqh1OIe8FyNcn4PlPhzGpH MYr9jlyb2bj3E+b4gm3r8kVJRxKtoLUhXIb06COlWWp/WBf4XzJJknCs/iFXnVukuDJP Sjba0qyv7DQwn/rYcHMFhJEeGaEb7iYm5ESvet2mgy/1U6poRl8vBYDxAgPRrQf+p2rm a+TGrP0SuWpWEyp/6AT5/8LctkiiaIMJwzmkQa+d9SDfAaL6ijGLLkZGFWD9IQECtrEh yzKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=pGHATikA; 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 oq5si6034772ejb.395.2020.05.17.23.05.31; Sun, 17 May 2020 23:05:55 -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=pGHATikA; 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 S1726428AbgERGBo (ORCPT + 99 others); Mon, 18 May 2020 02:01:44 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:6164 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726040AbgERGBo (ORCPT ); Mon, 18 May 2020 02:01:44 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Sun, 17 May 2020 23:00:26 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Sun, 17 May 2020 23:01:44 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Sun, 17 May 2020 23:01:44 -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; Mon, 18 May 2020 06:01:44 +0000 Received: from rnnvemgw01.nvidia.com (10.128.109.123) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 18 May 2020 06:01:43 +0000 Received: from sandstorm.nvidia.com (Not Verified[10.2.48.175]) by rnnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Sun, 17 May 2020 23:01:43 -0700 From: John Hubbard To: LKML CC: Mike Marshall , Martin Brandenburg , , John Hubbard Subject: [PATCH] orangefs: convert get_user_pages() --> pin_user_pages() Date: Sun, 17 May 2020 23:01:39 -0700 Message-ID: <20200518060139.2828423-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=1589781626; bh=L/5D60XFGdPvaS3NAfsHyW+VMUpnFlIrCbHG4lt9M0U=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: MIME-Version:X-NVConfidentiality:Content-Transfer-Encoding: Content-Type; b=pGHATikAs0+QHO2iJmt6ltZqaafiRAQeW/4IlWtoQODiUtQhge30yUQp3ETfwV4Eb uFdPYRzQPJ/1jEOjNZ1U1Hu9eVx7PWV33MwpWsJ4tU4LrL4iEqIm0C2P0ck7hoHc9R GD2rebyRcb/7eZtFeryBE83On6pcjDfRoeKjRmrCpdhHiLyZ1cJFTX8XBlq+vIhMLj 1wEW8QJfHmzOCfjuzxlmUo7O07QNwaAx6edCElbvdwyVeDF7Yx3ugAKEimv1ETjSqZ lfo+/w+WvZHSa0Ep7PpcTDzeakZqE/hJzhgrHtNIEAv7lAdr6aljDM9SYZFoITs4AP WhaIij0KjOgIw== 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 2" scenario (DMA/RDMA), 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/ Signed-off-by: John Hubbard --- 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