Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp173888ybt; Tue, 23 Jun 2020 18:37:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZ6HNyPqtjUtkUjdHIG7oqyo6wLHnfyQVhRjBJF8elgB/jxr7JCWUbpe1vHcG3U7BZfXRT X-Received: by 2002:a17:906:bcfc:: with SMTP id op28mr21966564ejb.237.1592962678871; Tue, 23 Jun 2020 18:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592962678; cv=none; d=google.com; s=arc-20160816; b=xpoIeZ74r9iZYAmNLH3j720IxYg/jEqm3c5ISNvqVWn4PZG1vpMnTgi7bSwm6iGxTX /yOv1nEJXEsQxh00sJfGAdq4OADPr27IsnOi8tqglFdCX6LYQ2Bn8Ri2nG1Vf/Q4Yy+Y sniS6+YbLTf61RXOec4G6Lee1JzJJD/ZTfCa4a9UpsqIKjGnrC95BCIXEMWoPCcM1VXr FzXoVu7Pb5BKSg2TvgL1n8JstMvnbKnBP6pJQKd9y745IUmBqTflvWZPv/dQzAEVh8/t ecb51BZTbmG69Ndcg+bgnClspslH1CYX2GKmZ1wHGGElbYez8Nnnk4Izp//xTPPQuOKi 9EUg== 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=q7jjyfHFC9E96qUQNIK0iSzZnFmQnU7S2H0dsaVw/bw=; b=nXfkxx6+Y96qBqRy2tHLMW3C0nn4wBQ3xrNG5Qtv4zT+y0NC80824N7ci02otpxeO5 /fe4E/pQ6CVteZNTt4KU8QN+ESac2MonTJGxIsAZIJiZoKa9FKW8OpdnG4FYkNRHXh1T qowQn8YgkGrVx+x7EIC2P0uxUwdx0P9pz4D861V8BRLr0X+jd8Y9QmgC6TOBrTL6aVmp KWHN//uAGbiGyn9pMuacW5PHMdTmP+/JTWT4C3LCKYpIU0NJHbd/dskm2zExBa5XUYn6 nl97hj5W3GgcfVAz2sgUf5oaM1qCjrutBWmA5OxXaX3KDVq2ND8+bckYqjCSOefDVpjv INTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hK7Rt5VM; 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 y1si5255554edt.101.2020.06.23.18.37.35; Tue, 23 Jun 2020 18:37:58 -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=hK7Rt5VM; 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 S2388536AbgFXBgR (ORCPT + 99 others); Tue, 23 Jun 2020 21:36:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388035AbgFXBgQ (ORCPT ); Tue, 23 Jun 2020 21:36:16 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57E1AC061573 for ; Tue, 23 Jun 2020 18:36:15 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id i3so748414ljg.3 for ; Tue, 23 Jun 2020 18:36:15 -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=q7jjyfHFC9E96qUQNIK0iSzZnFmQnU7S2H0dsaVw/bw=; b=hK7Rt5VMB2G5gbaRdIV0Ca6lV0ZaRMz+RDV4xUL2XkVbCQIDEzOKm49gQBGCHYiOM5 01IoGspdppI0EkYYitQghqMlWYxjWXvA/+3qZbU0KlZVs+xj1BqcrcCEPMGKW5PZTm8B g9u75oDqyl7m46djbSPk/Yw7xqTFCNyLCpUbGbck/WRnJMui8c89yeFj96+8belvxbna M5SZyJJ+dcvDMGJTLw4H2SZPdurlPzX0BYo0XgITMwuMlw8TnsTwTgIriOt2Exj06PtJ StY//vwUk0msYU4UBdT8AfDX73f5umwrQ7ITct+uyRy9dil1w0CADNCuTewpgAaJdsVC dPDQ== 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=q7jjyfHFC9E96qUQNIK0iSzZnFmQnU7S2H0dsaVw/bw=; b=apK06BfL8gUfHkwvM8r3pTiJHpKJjXKiXP27aWIxvRBjOhVIeo3tmfE8ATFV7YxuwG zWTVWrkhCg1RbpNDwmf7qCVwwbaqfZm1aeJzYD+k0A0VrEnbm4xy7kpDeyRhY5NNBJ7U fQjo9mNHDodmYTV7wNMCR+elI97HaMQ8FxThgdRlHjj0QzexM6NP/pXkrUJscJsKhr70 Ka87oEB0h9MYpue2/P0glvOCYwh80Ir93pvY/3b/ZU5tlxqJd2yl7AoW9yBhqm9hbfQr 6p/96W4pzSiu01HJ7uupJyNQ2p99/9sFHFNNGg0evq0HUdRbdfY3n+poM+F4FmvSK6Hg Fp8A== X-Gm-Message-State: AOAM532i9ESquGZ6p8T1sTeSA+Hogvrgmv6UwqRaM3cIEJCvCzXe/jGX LXTEiyya8hP333daqErJRIUs6NjWILQIrWKmNJs= X-Received: by 2002:a2e:b704:: with SMTP id j4mr13041345ljo.458.1592962573834; Tue, 23 Jun 2020 18:36:13 -0700 (PDT) MIME-Version: 1.0 References: <1592913499-15558-1-git-send-email-jrdr.linux@gmail.com> In-Reply-To: From: Souptick Joarder Date: Wed, 24 Jun 2020 07:06:01 +0530 Message-ID: Subject: Re: [RFC PATCH v2] xen/privcmd: Convert get_user_pages*() to pin_user_pages*() To: Boris Ostrovsky Cc: Juergen Gross , sstabellini@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, John Hubbard 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 Tue, Jun 23, 2020 at 11:11 PM Boris Ostrovsky wrote: > > On 6/23/20 7:58 AM, 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]. > > > > As discussed, pages need to be marked as dirty before unpinned it. > > > > Previously, if lock_pages() end up partially mapping pages, it used > > to return -ERRNO due to which unlock_pages() have to go through > > each pages[i] till *nr_pages* to validate them. This can be avoided > > by passing correct number partially mapped pages & -ERRNO separately > > while returning from lock_pages() due to error. > > With this fix unlock_pages() doesn't need to validate pages[i] till > > *nr_pages* for error scenario. > > > This should be split into two patches please. The first one will fix the > return value bug (and will need to go to stable branches) and the second > will use new routine to pin pages. Initially I split the patches into 2 commits. But at last moment I figure out that, this bug fix ( better to call coding error, doesn't looks like lead to any runtime bug) is tightly coupled to 2nd commit for pin_user_pages*() conversion, which means we don't need the bug fix patch if we are not converting the API to pin_user_pages*()/ unpin_user_pages_dirty_lock(). That's the reason to clubbed these two commits into a single one. If this looks unreasonable, will split it into 2 patches again. > > > > @@ -580,25 +580,30 @@ static long privcmd_ioctl_mmap_batch( > > > > static int lock_pages( > > struct privcmd_dm_op_buf kbufs[], unsigned int num, > > - struct page *pages[], unsigned int nr_pages) > > + struct page *pages[], unsigned int nr_pages, int *errno) > > > I'd prefer if you used more traditional way of returning error code by > the function, and pass the number of pinned pages as an argument. This > will also make call site simpler. Sure, Will do it. > > > -boris >