From patchwork Wed Jan 17 20:21:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10170739 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C852560386 for ; Wed, 17 Jan 2018 20:23:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7E16207A7 for ; Wed, 17 Jan 2018 20:23:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B66DF209D8; Wed, 17 Jan 2018 20:23:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7B5F26D05 for ; Wed, 17 Jan 2018 20:23:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754221AbeAQUXW (ORCPT ); Wed, 17 Jan 2018 15:23:22 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:56121 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753947AbeAQUXA (ORCPT ); Wed, 17 Jan 2018 15:23:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: 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=gxhRWbcJt7AX7Y95yQIm4Q1siXSpYAdP/qAVmMfyD+E=; b=e/oqTkra9Q31JRGihytyLluqF LFMamJMJCdFH7wNswd6oVa07+fPT4qXYcEaDFyvOyiTwIkITKvOTBuJNLYt7XzvnwAhXvcRwFzcyk 5aEO8uzmyDpuXxxrCfpeCOphMucjsALVXlJ8E+q1rjvJVJsaUXZ+XkMg25v5x8ZRoVyyzDKstFMsf oIZ1GY9HwPSrAjBqOiOea/cGJmrsyvCjf8c1Z19fQqM7x8rbBppvJkxP64di1ePahrqlDYNF3LiM6 uq48xKk9cg2xWxu6gLeH5VzYW+0cRlPu4O61xOi5NbpKkL/SoKZQMNXWdkZ7iEv5pIdl6Q08gyYLB zVqr/2QnA==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1ebuEd-0006F9-BM; Wed, 17 Jan 2018 20:22:59 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Cc: Matthew Wilcox , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-nilfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-usb@vger.kernel.org, Bjorn Andersson , Stefano Stabellini , iommu@lists.linux-foundation.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, intel-gfx@lists.freedesktop.org, cgroups@vger.kernel.org, linux-sh@vger.kernel.org, David Howells Subject: [PATCH v6 81/99] i915: Convert handles_vma to XArray Date: Wed, 17 Jan 2018 12:21:45 -0800 Message-Id: <20180117202203.19756-82-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180117202203.19756-1-willy@infradead.org> References: <20180117202203.19756-1-willy@infradead.org> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox Straightforward conversion. Signed-off-by: Matthew Wilcox --- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/i915/i915_gem_context.c | 12 +++++------- drivers/gpu/drm/i915/i915_gem_context.h | 4 ++-- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 6 +++--- drivers/gpu/drm/i915/selftests/mock_context.c | 2 +- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 25ce7bcf9988..69e944f4dfce 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -3351,7 +3351,7 @@ void i915_gem_close_object(struct drm_gem_object *gem, struct drm_file *file) if (ctx->file_priv != fpriv) continue; - vma = radix_tree_delete(&ctx->handles_vma, lut->handle); + vma = xa_erase(&ctx->handles_vma, lut->handle); GEM_BUG_ON(vma->obj != obj); /* We allow the process to have multiple handles to the same diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index f782cf2069c1..1aff35ba6e18 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -95,9 +95,9 @@ static void lut_close(struct i915_gem_context *ctx) { + XA_STATE(xas, &ctx->handles_vma, 0); struct i915_lut_handle *lut, *ln; - struct radix_tree_iter iter; - void __rcu **slot; + struct i915_vma *vma; list_for_each_entry_safe(lut, ln, &ctx->handles_list, ctx_link) { list_del(&lut->obj_link); @@ -105,10 +105,8 @@ static void lut_close(struct i915_gem_context *ctx) } rcu_read_lock(); - radix_tree_for_each_slot(slot, &ctx->handles_vma, &iter, 0) { - struct i915_vma *vma = rcu_dereference_raw(*slot); - - radix_tree_iter_delete(&ctx->handles_vma, &iter, slot); + xas_for_each(&xas, vma, ULONG_MAX) { + xas_store(&xas, NULL); __i915_gem_object_release_unless_active(vma->obj); } rcu_read_unlock(); @@ -276,7 +274,7 @@ __create_hw_context(struct drm_i915_private *dev_priv, ctx->i915 = dev_priv; ctx->priority = I915_PRIORITY_NORMAL; - INIT_RADIX_TREE(&ctx->handles_vma, GFP_KERNEL); + xa_init(&ctx->handles_vma); INIT_LIST_HEAD(&ctx->handles_list); /* Default context will never have a file_priv */ diff --git a/drivers/gpu/drm/i915/i915_gem_context.h b/drivers/gpu/drm/i915/i915_gem_context.h index 44688e22a5c2..8e3e0d002f77 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.h +++ b/drivers/gpu/drm/i915/i915_gem_context.h @@ -181,11 +181,11 @@ struct i915_gem_context { /** remap_slice: Bitmask of cache lines that need remapping */ u8 remap_slice; - /** handles_vma: rbtree to look up our context specific obj/vma for + /** handles_vma: lookup our context specific obj/vma for * the user handle. (user handles are per fd, but the binding is * per vm, which may be one per context or shared with the global GTT) */ - struct radix_tree_root handles_vma; + struct xarray handles_vma; /** handles_list: reverse list of all the rbtree entries in use for * this context, which allows us to free all the allocations on diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 435ed95df144..828f4b5473ea 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -683,7 +683,7 @@ static int eb_select_context(struct i915_execbuffer *eb) static int eb_lookup_vmas(struct i915_execbuffer *eb) { - struct radix_tree_root *handles_vma = &eb->ctx->handles_vma; + struct xarray *handles_vma = &eb->ctx->handles_vma; struct drm_i915_gem_object *obj; unsigned int i; int err; @@ -702,7 +702,7 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb) struct i915_lut_handle *lut; struct i915_vma *vma; - vma = radix_tree_lookup(handles_vma, handle); + vma = xa_load(handles_vma, handle); if (likely(vma)) goto add_vma; @@ -724,7 +724,7 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb) goto err_obj; } - err = radix_tree_insert(handles_vma, handle, vma); + err = xa_err(xa_store(handles_vma, handle, vma, GFP_KERNEL)); if (unlikely(err)) { kfree(lut); goto err_obj; diff --git a/drivers/gpu/drm/i915/selftests/mock_context.c b/drivers/gpu/drm/i915/selftests/mock_context.c index bbf80d42e793..b664a7159242 100644 --- a/drivers/gpu/drm/i915/selftests/mock_context.c +++ b/drivers/gpu/drm/i915/selftests/mock_context.c @@ -40,7 +40,7 @@ mock_context(struct drm_i915_private *i915, INIT_LIST_HEAD(&ctx->link); ctx->i915 = i915; - INIT_RADIX_TREE(&ctx->handles_vma, GFP_KERNEL); + xa_init(&ctx->handles_vma); INIT_LIST_HEAD(&ctx->handles_list); ret = ida_simple_get(&i915->contexts.hw_ida,