From patchwork Sun Sep 6 06:51:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 11759455 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4AECA618 for ; Sun, 6 Sep 2020 06:53:51 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 186A22080A for ; Sun, 6 Sep 2020 06:53:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MszkEUa5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 186A22080A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kEoXi-0007z5-Ce; Sun, 06 Sep 2020 06:52:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kEoXh-0007yx-Oz for xen-devel@lists.xenproject.org; Sun, 06 Sep 2020 06:52:49 +0000 X-Inumbo-ID: b40d6706-da4f-4a1f-828e-e6b319c4c834 Received: from mail-pf1-x443.google.com (unknown [2607:f8b0:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b40d6706-da4f-4a1f-828e-e6b319c4c834; Sun, 06 Sep 2020 06:52:49 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id 17so6897964pfw.9 for ; Sat, 05 Sep 2020 23:52:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Db0fgXXbzH2p2U25JJ6scSTK1v1Ti17DDq8xS5lR3/w=; b=MszkEUa5ryYy30yaiYP8RoyZtu6DMbERcUxtpSd18pBj6WexOGEKKL7JkkCjeVUYa4 CLPoxhkxomeYAPBFdTEqbgyEnE9h08KH9vh/2zYii0811dV9ABqMr9Y+OOGDR4GbOKWQ DTwpEZ4rNvQ47beCtgBw67QI3/z/j2BUult3VlMTBvtL7D8gc932t9nL1RVNBW0Q2Xql EOvSDVqH3rJH+AbCcVBG9XpMu4jVYzF9TmggKmsf6S17fC4F3G27oREvQ7LQPIXCtV4U 8VXHh/QZPE+IAXJLXGU2l8GBimNhAKcGwVpsPC1+d9MH2dSd3obODmPQiNoIKRnUkMfy Fgzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Db0fgXXbzH2p2U25JJ6scSTK1v1Ti17DDq8xS5lR3/w=; b=luH2F88ghxKHw0D0AseQsVMm5JSHQZK+K8nVh6wSStECHli75YrSvaJAgCG3AWJ5v7 tTZ83LZhC37DXMcNc/CO2sqKAxgrLhkjGBDf9e6m9HcB642uMEJQ2aAaakMWQVQ2AkRO M5aL3rmTWG76lA+jyDj4v4VwrySVjaVGZunAa3dvuIpaOY542XY0l4/+Ko6Uz7ozwjiT sN2prLurT/p0wgxUJ75GTCxvncQ6PrhXeUYI3wQ+h/uU2yZWUyfbllTa4C/vIeeGr7lQ O2avvonH0BGdZevM2cAF9SBn9o38elCgBcwcA0Tf8mRgNXITrz+euufXlE/d5nUZQQP1 reaQ== X-Gm-Message-State: AOAM531eREUME2cK6Ekj2PbbArPNNgPKyhZ/HZc6KTXRQpS8T3JcW+RT j1xDsxaNSlNsuNIQzrvFOkLT2SRsraolSA== X-Google-Smtp-Source: ABdhPJxQeP2UYdkYbiXq2FOVaFF2XXnDUgZOTqlJ7qMyx28A9j6QYQ0Cphyslfl3lZuG6wql4/ZCpQ== X-Received: by 2002:aa7:941a:: with SMTP id x26mr11701444pfo.177.1599375168362; Sat, 05 Sep 2020 23:52:48 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC.domain.name ([122.171.54.54]) by smtp.gmail.com with ESMTPSA id n128sm9199947pga.5.2020.09.05.23.52.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Sep 2020 23:52:47 -0700 (PDT) From: Souptick Joarder To: boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, david.vrabel@citrix.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Souptick Joarder , John Hubbard Subject: [PATCH 2/2] xen/gntdev.c: Convert get_user_pages*() to pin_user_pages*() Date: Sun, 6 Sep 2020 12:21:54 +0530 Message-Id: <1599375114-32360-2-git-send-email-jrdr.linux@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1599375114-32360-1-git-send-email-jrdr.linux@gmail.com> References: <1599375114-32360-1-git-send-email-jrdr.linux@gmail.com> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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: Juergen Gross Cc: David Vrabel Reviewed-by: Boris Ostrovsky --- drivers/xen/gntdev.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index 5e1411b..a36b712 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -731,7 +731,7 @@ static int gntdev_get_page(struct gntdev_copy_batch *batch, void __user *virt, unsigned long xen_pfn; int ret; - ret = get_user_pages_fast(addr, 1, batch->writeable ? FOLL_WRITE : 0, &page); + ret = pin_user_pages_fast(addr, 1, batch->writeable ? FOLL_WRITE : 0, &page); if (ret < 0) return ret; @@ -745,13 +745,7 @@ static int gntdev_get_page(struct gntdev_copy_batch *batch, void __user *virt, static void gntdev_put_pages(struct gntdev_copy_batch *batch) { - unsigned int i; - - for (i = 0; i < batch->nr_pages; i++) { - if(batch->writeable && !PageDirty(batch->pages[i])) - set_page_dirty_lock(batch->pages[i]); - put_page(batch->pages[i]); - } + unpin_user_pages_dirty_lock(batch->pages, batch->nr_pages, batch->writeable); batch->nr_pages = 0; batch->writeable = false; }