Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1194948ybt; Wed, 24 Jun 2020 23:28:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdrogLaz1ZvC942TmU58k/eLSiQrPnkxePtjy2f7sQov/MR4TQOJ566nn4womq3TzLKd83 X-Received: by 2002:a50:f7c2:: with SMTP id i2mr4595828edn.19.1593066499536; Wed, 24 Jun 2020 23:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593066499; cv=none; d=google.com; s=arc-20160816; b=TnqZ9MlJr17oTOBOj8TOLjX3eCkLJbloXglrgc3Luk35D2KDxemcvNjbnlMMH6XDfH CL0BFsTX+653HBld8ZorbNNkLbgmmDE0uoeInd8CzZW5f7hsBLSBwYqehEKP09EflGY/ w5yOjeIKivkXihl1g8NQwMuBKtLviqELhZbiDG+JQrzTZcQhOT1R9wOmAOvNdT8Uru0P ciCM7TwPSudVi7OIhBAqFhJwD/HSXxIpG+YW45pdD25hZouNet+F0JUw8lbs3acPfqCX d2CJz/2nhkrJCjY6r1/pdsVz596TDQ4pUjUgTrNYL6LrUyT72eKSIcdMlT2WaauI7qZK Wfug== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=hWnF3N0wCKATLkkSfY0YFbwq7TYcYG70FRiPZLz+TCA=; b=jbN/3zSaw3MXsuKEtdfCxjJI/B4h/Dzweagm+lzuVHqdqHJBg7OUSaJuI7NJR4L7Bb eJRozOsbH4junaKAgN21Xy95csRQyQxKhghc1JjH3kF48R+mk5NOnteAcqIkOUFVkseo zn+sEJVMkG9ImcNDQ9b8Pq7wF3EtE+C/c+tjR0f1XVkFvsbN2gXbBemq6ORkJhHj4hkJ Cn5TPosluXFkuUpUaQGfD6o2JLsOoa5EQltWqpLJvHVpMcxDM0+0G2VfEZ6ZoXH78SlR Haf45o6oAbbwGenr26nsdliXGJg8pTHh1BJtVV2cvxDSmlLsG7SiBitfPQfsBeAppH/6 6Fbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Ou2+hLOa; 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 e23si2480495edq.600.2020.06.24.23.27.56; Wed, 24 Jun 2020 23:28:19 -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=Ou2+hLOa; 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 S2389845AbgFYFtE (ORCPT + 99 others); Thu, 25 Jun 2020 01:49:04 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:7510 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389617AbgFYFtD (ORCPT ); Thu, 25 Jun 2020 01:49:03 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 24 Jun 2020 22:48:17 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Wed, 24 Jun 2020 22:49:03 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Wed, 24 Jun 2020 22:49:03 -0700 Received: from [10.2.59.206] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 25 Jun 2020 05:49:02 +0000 Subject: Re: [PATCH 2/2] xen/privcmd: Convert get_user_pages*() to pin_user_pages*() To: Souptick Joarder , , , CC: , , Paul Durrant References: <1593054160-12628-1-git-send-email-jrdr.linux@gmail.com> <1593054160-12628-2-git-send-email-jrdr.linux@gmail.com> From: John Hubbard Message-ID: <59afe2fe-3718-85aa-f3b5-83ca0b9df577@nvidia.com> Date: Wed, 24 Jun 2020 22:49:02 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <1593054160-12628-2-git-send-email-jrdr.linux@gmail.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1593064097; bh=hWnF3N0wCKATLkkSfY0YFbwq7TYcYG70FRiPZLz+TCA=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=Ou2+hLOaCBz5atm+9GHKtzk2bsBzKjQpsnvnwY2SlNbHVBzzL+/gQ3IF+qLThXkSb u4uehwdHRm+7H+ISGqx9LuSs62EgWyvSOnyTPq8gAuSVnA/OmC6ysPb59sBzr2usdn aEnDnmC1GhNwFrZOk7VLroiVZqtLYB/tiUXMSSh+8+G09UySSwK17c44IFFvw+C4jE YokJFSjzFST3CpV1TMAJWqlA8A1sPBaZzZBJ1cjuOYLmTIlxudkBQePekA1XbpiYMy yiKYBAWwKB7/h5LGmYbn844WExZQR3Zep0YtJkMbmQg5w/QxcCBpmdh/1Epgu/kxJ1 H2nDpVqD51F+A== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-06-24 20:02, Souptick Joarder wrote: > In 2019, we introduced pin_user_pages*() and now we are converting > get_user_pages*() to the new API as appropriate. [1] & [2] could > be referred for more information. This is case 5 as per document [1]. > > [1] Documentation/core-api/pin_user_pages.rst > > [2] "Explicit pinning of user-space pages": > https://lwn.net/Articles/807108/ > > Signed-off-by: Souptick Joarder > Cc: John Hubbard > Cc: Boris Ostrovsky > Cc: Paul Durrant > --- > Hi, > > I'm compile tested this, but unable to run-time test, so any testing > help is much appriciated. > > drivers/xen/privcmd.c | 10 ++-------- > 1 file changed, 2 insertions(+), 8 deletions(-) > > diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c > index 0da417c..eb05254 100644 > --- a/drivers/xen/privcmd.c > +++ b/drivers/xen/privcmd.c > @@ -595,7 +595,7 @@ static int lock_pages( > if (requested > nr_pages) > return -ENOSPC; > > - page_count = get_user_pages_fast( > + page_count = pin_user_pages_fast( > (unsigned long) kbufs[i].uptr, > requested, FOLL_WRITE, pages); > if (page_count < 0) { > @@ -612,13 +612,7 @@ static int lock_pages( > > static void unlock_pages(struct page *pages[], unsigned int nr_pages) > { > - unsigned int i; > - > - for (i = 0; i < nr_pages; i++) { > - if (!PageDirty(page)) > - set_page_dirty_lock(page); > - put_page(pages[i]); > - } > + unpin_user_pages_dirty_lock(pages, nr_pages, 1); "true", not "1", is the correct way to call that function. Also, this approach changes the behavior slightly, but I think it's reasonable to just set_page_dirty_lock() on the whole range--hard to see much benefit in checking PageDirty first. > } > > static long privcmd_ioctl_dm_op(struct file *file, void __user *udata) > thanks, -- John Hubbard NVIDIA