Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp283985ybt; Thu, 25 Jun 2020 22:30:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWKXYabVVH4yH2ajzXYaWvQ12f+StbnzHW4FNqUT/wfZ3XzVTMqjLXIE8KXnjwGcGeEuM7 X-Received: by 2002:a17:906:3e13:: with SMTP id k19mr1048943eji.476.1593149456529; Thu, 25 Jun 2020 22:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593149456; cv=none; d=google.com; s=arc-20160816; b=IWwiCHCSjYDvbwsueVQWlOJU1UjrRnydDOnAoSo7a3D35MFaMsovaVNIQOIL5Vx7r2 RQHn9c2wVJcddg//npquQGA499PVR85yzSHZaeTHJFn0XvKNYcN9zMwpFS/S+AIZZ0Mx sKbj5oTSOkV09S9061JYyP6I1+yCk/ZAHq+WI4Hzg3JFheSAqYCMZI0M2ZBrQzg2ZOZO 0SSAzSjmboSVY9HkZu4MJ0ZahOwIP9yCrzNWQtEwHizH+nI+33ec/tNDcN5NifphMNTA xr/G+K5ppWTzQNSUj2TUtt9fzbMQM1mGxJtTwT3j5oJ67sP8LQ4wA/7u8AN9/nvYIg6P BWUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=VuCEJOiQoqa0Rytop5ZoclTGnejYAU1zTtQWpgV+XJk=; b=uU0dVkxjHBIGEpUeO3HAboL8ySePoDvbhClMgwvImSKwIaUati2viHn7czdgLw3JYI cKFothXQ7bX9LIRwza7Ri8e8hRa7A3Kkd5u27d89X8n0pEgrtScI4eSKGJAUNktZjBob YMLoZp4yMEKC3uDs9rqfNfrPAmSbIugNfix7A06SPGvA4qbr7YKI4PyOB3kNRypTrMrc C2FxQxp3xVxnUgKiKlqx1RUadv52sciLweWYkZrMxOCXAJYWKAjKKVFyFIVjsy1dZZwJ VUm6K1IN57cxncaOiCriuc5JgNUUaehnvye3o1bhE47/gSapiDLe0JGYWMxs1p7fCrXv v5Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tRZemnxb; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dj11si3717282edb.279.2020.06.25.22.30.32; Thu, 25 Jun 2020 22:30:56 -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=@gmail.com header.s=20161025 header.b=tRZemnxb; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728024AbgFZF1K (ORCPT + 99 others); Fri, 26 Jun 2020 01:27:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbgFZF1H (ORCPT ); Fri, 26 Jun 2020 01:27:07 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 981ECC08C5C1 for ; Thu, 25 Jun 2020 22:27:06 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id s1so9016324ljo.0 for ; Thu, 25 Jun 2020 22:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VuCEJOiQoqa0Rytop5ZoclTGnejYAU1zTtQWpgV+XJk=; b=tRZemnxbVY6+6epMlhA+YSEtiuBGPEfAgB7O3fyn6uOiRsNkYm8inikyYy99XChNgC IjyB5mPxS+WDnHZLaTELQk0or68E/i08k+5eQ3qHN3hKJ1lSGExWo7fLmnSljN8CSPZs 3aotvq09CnSbdrOE4Qao5qky74s3HwM8Lhtc8h6mzIfbma4aaEyH8/pfiNoqDA0cMX7m Hua8P47pfUW94Ms5WNu2oeE2qYHV5+np7uwKMXTbrBkfI6BepiAUIbwVtsafO2aWaVhP ZEYnQCUjJEmgnL+8WiH40CxOdIE5lltvkb7bOjS9g6lRMmYGAfsqdBfeGs60h3rO6SNw RTrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VuCEJOiQoqa0Rytop5ZoclTGnejYAU1zTtQWpgV+XJk=; b=mTM8/hKmqdgbI4vwBnuvYKVJn7+sp9j7A7OzYP5fKH5huOgz69286RYuFi+VBo/fI0 xMzTj8X8jueLHZoIDgoI71hRQWskujeKErBcxTcn0L07pcQ1KYWyyDUNSt/NjgGRS/P6 LpyRKWiE7WB3iCsnGB4k/K3rDeZNmVvvNuADUgraGe+DEeVwuQoKlYeGKpXVbF7EYQEz b4n95/dCmYv8dW/V7UJ7dm3N3htDKzL/Oxn66jP/JgSvaEHr1VcSl2X+R8ADoegJfjpT QY/jB23oX4bFDK/xexiq5P9Kl7mFIsZ+pGEp0ZMWRIzIvRxVjOQ8gYuairoHYewXENgz bWuA== X-Gm-Message-State: AOAM532VWpc+gjllk8auEREyxlSlynfVJf8PCNm34KBXfo9ge122YOP0 /FGGLm2UqMeeHsgiO1IlKmQo9/je73cm11xcsNk= X-Received: by 2002:a2e:b704:: with SMTP id j4mr593539ljo.458.1593149225080; Thu, 25 Jun 2020 22:27:05 -0700 (PDT) MIME-Version: 1.0 References: <1593054160-12628-1-git-send-email-jrdr.linux@gmail.com> <1593054160-12628-2-git-send-email-jrdr.linux@gmail.com> <59afe2fe-3718-85aa-f3b5-83ca0b9df577@nvidia.com> In-Reply-To: <59afe2fe-3718-85aa-f3b5-83ca0b9df577@nvidia.com> From: Souptick Joarder Date: Fri, 26 Jun 2020 10:56:53 +0530 Message-ID: Subject: Re: [PATCH 2/2] xen/privcmd: Convert get_user_pages*() to pin_user_pages*() To: John Hubbard Cc: Boris Ostrovsky , Juergen Gross , sstabellini@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Paul Durrant Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 25, 2020 at 11:19 AM John Hubbard wrote: > > 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. Ok. > > 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. unpin_user_pages_dirty_lock() internally will do the same check after patch [2/2] So I thought to keep old and new code in sync. Shall we avoid this check ? > > > > } > > > > static long privcmd_ioctl_dm_op(struct file *file, void __user *udata) > > > > thanks, > -- > John Hubbard > NVIDIA