Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4400242imu; Mon, 14 Jan 2019 22:28:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN7I24x328WkqRsB+JPJ8zmg+KluCJOZigzmeyRJWmvIBjleKpLF3SIS/VNcO7aKD6T971W/ X-Received: by 2002:a63:5252:: with SMTP id s18mr2368902pgl.326.1547533700072; Mon, 14 Jan 2019 22:28:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547533700; cv=none; d=google.com; s=arc-20160816; b=buC++VCc6beOu2zED9bNrw7h45UnqDtTN2LnR9ed5nuNN/LxNPF0+a/JG3+nm3fMvW Em08dJxWRqO/bs8d9RWXQVifCAuey8+xiqF6Cxfqx+3HfPDhx5XNH/EaLSCIZMhYfo/j +vGwvdOy4NVek8Gep8Ef9+36/l5Duak77l3gSN0Rrq3jEXTVUAOVz42+cwlc5Ii2qU7d O1OsnZR32H8tsEOfYNxXoE/5MMS86ZHKI2t6zpogeBIEMYSTsOgxGigzGQ/GZfM1/Qsy rrrYsu3/WeYarq+ikuV/XZB1qEvGx6BtQGRFQS1/9E6dAAz4SlAeWiKcIZxiArXD/wwp ZuhA== 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=3TXiWK8V2OmVXxJRMbWQxDG/DyuoOV26hjhztUIr7v0=; b=snJFDxyQSb4RFECQCGh28QgGS4RHpSU1eX4Mz0xAMzxER9m9Of0QIGv9dvloU2YmBJ FUwgC1hVLWyNKKc4XMf1b6aLMtf4A4NpZpsVt7CNlTzM+DZSFRxsj23uF2EJkuTZsFku QUN8lMdOHM7XGugNp936x2HD4XKbzjtqa+h1lF3OPisczXZZKeKWtHCNZq9POsT4Dll3 Sls67hXSayozve52BcWUGJ3eJ5okv9A7BaMl5FDlXAJ0r4fxqNJH71jxidZdUF/7nit8 OgWQ9/Ci23wLtrNMQpib3F79Cs3aGXNcGvx+QyiQc/fn+OlR98oNtiPAthxXrJOSSeGs yoQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mVtcuV0E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id e68si2507757pfb.101.2019.01.14.22.28.04; Mon, 14 Jan 2019 22:28:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mVtcuV0E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727899AbfAOEuL (ORCPT + 99 others); Mon, 14 Jan 2019 23:50:11 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:44906 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727223AbfAOEuK (ORCPT ); Mon, 14 Jan 2019 23:50:10 -0500 Received: by mail-lf1-f66.google.com with SMTP id z13so979606lfe.11 for ; Mon, 14 Jan 2019 20:50:09 -0800 (PST) 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=3TXiWK8V2OmVXxJRMbWQxDG/DyuoOV26hjhztUIr7v0=; b=mVtcuV0EWzi7waFPQ8kYoJPyXBr+5pYoBCie6M0hgYyXy7vhQ5az3gqJxtEbxr3nn2 j9ilWv71hMMplMbZtgb43pPMZXzFr7wx5xRxPS8DNzutWYmyB9EbCwsRsuXMufbg0xyR /YEVGqozNiko6lxpg06VLAT4fpTuQZmDYLb+sIUstV44HcikXtqaXUTSG9GTURBiUSNA 8BYjInM+97RsYzeR70yuKV67ybVWP0xN7Rx/tFxF+bbrHmJYj33wSR5ZPzMHcXDr0m+1 2a6FY+nVTaxr2WZQJEJ4B4b10N7sCID+uDbgcnuZjxWcfRn319/fRSQvaJDYttnRfiRL kkxQ== 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=3TXiWK8V2OmVXxJRMbWQxDG/DyuoOV26hjhztUIr7v0=; b=EtCIyp7eiEibH3e2x5G2CI+5CL9uNEFr2Bo51mzvh1ovHLvskQ/aSQtdobYCp2g73d b858lDTdj+h3uSg/C0P176dPXBJZU+55v95vAzO+LNUY6ebGOuKSA7S7241wcaT2IUxq bJOqTkgNcQ7CCWJncQlZ0566ILdxBoriJ4Pq2ysOYelofI+GyXXMyLfqsyy8gmX0yuvz lJqn31i72i/MMZPppQN5S8fnijC1VKbmvrvlUteEHqGdKuljJtQ2bKYrIzX6BujFBwmO uSvMHadeYVHShohtAuz/SGAc/dNzSSHTNEdsRY6Z/KEFmHmQk7CFM+AzlQNUbUO8qVpE 3JdA== X-Gm-Message-State: AJcUukd67DRpV6NA1DseBPuPzcV6riDNBxuZRY53qaW42Ndo9919oBF6 qm3BzlvwLxbPlSohdwKolcpF2c38VdJvqLHo/f8= X-Received: by 2002:a19:ee08:: with SMTP id g8mr1378271lfb.72.1547527808437; Mon, 14 Jan 2019 20:50:08 -0800 (PST) MIME-Version: 1.0 References: <20190111151235.GA2836@jordon-HP-15-Notebook-PC> In-Reply-To: From: Souptick Joarder Date: Tue, 15 Jan 2019 10:19:55 +0530 Message-ID: Subject: Re: [PATCH 8/9] xen/gntdev.c: Convert to use vm_insert_range To: Boris Ostrovsky Cc: Andrew Morton , Matthew Wilcox , Michal Hocko , Juergen Gross , Russell King - ARM Linux , robin.murphy@arm.com, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Linux-MM 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, Jan 15, 2019 at 4:58 AM Boris Ostrovsky wrote: > > On 1/11/19 10:12 AM, Souptick Joarder wrote: > > Convert to use vm_insert_range() to map range of kernel > > memory to user vma. > > > > Signed-off-by: Souptick Joarder > > Reviewed-by: Boris Ostrovsky > > (although it would be good to mention in the commit that you are also > replacing count with vma_pages(vma), and why) The original code was using count ( *count = vma_pages(vma)* ) which is same as this patch. Do I need capture it change log ? > > > > --- > > drivers/xen/gntdev.c | 16 ++++++---------- > > 1 file changed, 6 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c > > index b0b02a5..ca4acee 100644 > > --- a/drivers/xen/gntdev.c > > +++ b/drivers/xen/gntdev.c > > @@ -1082,18 +1082,17 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) > > { > > struct gntdev_priv *priv = flip->private_data; > > int index = vma->vm_pgoff; > > - int count = vma_pages(vma); > > struct gntdev_grant_map *map; > > - int i, err = -EINVAL; > > + int err = -EINVAL; > > > > if ((vma->vm_flags & VM_WRITE) && !(vma->vm_flags & VM_SHARED)) > > return -EINVAL; > > > > pr_debug("map %d+%d at %lx (pgoff %lx)\n", > > - index, count, vma->vm_start, vma->vm_pgoff); > > + index, vma_pages(vma), vma->vm_start, vma->vm_pgoff); > > > > mutex_lock(&priv->lock); > > - map = gntdev_find_map_index(priv, index, count); > > + map = gntdev_find_map_index(priv, index, vma_pages(vma)); > > if (!map) > > goto unlock_out; > > if (use_ptemod && map->vma) > > @@ -1145,12 +1144,9 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) > > goto out_put_map; > > > > if (!use_ptemod) { > > - for (i = 0; i < count; i++) { > > - err = vm_insert_page(vma, vma->vm_start + i*PAGE_SIZE, > > - map->pages[i]); > > - if (err) > > - goto out_put_map; > > - } > > + err = vm_insert_range(vma, map->pages, map->count); > > + if (err) > > + goto out_put_map; > > } else { > > #ifdef CONFIG_X86 > > /* >