Received: by 10.223.164.202 with SMTP id h10csp657904wrb; Wed, 22 Nov 2017 13:11:08 -0800 (PST) X-Google-Smtp-Source: AGs4zMbaXLP7TDlJVNvTCfnVE4yo2gXG9iwXr5RkKk4TYFvC83FNzj37iUpuSRTTPbDsw0ud6vpo X-Received: by 10.159.195.69 with SMTP id z5mr22612670pln.183.1511385068438; Wed, 22 Nov 2017 13:11:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385068; cv=none; d=google.com; s=arc-20160816; b=j4icrOUeNehhBva+toNzfPyt5De1l6OhLVqdcm/2dqLnHSX2najGavu/qOMzVJszyT 9xdVbqN6Rvkb7KjHC0IvTcn+KP6HcUwDaQwFdW5co1kby710PwJ/2nTl/Exa45bXBWz4 Eku4mqs8iBazzcOVYGEMzKp5VXurKUQ744ovuyF9HJesL6l7urLP0OgighPsfuGcd/KZ QGVjPmn96SnHvG46etwXgjCvSY16EAQx2tyAhacvVr+V2W39dB2rEYhiQ+urJrwq1Cw8 y5vYSrigw9hc/8iCUrR6Kvm1fdajGM4Ir5pRw9HfiIXYcVZqEuu6Kn7Kg9qxq2raUF9/ dHEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ZMYWclJwc04pfKKTDL+wG25LvMRFkKtQOc9M89vWi0Y=; b=DDiHrIwx7pYKWZNJDj3Iq8Nl7rtMwy0t9XaT1jMt2IpoNCV1V43/AMVhsIiRenBWFc 9rDG18z5XROmidwxruMogdwKusmi10hN76kUyfeApjYKEpe1/7owqsb0hoXlwphfDZQp kioCy/2ZV56XiKsPNKFmdAL2u3Ccmlt/p0pbndIrJVSS/SmP9VY/x1QSdlJVDSfobiEl mXYrKzl2axdPysEUkB9BLG4Qi73p+c7H93QpgbMVPo4Rmf1+Ap7EhiqnH7/ypi1+UJD8 FPodlQKmB0M1fUtnNoT4L0iN2vXkL00MS+cGKa6JYy9H+McmsQY4V7oE5YnKQ4A4noGD ODWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=sdDZw+Ow; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g92si14164303plg.247.2017.11.22.13.10.57; Wed, 22 Nov 2017 13:11:08 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=sdDZw+Ow; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752120AbdKVVJU (ORCPT + 77 others); Wed, 22 Nov 2017 16:09:20 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:41193 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751885AbdKVVIU (ORCPT ); Wed, 22 Nov 2017 16:08:20 -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=ZMYWclJwc04pfKKTDL+wG25LvMRFkKtQOc9M89vWi0Y=; b=sdDZw+OwuUtiHkx8pRwyTATKj yuUYSpvLEqOdVXia/CNlWSSB5I9RZgFWUx7GkK6EteSwF3KcYpx9MGczh8pdync5Z+xw8D0fZ/zTu EVZSjeU1dWrG0B6y49gNUV9zWscvKAT54ULeyCQ+kJjmhfLipPZSbgQ7olZ/CQ5LoaUb8TcoVB3C2 HNJVKYhzzT9FUlRYlpQNlkGumCnn7+LE2G1qgsRiy2yeS9qAFchP3y2dnC5TGW9F3jj5k4a5NiRQp P9/l5pKYozAM94fpwiUydB+/VwCzNrfnOXUmo2CWvjL4yA0cn34nHy3TwNxprz3d3CaWw9H4Xr6DL Z9qt11NdA==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFo-0007z2-GL; Wed, 22 Nov 2017 21:08:20 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 60/62] drm: Replace vmwgfx IDRs with IDAs Date: Wed, 22 Nov 2017 13:07:37 -0800 Message-Id: <20171122210739.29916-61-willy@infradead.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox These IDRs were only being used to allocate unique numbers, not to look up pointers, so they can use the more space-efficient IDA instead. Signed-off-by: Matthew Wilcox --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 6 +++--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 28 ++++++++++------------------ 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 184340d486c3..fc6e04cf071e 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -652,7 +652,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) spin_lock_init(&dev_priv->cursor_lock); for (i = vmw_res_context; i < vmw_res_max; ++i) { - idr_init(&dev_priv->res_idr[i]); + ida_init(&dev_priv->res_ida[i]); INIT_LIST_HEAD(&dev_priv->res_lru[i]); } @@ -950,7 +950,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) vmw_ttm_global_release(dev_priv); out_err0: for (i = vmw_res_context; i < vmw_res_max; ++i) - idr_destroy(&dev_priv->res_idr[i]); + ida_destroy(&dev_priv->res_ida[i]); if (dev_priv->ctx.staged_bindings) vmw_binding_state_free(dev_priv->ctx.staged_bindings); @@ -1002,7 +1002,7 @@ static void vmw_driver_unload(struct drm_device *dev) vmw_ttm_global_release(dev_priv); for (i = vmw_res_context; i < vmw_res_max; ++i) - idr_destroy(&dev_priv->res_idr[i]); + ida_destroy(&dev_priv->res_ida[i]); kfree(dev_priv); } diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 7e5f30e234b1..96866a1e3547 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -429,7 +429,7 @@ struct vmw_private { */ rwlock_t resource_lock; - struct idr res_idr[vmw_res_max]; + struct ida res_ida[vmw_res_max]; /* * Block lastclose from racing with firstopen. */ diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index a96f90f017d1..ca0e2a1fd0c5 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c @@ -80,13 +80,11 @@ vmw_resource_reference_unless_doomed(struct vmw_resource *res) void vmw_resource_release_id(struct vmw_resource *res) { struct vmw_private *dev_priv = res->dev_priv; - struct idr *idr = &dev_priv->res_idr[res->func->res_type]; + struct ida *ida = &dev_priv->res_ida[res->func->res_type]; - write_lock(&dev_priv->resource_lock); if (res->id != -1) - idr_remove(idr, res->id); + ida_simple_remove(ida, res->id); res->id = -1; - write_unlock(&dev_priv->resource_lock); } static void vmw_resource_release(struct kref *kref) @@ -95,7 +93,7 @@ static void vmw_resource_release(struct kref *kref) container_of(kref, struct vmw_resource, kref); struct vmw_private *dev_priv = res->dev_priv; int id; - struct idr *idr = &dev_priv->res_idr[res->func->res_type]; + struct ida *ida = &dev_priv->res_ida[res->func->res_type]; write_lock(&dev_priv->resource_lock); res->avail = false; @@ -132,10 +130,8 @@ static void vmw_resource_release(struct kref *kref) else kfree(res); - write_lock(&dev_priv->resource_lock); if (id != -1) - idr_remove(idr, id); - write_unlock(&dev_priv->resource_lock); + ida_simple_remove(ida, id); } void vmw_resource_unreference(struct vmw_resource **p_res) @@ -159,20 +155,16 @@ int vmw_resource_alloc_id(struct vmw_resource *res) { struct vmw_private *dev_priv = res->dev_priv; int ret; - struct idr *idr = &dev_priv->res_idr[res->func->res_type]; + struct ida *ida = &dev_priv->res_ida[res->func->res_type]; BUG_ON(res->id != -1); - idr_preload(GFP_KERNEL); - write_lock(&dev_priv->resource_lock); - - ret = idr_alloc(idr, res, 1, 0, GFP_NOWAIT); - if (ret >= 0) - res->id = ret; + ret = ida_simple_get(ida, 1, 0, GFP_KERNEL); + if (ret < 0) + return ret; - write_unlock(&dev_priv->resource_lock); - idr_preload_end(); - return ret < 0 ? ret : 0; + res->id = ret; + return 0; } /** -- 2.15.0 From 1584802647015493309@xxx Wed Nov 22 21:19:41 +0000 2017 X-GM-THRID: 1584802647015493309 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread