From: Tejun Heo <tj@kernel.org>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Lai Jiangshan <jiangshanlai@gmail.com>,
Jens Axboe <axboe@kernel.dk>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-block@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [RFC 00/10] implement alternative and much simpler id allocator
Date: Fri, 9 Dec 2016 08:49:14 -0500 [thread overview]
Message-ID: <20161209134914.GC30394@mtj.duckdns.org> (raw)
In-Reply-To: <1481160187-9652-1-git-send-email-linux@rasmusvillemoes.dk>
Hello, Rasmus.
On Thu, Dec 08, 2016 at 02:22:55AM +0100, Rasmus Villemoes wrote:
> TL;DR: these patches save 250 KB of memory, with more low-hanging
> fruit ready to pick.
>
> While browsing through the lib/idr.c code, I noticed that the code at
> the end of ida_get_new_above() probably doesn't work as intended: Most
> users of ida use it via ida_simple_get(), and that starts by
> unconditionally calling ida_pre_get(), ensuring that ida->idr has
> 8==MAX_IDR_FREE idr_layers in its free list id_free. In the common
> case, none (or at most one) of these get used during
> ida_get_new_above(), and we only free one, leaving at least 6 (usually
> 7) idr_layers in the free list.
So, if you take a look at idr_layer_alloc(), there are two alternative
preloading mechanisms. The one based on per-idr freelist -
get_from_free_list() - and the one using per-cpu preload cache. idr
currently uses the new percpu path and ida uses the old path. There
isn't anything fundamental to this difference. It's just that we
introduced the new perpcu path to idr and haven't converted ida over
to it yet.
> Patches 1 and 2 are minor optimization opportunities, while patch 3 is
> an attempt at making the 'free the extra idr_layers one at a time'
> actually work. But it's not a very good solution, since it doesn't
> help the users who never do more than a handful of allocations, nor
> does it help those who call ida_pre_get/ida_get_new
> directly. Moreover, even if we somehow had perfect heuristics and got
> rid of all excess idr_layers and ida_bitmap (another 128 bytes we
> usually have hanging around), the minimum overhead of sizeof(struct
> idr_layer)+sizeof(struct ida_bitmap) ~ 2200 bytes is quite a lot for
> the many ida users who never allocate more than 100 ids.
>
> So instead/in addition, I suggest we introduce a much simpler
> allocator based on a dynamically growing bitmap. Patches 4-10
> introduce struct tida and has a few examples of replacing ida with
> tida. [Yeah, tida is not a good name, and probably _get and _put are also
> bad.]
So, instead of creating something new, it'd be a lot better to
implement the same per-cpu preload behavior for ida so that caching is
per-cpu instead of per-ida.
Thanks.
--
tejun
next prev parent reply other threads:[~2016-12-09 13:49 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-08 1:22 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 ` [RFC 09/10] drm: use simpler id allocator Rasmus Villemoes
2016-12-08 1:23 ` [RFC 10/10] fs/devpts: use tida for id allocation Rasmus Villemoes
2016-12-09 13:49 ` Tejun Heo [this message]
2016-12-09 22:01 ` [RFC 00/10] implement alternative and much simpler id allocator 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=20161209134914.GC30394@mtj.duckdns.org \
--to=tj@kernel.org \
--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-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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
Powered by JetHome