Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp356065ybl; Tue, 27 Aug 2019 22:02:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxAwo6OVQYXVmeUSSihYj2mCbQ9AM+sdcyIgZYjtR3wQioB2C3oCItR5JLbjH25tUrkPTKB X-Received: by 2002:a17:902:a606:: with SMTP id u6mr2445582plq.224.1566968550002; Tue, 27 Aug 2019 22:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566968549; cv=none; d=google.com; s=arc-20160816; b=DCgv9nkCr6+Pm4vadOQnH1Fxarf/yZ3h3sU/qNbOM3C5nPgzlNwwbqH7OjSe3ZvpHV Gcx3nguhYySkZ9nxE+uVknHJa1yGNzdKO7zHeuwc4cOPDmbO8Pve2nKbzyZphyuy4DCU xQEje09joyl0eNVp/c51SctK/IpYmwoJSa8Lkwch29zkmC7cR3en3OYflU0vv3m33kv1 JZVCmkh5E7q3MCG2Q9FsXrYH3W6DSEvTDlmsVZblEIvuK0YTKi1XUWgWtJ0H6ks/it5S N7jn/JUp92vY2CsZ8FMVtmo5Jm5cPklL3aJvgJoWvsRhq56e/vP64b/XYY91enICxDxE m5cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Twq2yQQW1kb+CdWAXLUhBkn41nTMmiL4dInftsa3ZCQ=; b=YboCRUYxMJOhmY6Qgg78FTS74rT+wP6UYajEYQpN5fTcg2CiExLtmTHT0sFaXPeRcT X2eIM1fpN7pWHhdftb3LCM3BUhsqTmBLjT3hGYaycxjYT3nSLfSz7k02P0rqBpTBAUgk DOGpEmHuKBtZK+onAy3g5ohlZghwg1O+PARgXDppMoDhacWH2hFXr8M5GvgV1rzltcsC t2zty1XoVfXFjE7c0Q2jO/E4O+BnptnTeBAUNhN2+5BdUWgmxCMYgxBNU9NMpW61axyp QQHRjagcyu6uMHQjS6QB8eOSpjt6ycDEyN9BwPjKUzp+82y88twUOf+yyWeoKGv0NDjX 12rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WZljqAGW; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e8si991862plt.288.2019.08.27.22.02.14; Tue, 27 Aug 2019 22:02:29 -0700 (PDT) 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=@kernel.org header.s=default header.b=WZljqAGW; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726278AbfH1FAl (ORCPT + 99 others); Wed, 28 Aug 2019 01:00:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:54024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726052AbfH1FAk (ORCPT ); Wed, 28 Aug 2019 01:00:40 -0400 Received: from localhost (unknown [77.137.115.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A1C7122CF4; Wed, 28 Aug 2019 05:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566968439; bh=Twq2yQQW1kb+CdWAXLUhBkn41nTMmiL4dInftsa3ZCQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WZljqAGWZT4g8A0yMdejOLzv1u7W2uhfFa5rqORxiArnhe3swrP+m7icxDTO0aneI RZd1YgueeJJ/2oUlEJMf2CtPEW+yE08MKFWkXyGlXgAe6Ox6vOQf+5ARKOiSByUK1h jOMxty5Y4iECjQjc+E+TbCaIOBanmLGjjeliin+M= Date: Wed, 28 Aug 2019 08:00:09 +0300 From: Leon Romanovsky To: Souptick Joarder Cc: Jason Gunthorpe , Doug Ledford , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Matthew Wilcox Subject: Re: [PATCH] IB/mlx5: Convert to use vm_map_pages_zero() Message-ID: <20190828050009.GB4725@mtr-leonro.mtl.com> References: <1566713247-23873-1-git-send-email-jrdr.linux@gmail.com> <20190825194354.GC21239@ziepe.ca> <20190826122055.GA27349@ziepe.ca> <20190827154935.GD7149@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 28, 2019 at 08:57:19AM +0530, Souptick Joarder wrote: > On Tue, Aug 27, 2019 at 9:19 PM Jason Gunthorpe wrote: > > > > On Tue, Aug 27, 2019 at 01:48:57AM +0530, Souptick Joarder wrote: > > > On Mon, Aug 26, 2019 at 5:50 PM Jason Gunthorpe wrote: > > > > > > > > On Mon, Aug 26, 2019 at 01:32:09AM +0530, Souptick Joarder wrote: > > > > > On Mon, Aug 26, 2019 at 1:13 AM Jason Gunthorpe wrote: > > > > > > > > > > > > On Sun, Aug 25, 2019 at 11:37:27AM +0530, Souptick Joarder wrote: > > > > > > > First, length passed to mmap is checked explicitly against > > > > > > > PAGE_SIZE. > > > > > > > > > > > > > > Second, if vma->vm_pgoff is passed as non zero, it would return > > > > > > > error. It appears like driver is expecting vma->vm_pgoff to > > > > > > > be passed as 0 always. > > > > > > > > > > > > ? pg_off is not zero > > > > > > > > > > Sorry, I mean, driver has a check against non zero to return error -EOPNOTSUPP > > > > > which means in true scenario driver is expecting vma->vm_pgoff should be passed > > > > > as 0. > > > > > > > > get_index is masking vm_pgoff, it is not 0 > > > > > > Sorry, I missed this part. Further looking into code, > > > in mlx5_ib_mmap(), vma_vm_pgoff is used to get command and > > > inside mlx5_ib_mmap_clock_info_page() entire *dev->mdev->clock_info* > > > is mapped. > > > > > > Consider that, the below modification will only take care of vma length > > > error check inside vm_map_pages_zero() and an extra check for vma > > > length is not needed. > > > > What is the point of vm_map_pages_zero() Is there some reason we should > > prefer it for mapping a single page? > > vm_map_pages_zero() can be used to map single/ multiple pages both. > There were drivers previously which either check length and pg_off explicitly > or didn't check for incorrect value of length /pg_off passed to it at > all. Calling > vm_map_pages_zero() in those places were more appropriate as it has > internal check for both. > > Now considering this patch, avoiding an extra check for length > explicitly is the only > part which can be avoided if converted to use vm_map_pages_zero() > because pg_off > is used in different context ( to identify command). So yes, > improvement wise convert > to use vm_map_pages_zero() is not making much difference here. So let's drop it, please. Thanks