Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3832556imu; Tue, 18 Dec 2018 05:03:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vd99487CVSSS6hNUmltj2Pq989cW7aUSvbmG+pGwA0JmZC2CZKPACzKySCew+ehE/mybVo X-Received: by 2002:a63:ae01:: with SMTP id q1mr15295345pgf.402.1545138230626; Tue, 18 Dec 2018 05:03:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545138230; cv=none; d=google.com; s=arc-20160816; b=bVsQCAZF+E/+L6b0BkjGMk3Ni1K5sE5KS1B0PbqNHe8vP+B/dcV2MOs3nL2I98DorR QuGBbnnR+AJ8Iz6KwWwunceeE4oaG5URnkKFXx0HyoQFAwGW6wpw1TAWE/qSxaNvWFQ+ VSYuFtyj5hFw7zy5pLX/EKu0+iNQWWmtuT+61ot4FSKafmJ6HOx8msVRNFhHiCjLUm0W 7cyRXAq/U3kwj1vEA1+GWOYUKd4p3zLwuETnkuPinvb4pUlgJ+8lePogCG2hWe9ZMnF3 HMHSYWsGR7pboSTyoC5V60Wl8gY8DaHvK+J3OduSG+cNwcO5xghdreDpWFM+EGRdiSSL C+wg== 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=p/zQXaDdLenxksVTHmUzxUflGwJ16RJL7z8txHgD+to=; b=VJgYr88UfUT29aK9YH7xH48687BDw8KrQ7pMC4aYS9M5kw08qOJrOd0WVC1fzzycd9 HUjfnGr/1BXgZRgTiXF9MqmCXihSuDEwXgSzgF4OpRsXF4d5H6aGqDKSs/JVcfX2NL5g 4tNryeXpZIQPiN+dBBEhZo0NAWtysfIpqzOninQKyMA+24HLJNOXYUVhl1/sc5sa3q0W q/YPpIYQAnD9mPKI/ERJdnvodiyyqt/QHEwJTT4h/ap1jUsVvwmbpdLdfRPqDN3C741+ pNH79XLsZHfEUhaS3mQF8sxugTUVxs1briDeE0ofBssVcAMkshBAVUQaYDZZ+aSOOkzl Vu1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@armlinux.org.uk header.s=pandora-2014 header.b=huVwdg5h; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si11520427pgl.485.2018.12.18.05.03.32; Tue, 18 Dec 2018 05:03:50 -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=neutral (body hash did not verify) header.i=@armlinux.org.uk header.s=pandora-2014 header.b=huVwdg5h; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726661AbeLRNCC (ORCPT + 99 others); Tue, 18 Dec 2018 08:02:02 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:41756 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726430AbeLRNCC (ORCPT ); Tue, 18 Dec 2018 08:02:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZSPtYofuOLJbbEzZt9KWJCLaMECNc3Sg0IjTDIcqrow=; b=huVwdg5hpf7Kdngv6UqAHWE8E dF5KT0mvbWHNEovvbpNV/5AFkspcBEc6Apf5qWaXTnCdTmD0RmkZyF3SvWc96Mh/Li9BBr2f72lzm 1yjKGQyr2310MqNjOuPPvBzxE1TTOB76Sy4YSwoi+H6DWTu9MMQAO+ggYoMumncwVxSmg=; Received: from n2100.armlinux.org.uk ([fd8f:7570:feb6:1:214:fdff:fe10:4f86]:39923) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1gZF0Q-0006Dt-RI; Tue, 18 Dec 2018 13:01:50 +0000 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.90_1) (envelope-from ) id 1gZF0O-0007cq-CP; Tue, 18 Dec 2018 13:01:48 +0000 Date: Tue, 18 Dec 2018 13:01:46 +0000 From: Russell King - ARM Linux To: Souptick Joarder Cc: Michal Hocko , Heiko Stuebner , Linux-MM , airlied@linux.ie, hjc@rock-chips.com, Matthew Wilcox , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org, Andrew Morton , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range Message-ID: <20181218130146.GO26090@n2100.armlinux.org.uk> References: <20181217202334.GA11758@jordon-HP-15-Notebook-PC> <20181218095709.GJ26090@n2100.armlinux.org.uk> <20181218123318.GN26090@n2100.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 18, 2018 at 06:24:29PM +0530, Souptick Joarder wrote: > On Tue, Dec 18, 2018 at 6:03 PM Russell King - ARM Linux > wrote: > > > > On Tue, Dec 18, 2018 at 05:36:04PM +0530, Souptick Joarder wrote: > > > On Tue, Dec 18, 2018 at 3:27 PM Russell King - ARM Linux > > > wrote: > > > > This looks like a change in behaviour. > > > > > > > > If user_count is zero, and offset is zero, then we pass into > > > > vm_insert_range() a page_count of zero, and vm_insert_range() does > > > > nothing and returns zero. > > > > > > > > However, as we can see from the above code, the original behaviour > > > > was to return -ENXIO in that case. > > > > > > I think these checks are not necessary. I am not sure if we get into mmap > > > handlers of driver with user_count = 0. > > > > I'm not sure either, I'm just pointing out the change of behaviour. > > Ok. I think feedback from Heiko might be helpful here :) > > > > > > > The other thing that I'm wondering is that if (eg) count is 8 (the > > > > object is 8 pages), offset is 2, and the user requests mapping 6 > > > > pages (user_count = 6), then we call vm_insert_range() with a > > > > pages of rk_obj->pages + 2, and a pages_count of 6 - 2 = 4. So we > > > > end up inserting four pages. > > > > > > Considering the scenario, user_count will remain 8 (user_count = > > > vma_pages(vma) ). ? No ? > > > Then we call vm_insert_range() with a pages of rk_obj->pages + 2, and > > > a pages_count > > > of 8 - 2 = 6. So we end up inserting 6 pages. > > > > > > Please correct me if I am wrong. > > > > vma_pages(vma) is the number of pages that the user requested, it is > > the difference between vma->vm_end and vma->vm_start in pages. As I > > said above, "the user requests mapping 6 pages", so vma_pages() will > > be 6, and so user_count will also be 6. You are passing > > user_count - offset into vm_insert_range(), which will be 6 - 2 = 4 > > in my example. This is two pages short of what the user requested. > > > > So, this should be the correct behavior. > > return vm_insert_range(vma, vma->vm_start, > rk_obj->pages + offset, > user_count); ... and by doing so, you're introducing another instance of the same bug I pointed out in patch 2. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up