Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4625958imu; Tue, 18 Dec 2018 19:35:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/XhJC2FS+Xi1+CrNVP9TowhLe843joBGADMbnIbBbiAJyXxtmCOnCmKaGrKg8/3VZOeHgVV X-Received: by 2002:a62:2781:: with SMTP id n123mr19306821pfn.138.1545190521493; Tue, 18 Dec 2018 19:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545190521; cv=none; d=google.com; s=arc-20160816; b=DuqO3pLKsjDeJ2OB1IC7o62gzKYfrtuo688M/m7I0cLo7eqtUHFv+48zFJHgbn2iDt 3UBLMxx/tGAJk3/ZT6cMQxnwOPkLkj/QjcyXzbBKusRYQEg0cmldbagiAU986sc+1ZuL cTWy7Iz2Z/HjCDNcRX6pe9p6nEMtf9JVguixaB5FryqSYJdvcbOtDUfWsMTcCRT9GB5U BDdqWxPifFpHdGgutJdnXxTuIbpsPFi75bAd67tQ4ZxuNAt8bLyNae4t/E5IiCKHA846 fWVk7Im9wfPIqPA0deQf3WjbOqOy5G80LSmFKEDdYUsTX4Doy1rZ82t68Y0sATaJptTV WcYw== 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=hyoE9cQYj2vKKeNaKbEZn+1/rj10Ta2+2thIX+qo1mM=; b=IZJND/ASPC3oIb2w6PQ5oeCLsjuw5Hs5qCBCflqlGxUpAZD0z0MtX8FL9sZpuLBYqc rASCE/pg14HhtKv4NFiESvIQyUjoXKgfDMaBJywT61OKsUqiLWRXWOFqSfBFNyBlPHNx YhoWwN71Kipy4llBzZkMRkf3RQ0dzyZOgaI62Rp+V4oqiRxlgAZ2Bog9G9vrMBsJMVtr kXzCrQecx+ri9iDbq1xckBBSodwigS3LKEjEMXtb6DUtgCB/njM2HRCVD5eHljRg3qzR Xk7US5zqKiF0i+kkZjdm100Fguj1Tz6ePegaWuum2JYiEY/Sg+vloRmw5DHmgEZ+fo1Z EIaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XQjLNi60; 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 g10si14208151plq.371.2018.12.18.19.35.04; Tue, 18 Dec 2018 19:35:21 -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=XQjLNi60; 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 S1727380AbeLSDbX (ORCPT + 99 others); Tue, 18 Dec 2018 22:31:23 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:41463 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbeLSDbW (ORCPT ); Tue, 18 Dec 2018 22:31:22 -0500 Received: by mail-lf1-f65.google.com with SMTP id c16so13901870lfj.8 for ; Tue, 18 Dec 2018 19:31:21 -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=hyoE9cQYj2vKKeNaKbEZn+1/rj10Ta2+2thIX+qo1mM=; b=XQjLNi60OQMSNl8uGp8JWoIVDx7+LLcQ46BFKojokG5wz4nId2PwPWwcYXF5ewHn3J EcIbxmYeWA4HepLPpx4EPwnahRNcOFM/gb/YtjrlmkiGbWKogwhtsCSNmG6+zmyNMq64 cZMXW2seVxU61ZS9BxO1qv/KMIwEGFmTcLUJH+1CX1hXFo5/KZSIXcBORrgh/kWEa2aZ xRhd5+UeLSPi1AVXhaH4zM5axZtfevgWIlDx+ZaH7e2KaZlSWdrEBjWuN1ZqEXuyI13U YW0Thnebflvl6Xbj7DGnoCBE+iNrtmHWTjBXZGgZKDJyzOXYb59SpOLpy+EvdrS+AqZ3 6P0g== 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=hyoE9cQYj2vKKeNaKbEZn+1/rj10Ta2+2thIX+qo1mM=; b=af3s8TIWRjYEpP64vEWUSXd5btUwK+QclAezkwb2FBPyQoo59tHtXFMZL5x3Hpu1AA AOkjDCxNLDZBj1y9/1ldxtWdDaKDrFYRMLc8Hx77gWQa1btCZdx3BbMKTfvsY9zgmJEz As5Tfxa4kXZAES+QX2l/sGmuZt21FRTOFWXiT/8R1t9st1YZkYvSHJwMK/Ic9XCNq0d9 xGosNx0bnrN8nlfzMhENou8S/mB3JnY83n7wCn+esgd76NN5fI5OgFB0Spkm/oQ/KYGN YkaNg93f7w3xViuDoqZM+qJetyPqirubgOIAzl9GZQuVDe3tkmHkZjzNna/waAQxPszF GBZA== X-Gm-Message-State: AA+aEWZ9FThdJ+lHf++E7lnarSECwg4iTcTTKpX6eEphU5LnyShBRUbj i6XL9KV351AuGcPDI1uHXq5JZAVBNRLFIFuVxX8= X-Received: by 2002:a19:24c6:: with SMTP id k189mr11910717lfk.77.1545190280199; Tue, 18 Dec 2018 19:31:20 -0800 (PST) MIME-Version: 1.0 References: <20181217202334.GA11758@jordon-HP-15-Notebook-PC> <20181218095709.GJ26090@n2100.armlinux.org.uk> <20181218123318.GN26090@n2100.armlinux.org.uk> <20181218130146.GO26090@n2100.armlinux.org.uk> In-Reply-To: <20181218130146.GO26090@n2100.armlinux.org.uk> From: Souptick Joarder Date: Wed, 19 Dec 2018 09:01:09 +0530 Message-ID: Subject: Re: [PATCH v4 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range To: Russell King - ARM Linux 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 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, Dec 18, 2018 at 6:31 PM Russell King - ARM Linux wrote: > > 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. Sorry but didn't get it ? How it will be similar to the bug 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