Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1073340ybm; Wed, 27 May 2020 15:37:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygpg7nXOm+kT4/f6RiuhU8hosqD31lGB3dltXSr7TYb1PZwzkd0+o98I+JPZc2hPGjeXpV X-Received: by 2002:a50:fd99:: with SMTP id o25mr328905edt.98.1590619032805; Wed, 27 May 2020 15:37:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590619032; cv=none; d=google.com; s=arc-20160816; b=yfK0VF+UETOJM6sluCmI/2+EOdLNHunv/8GkKLwpAreF0ScpyCJVRu2aa/3WihK/Ig q+msfa6XFkfTrugvO0kQmfFM8XGdWw8A4cPBE6mjC45a3d2CU6XbXouWldz4tiuF+339 AFLuzpfxAPp/l339FfTpWumrGAgfgce2X+WmTDunlJ6BeGH3/bR87UJ4QJ7zcGEHwdCu H1KNw9Zg1tmBCmPkHXXBqnm2fc7vpMIJe8Mexe2eCC2NaDdrYweW08YkU9eKrVV2j+5j YqF2tNJou/SBjs2Pxnq+/rphctjZlRkK0dQZEUy3b7puFIaxNBUH0U+igLDtdPxnlzhy d3VQ== 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=sWvJDniuNa0MloWGBo3nO/qwt/IUY5Pd+BokGdPrg7M=; b=ldYdp79xSGJdhJPaAlqlfin6zAHLQTMMBj3pwgOep+sw/wAXbxftNaAk+sgG7pBa55 VgpOPphIxGZkajkUAgsN6m6OC9A/puK+e5zZk96xdfLpBg/INAvSUXYW8L5WJL/at5qm im1+AqSQBdB8wGiSaRdhP1oZg7sE9ZTbjb+e1jdg1JV6OJKeAxikIcsavYEFdo6pUK5O q71MrQob5W55II/mcfN/qGA5rFavytUScAtLG9VjC0kJnrPEXih34T4mr6Y7fXYc7zER L44sSZrmzNVoasrvKLBeJ0B3OAZ1rhxC6JbDk1tDwjC+HG8AlfkOy4lrTaolTt/31/iu I+Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=SKkdpxYi; 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 z3si2697079ejm.403.2020.05.27.15.36.49; Wed, 27 May 2020 15:37:12 -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=SKkdpxYi; 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 S1725988AbgE0Wcs (ORCPT + 99 others); Wed, 27 May 2020 18:32:48 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:17990 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725780AbgE0Wcr (ORCPT ); Wed, 27 May 2020 18:32:47 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 27 May 2020 15:31:23 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 27 May 2020 15:32:46 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 27 May 2020 15:32:46 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 27 May 2020 22:32:46 +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; Wed, 27 May 2020 22:32:46 +0000 Received: from sandstorm.nvidia.com (Not Verified[10.2.87.74]) by rnnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 27 May 2020 15:32:45 -0700 From: John Hubbard To: Andrew Morton CC: LKML , , John Hubbard Subject: [PATCH 2/2] mm/gup: frame_vector: convert get_user_pages() --> pin_user_pages() Date: Wed, 27 May 2020 15:32:43 -0700 Message-ID: <20200527223243.884385-3-jhubbard@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200527223243.884385-1-jhubbard@nvidia.com> References: <20200527223243.884385-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=1590618683; bh=sWvJDniuNa0MloWGBo3nO/qwt/IUY5Pd+BokGdPrg7M=; 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=SKkdpxYia+zl8I1G5aytJpugRzjxOPugRFmINeXYNJyvv2wNBDukmddpHstDNZ4PQ 1aCOw+8GDWZlXhZ6C6i8g+UjIArzo16lNFuKbFNWekzRe/N8w81kArI55DnWNoL0T0 rLUBTUj/hTu0eUsJvN/PGKFmgeRYL5rfhiVj5mc/nPCgedQ/oxsx2yQUM89zK5D2vP pJN16iaiiJEnWDZ6X5TiRvTVAH010Vq1eMjMeEsdgRND8BChBrF9EVbvxscaHNSnrl j5H2FprhjqxJiUHAIrJmCHYDtFX/PZaizEr2Ia0lMrc88NVFRh3zYRloXamQQ28K2B mBQehtwhjhZfw== 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*(), and all of the callers so far were 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 --- mm/frame_vector.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/frame_vector.c b/mm/frame_vector.c index c431ca81dad5..4107dbca0056 100644 --- a/mm/frame_vector.c +++ b/mm/frame_vector.c @@ -72,7 +72,7 @@ int get_vaddr_frames(unsigned long start, unsigned int nr= _frames, if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) { vec->got_ref =3D true; vec->is_pfns =3D false; - ret =3D get_user_pages_locked(start, nr_frames, + ret =3D pin_user_pages_locked(start, nr_frames, gup_flags, (struct page **)(vec->ptrs), &locked); goto out; } @@ -122,7 +122,6 @@ EXPORT_SYMBOL(get_vaddr_frames); */ void put_vaddr_frames(struct frame_vector *vec) { - int i; struct page **pages; =20 if (!vec->got_ref) @@ -135,8 +134,8 @@ void put_vaddr_frames(struct frame_vector *vec) */ if (WARN_ON(IS_ERR(pages))) goto out; - for (i =3D 0; i < vec->nr_frames; i++) - put_page(pages[i]); + + unpin_user_pages(pages, vec->nr_frames); vec->got_ref =3D false; out: vec->nr_frames =3D 0; --=20 2.26.2