From patchwork Thu Dec 8 01:23:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 9467363 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 0C88060231 for ; Fri, 9 Dec 2016 01:41:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F242928534 for ; Fri, 9 Dec 2016 01:41:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E67C128615; Fri, 9 Dec 2016 01:41:19 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 832DF28534 for ; Fri, 9 Dec 2016 01:41:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC86A6E8C7; Fri, 9 Dec 2016 01:40:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wj0-x230.google.com (mail-wj0-x230.google.com [IPv6:2a00:1450:400c:c01::230]) by gabe.freedesktop.org (Postfix) with ESMTPS id BCB2A6E59B for ; Thu, 8 Dec 2016 01:23:31 +0000 (UTC) Received: by mail-wj0-x230.google.com with SMTP id v7so376316249wjy.2 for ; Wed, 07 Dec 2016 17:23:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UEAVmp05KhAFSIG5+tW4m1m8MA+IoYxL8dQJjYQB7c4=; b=b0xUti8wvxYH6RbiZPl7ucJ0JmwfrEOlK8TUKludZYIXc2vsUtGpk4KF8EiqiXtEsa VACaF7tqv6EcIvmEkI4j3yqjXIxD064AcCf1rqSERl1beBVsyZFMbxqleKjeYZ8NZOnX 2fj9CviEEMmCziDkH3+wjFTvc8N4MU3zPdgP0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UEAVmp05KhAFSIG5+tW4m1m8MA+IoYxL8dQJjYQB7c4=; b=hQdkuFkF+ZjjYcvHdKr8WrbkXziL/tzbeBT1kVelWR7soWG0SHsXVKNhBqP9ItgB9e UJMwaInoQf9LwxXOg5u2z0A1TyHKFdGYx/3dRl2nJelK/w70e2i+GNV7CCA8gtsUH48e WsHtRtLKAKnmjIq/gg6AsLhRbmSFUMkiNxlwqQ6+uvDT7aAs/8ZgkK4JxodN8XGMRyFA b1pYJm8BWpYy4v5n70DY62tBACxqbHvFDY8WAI3j7zO/BINQjCwChXWM0WdhpOSjfzvK l+kxU9R3QOCN742qKbxCHppOI/n640dKZREGuddgI1Ux66xJNhTSJUebaggue4U1ucjd qxHA== X-Gm-Message-State: AKaTC01CNeImwoW2L0rUv4aLS9Aqleggzgk6m/1CjS1vyRKeAvrivNds57a0WXI8AKxabw== X-Received: by 10.194.201.103 with SMTP id jz7mr68242240wjc.70.1481160210147; Wed, 07 Dec 2016 17:23:30 -0800 (PST) Received: from lvps87-230-87-209.dedicated.hosteurope.de (wildmoose.dk. [87.230.87.209]) by smtp.gmail.com with ESMTPSA id bj1sm34218689wjc.17.2016.12.07.17.23.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Dec 2016 17:23:29 -0800 (PST) From: Rasmus Villemoes To: Tejun Heo , Andrew Morton Subject: [RFC 09/10] drm: use simpler id allocator Date: Thu, 8 Dec 2016 02:23:04 +0100 Message-Id: <1481160187-9652-10-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1481160187-9652-1-git-send-email-linux@rasmusvillemoes.dk> References: <1481160187-9652-1-git-send-email-linux@rasmusvillemoes.dk> X-Mailman-Approved-At: Fri, 09 Dec 2016 01:39:51 +0000 Cc: Jens Axboe , Rasmus Villemoes , Greg Kroah-Hartman , Lai Jiangshan , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Using the recently introduced "tida" allocator for small integer ids saves about 100 KB of memory on my laptop - every struct ida from which a single id has been allocated uses at least 16 KB of memory due to the pre-allocation/caching of struct idr_layers (each worth a little over 2K). Signed-off-by: Rasmus Villemoes --- drivers/gpu/drm/drm_connector.c | 21 ++++++++++----------- drivers/gpu/drm/drm_crtc.c | 4 ++-- include/drm/drm_crtc.h | 3 ++- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 2db7fb510b6c..70e5f3b84f2a 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -61,7 +61,7 @@ struct drm_conn_prop_enum_list { int type; const char *name; - struct ida ida; + struct tida ida; }; /* @@ -93,7 +93,7 @@ void drm_connector_ida_init(void) int i; for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++) - ida_init(&drm_connector_enum_list[i].ida); + tida_init(&drm_connector_enum_list[i].ida); } void drm_connector_ida_destroy(void) @@ -101,7 +101,7 @@ void drm_connector_ida_destroy(void) int i; for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++) - ida_destroy(&drm_connector_enum_list[i].ida); + tida_destroy(&drm_connector_enum_list[i].ida); } /** @@ -186,7 +186,7 @@ int drm_connector_init(struct drm_device *dev, { struct drm_mode_config *config = &dev->mode_config; int ret; - struct ida *connector_ida = + struct tida *connector_ida = &drm_connector_enum_list[connector_type].ida; drm_modeset_lock_all(dev); @@ -201,7 +201,7 @@ int drm_connector_init(struct drm_device *dev, connector->dev = dev; connector->funcs = funcs; - ret = ida_simple_get(&config->connector_ida, 0, 0, GFP_KERNEL); + ret = tida_get(&config->connector_ida, GFP_KERNEL); if (ret < 0) goto out_put; connector->index = ret; @@ -209,7 +209,7 @@ int drm_connector_init(struct drm_device *dev, connector->connector_type = connector_type; connector->connector_type_id = - ida_simple_get(connector_ida, 1, 0, GFP_KERNEL); + tida_get_above(connector_ida, 1, GFP_KERNEL); if (connector->connector_type_id < 0) { ret = connector->connector_type_id; goto out_put_id; @@ -250,10 +250,10 @@ int drm_connector_init(struct drm_device *dev, connector->debugfs_entry = NULL; out_put_type_id: if (ret) - ida_simple_remove(connector_ida, connector->connector_type_id); + tida_put(connector_ida, connector->connector_type_id); out_put_id: if (ret) - ida_simple_remove(&config->connector_ida, connector->index); + tida_put(&config->connector_ida, connector->index); out_put: if (ret) drm_mode_object_unregister(dev, &connector->base); @@ -341,11 +341,10 @@ void drm_connector_cleanup(struct drm_connector *connector) list_for_each_entry_safe(mode, t, &connector->modes, head) drm_mode_remove(connector, mode); - ida_simple_remove(&drm_connector_enum_list[connector->connector_type].ida, + tida_put(&drm_connector_enum_list[connector->connector_type].ida, connector->connector_type_id); - ida_simple_remove(&dev->mode_config.connector_ida, - connector->index); + tida_put(&dev->mode_config.connector_ida, connector->index); kfree(connector->display_info.bus_formats); drm_mode_object_unregister(dev, &connector->base); diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 2d7bedf28647..c38cda9bdf09 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1075,7 +1075,7 @@ void drm_mode_config_init(struct drm_device *dev) INIT_LIST_HEAD(&dev->mode_config.plane_list); idr_init(&dev->mode_config.crtc_idr); idr_init(&dev->mode_config.tile_idr); - ida_init(&dev->mode_config.connector_ida); + tida_init(&dev->mode_config.connector_ida); drm_modeset_lock_all(dev); drm_mode_create_standard_properties(dev); @@ -1156,7 +1156,7 @@ void drm_mode_config_cleanup(struct drm_device *dev) drm_framebuffer_free(&fb->base.refcount); } - ida_destroy(&dev->mode_config.connector_ida); + tida_destroy(&dev->mode_config.connector_ida); idr_destroy(&dev->mode_config.tile_idr); idr_destroy(&dev->mode_config.crtc_idr); drm_modeset_lock_fini(&dev->mode_config.connection_mutex); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 0aa292526567..3f5255b801e2 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -1045,7 +1046,7 @@ struct drm_mode_config { /** * @connector_ida: ID allocator for connector indices. */ - struct ida connector_ida; + struct tida connector_ida; /** * @connector_list: List of connector objects. */