Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2118392imu; Thu, 24 Jan 2019 07:31:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN63yj9iK0ThzWdVYV+fdTQuxtWR7BXdhAJxC641yy3u6/DzbpjJjVtc10LJNT7MuMfPnSTG X-Received: by 2002:a17:902:3124:: with SMTP id w33mr7028818plb.241.1548343895104; Thu, 24 Jan 2019 07:31:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548343895; cv=none; d=google.com; s=arc-20160816; b=L5r9XJJwFL1nZUBUBXOCVRtgrOgbZVLZo8RtXW/xvv0pw1CgYF5J2fwZL4JfblZ8qr o60d7HwqN+8y4u3Y9lRzF2B5108lwlMoYKaJeLUormFFpJTMG1DMNBCUtjgyRcJ1Wukx o++/dyM4XjGGWulZtFr0CqlZEuKrcPqUZz6e6LSXoQniSy7npjhkagCVy+Vo92F4evu/ C6/m09HN/xbEjOR2aM7MNbyoY1uWjVUtrV2hTVZXN1crV8BImIC69yAPJLTM+eJameXg iyMhZroHtK240ui9h1+RV2UN6Kp04MCqN3sLFY3HvJ1bdzBZwg2tR1m05fpAxJA2Nm5H eddQ== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=yV6J1TVAqVzmsV2R6pbyZVQupK7tWXilgRYKUwlBw+E=; b=aVt1udS4bJLjpmd/gUPjiTH8VWqbB+Nmp/sD/A2Z8th2x9V38k3RIxL6rkxfKyL3M3 Pa6npsIm9TAPUY7+HYDAUHlFPvZtvFlqEWAxK2wY3hE4f5bklRWvUuzZ1SdytHv6jgq2 s+UTD0WfAY88jnLmyPAM0Di5JgAMrD1waOyFW4s8akAjVfZa4yKBl9hFCDWUqHSzdTHt aGhd174W6/Pf3OsYSkeKRmnRctdo5iRj4/XM6B/yls03D/AImiNt1Ft2+OVVSGcBaC96 GPNT2dJi35AAVqAO+CXHh53ESEyLLLLHqSY+qs5tynBSjrvfmGnIm3VqciS2TvwWHgj7 p9QA== ARC-Authentication-Results: i=1; mx.google.com; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x191si722541pfd.220.2019.01.24.07.31.19; Thu, 24 Jan 2019 07:31:35 -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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728602AbfAXPau (ORCPT + 99 others); Thu, 24 Jan 2019 10:30:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48452 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728079AbfAXPau (ORCPT ); Thu, 24 Jan 2019 10:30:50 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E547DC070E05; Thu, 24 Jan 2019 15:30:48 +0000 (UTC) Received: from redhat.com (unknown [10.20.6.236]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 11F6F10D8233; Thu, 24 Jan 2019 15:30:33 +0000 (UTC) Date: Thu, 24 Jan 2019 10:30:32 -0500 From: Jerome Glisse To: Joonas Lahtinen Cc: linux-mm@kvack.org, Ralph Campbell , Jan Kara , Arnd Bergmann , kvm@vger.kernel.org, Matthew Wilcox , linux-rdma@vger.kernel.org, John Hubbard , Felix Kuehling , Radim =?utf-8?B?S3LEjW3DocWZ?= , Dan Williams , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Michal Hocko , Jason Gunthorpe , Ross Zwisler , linux-fsdevel@vger.kernel.org, Paolo Bonzini , Andrew Morton , Christian =?iso-8859-1?Q?K=F6nig?= Subject: Re: [PATCH v4 8/9] gpu/drm/i915: optimize out the case when a range is updated to read only Message-ID: <20190124153032.GA5030@redhat.com> References: <20190123222315.1122-1-jglisse@redhat.com> <20190123222315.1122-9-jglisse@redhat.com> <154833175216.4120.925061299171157938@jlahtine-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <154833175216.4120.925061299171157938@jlahtine-desk.ger.corp.intel.com> User-Agent: Mutt/1.10.0 (2018-05-17) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 24 Jan 2019 15:30:49 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 24, 2019 at 02:09:12PM +0200, Joonas Lahtinen wrote: > Hi Jerome, > > This patch seems to have plenty of Cc:s, but none of the right ones :) So sorry, i am bad with git commands. > For further iterations, I guess you could use git option --cc to make > sure everyone gets the whole series, and still keep the Cc:s in the > patches themselves relevant to subsystems. Will do. > This doesn't seem to be on top of drm-tip, but on top of your previous > patches(?) that I had some comments about. Could you take a moment to > first address the couple of question I had, before proceeding to discuss > what is built on top of that base. It is on top of Linus tree so roughly ~ rc3 it does not depend on any of the previous patch i posted. I still intended to propose to remove GUP from i915 once i get around to implement the equivalent of GUP_fast for HMM and other bonus cookies with it. The plan is once i have all mm bits properly upstream then i can propose patches to individual driver against the proper driver tree ie following rules of each individual device driver sub-system and Cc only people there to avoid spamming the mm folks :) > > My reply's Message-ID is: > 154289518994.19402.3481838548028068213@jlahtine-desk.ger.corp.intel.com > > Regards, Joonas > > PS. Please keep me Cc:d in the following patches, I'm keen on > understanding the motive and benefits. > > Quoting jglisse@redhat.com (2019-01-24 00:23:14) > > From: Jérôme Glisse > > > > When range of virtual address is updated read only and corresponding > > user ptr object are already read only it is pointless to do anything. > > Optimize this case out. > > > > Signed-off-by: Jérôme Glisse > > Cc: Christian König > > Cc: Jan Kara > > Cc: Felix Kuehling > > Cc: Jason Gunthorpe > > Cc: Andrew Morton > > Cc: Matthew Wilcox > > Cc: Ross Zwisler > > Cc: Dan Williams > > Cc: Paolo Bonzini > > Cc: Radim Krčmář > > Cc: Michal Hocko > > Cc: Ralph Campbell > > Cc: John Hubbard > > Cc: kvm@vger.kernel.org > > Cc: dri-devel@lists.freedesktop.org > > Cc: linux-rdma@vger.kernel.org > > Cc: linux-fsdevel@vger.kernel.org > > Cc: Arnd Bergmann > > --- > > drivers/gpu/drm/i915/i915_gem_userptr.c | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > > > diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c > > index 9558582c105e..23330ac3d7ea 100644 > > --- a/drivers/gpu/drm/i915/i915_gem_userptr.c > > +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c > > @@ -59,6 +59,7 @@ struct i915_mmu_object { > > struct interval_tree_node it; > > struct list_head link; > > struct work_struct work; > > + bool read_only; > > bool attached; > > }; > > > > @@ -119,6 +120,7 @@ static int i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, > > container_of(_mn, struct i915_mmu_notifier, mn); > > struct i915_mmu_object *mo; > > struct interval_tree_node *it; > > + bool update_to_read_only; > > LIST_HEAD(cancelled); > > unsigned long end; > > > > @@ -128,6 +130,8 @@ static int i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, > > /* interval ranges are inclusive, but invalidate range is exclusive */ > > end = range->end - 1; > > > > + update_to_read_only = mmu_notifier_range_update_to_read_only(range); > > + > > spin_lock(&mn->lock); > > it = interval_tree_iter_first(&mn->objects, range->start, end); > > while (it) { > > @@ -145,6 +149,17 @@ static int i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, > > * object if it is not in the process of being destroyed. > > */ > > mo = container_of(it, struct i915_mmu_object, it); > > + > > + /* > > + * If it is already read only and we are updating to > > + * read only then we do not need to change anything. > > + * So save time and skip this one. > > + */ > > + if (update_to_read_only && mo->read_only) { > > + it = interval_tree_iter_next(it, range->start, end); > > + continue; > > + } > > + > > if (kref_get_unless_zero(&mo->obj->base.refcount)) > > queue_work(mn->wq, &mo->work); > > > > @@ -270,6 +285,7 @@ i915_gem_userptr_init__mmu_notifier(struct drm_i915_gem_object *obj, > > mo->mn = mn; > > mo->obj = obj; > > mo->it.start = obj->userptr.ptr; > > + mo->read_only = i915_gem_object_is_readonly(obj); > > mo->it.last = obj->userptr.ptr + obj->base.size - 1; > > INIT_WORK(&mo->work, cancel_userptr); > > > > -- > > 2.17.2 > > > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/dri-devel