From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Tejun Heo <tj@kernel.org>, Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
Lai Jiangshan <jiangshanlai@gmail.com>,
Jens Axboe <axboe@kernel.dk>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
dri-devel@lists.freedesktop.org
Subject: [RFC 09/10] drm: use simpler id allocator
Date: Thu, 8 Dec 2016 02:23:04 +0100 [thread overview]
Message-ID: <1481160187-9652-10-git-send-email-linux@rasmusvillemoes.dk> (raw)
In-Reply-To: <1481160187-9652-1-git-send-email-linux@rasmusvillemoes.dk>
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 <linux@rasmusvillemoes.dk>
---
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 <linux/spinlock.h>
#include <linux/types.h>
#include <linux/idr.h>
+#include <linux/tida.h>
#include <linux/fb.h>
#include <linux/hdmi.h>
#include <linux/media-bus-format.h>
@@ -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.
*/
--
2.1.4
next prev parent reply other threads:[~2016-12-08 1:30 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-08 1:22 [RFC 00/10] implement alternative and much " Rasmus Villemoes
2016-12-08 1:22 ` [RFC 01/10] lib/idr.c: reused free bitmaps are already clear Rasmus Villemoes
2016-12-08 1:22 ` [RFC 02/10] lib/idr.c: delete useless condition Rasmus Villemoes
2016-12-08 1:22 ` [RFC 03/10] lib/idr.c: only fill ida->idr when needed Rasmus Villemoes
2016-12-08 1:22 ` [RFC 04/10] lib/tida.c: a very simple integer id allocator Rasmus Villemoes
2016-12-08 1:23 ` [RFC 05/10] kernel/workqueue.c: replace id allocator ida with tida Rasmus Villemoes
2016-12-08 1:23 ` [RFC 06/10] block: use tida as small id allocator Rasmus Villemoes
2016-12-08 3:56 ` Jens Axboe
2016-12-08 11:02 ` Greg Kroah-Hartman
2016-12-08 1:23 ` [RFC 07/10] drivers/base/platform.c: use simpler " Rasmus Villemoes
2016-12-08 1:23 ` [RFC 08/10] lib/tida.c: introduce tida_get_above Rasmus Villemoes
2016-12-08 1:23 ` Rasmus Villemoes [this message]
2016-12-08 1:23 ` [RFC 10/10] fs/devpts: use tida for id allocation Rasmus Villemoes
2016-12-09 13:49 ` [RFC 00/10] implement alternative and much simpler id allocator Tejun Heo
2016-12-09 22:01 ` Andrew Morton
2016-12-12 17:09 ` Tejun Heo
2016-12-12 17:35 ` Matthew Wilcox
2016-12-12 18:05 ` Tejun Heo
2016-12-16 19:14 ` Matthew Wilcox
2016-12-16 20:32 ` Rasmus Villemoes
2016-12-16 21:09 ` Matthew Wilcox
2016-12-17 13:28 ` Matthew Wilcox
2016-12-22 23:46 ` Rasmus Villemoes
2016-12-23 17:03 ` Matthew Wilcox
2016-12-18 2:42 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1481160187-9652-10-git-send-email-linux@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®