From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Tejun Heo <tj@kernel.org>, Lai Jiangshan <laijs@cn.fujitsu.com>,
Jean Delvare <jdelvare@suse.de>,
Monam Agarwal <monamagarwal123@gmail.com>,
Jeff Layton <jlayton@redhat.com>,
Andreas Gruenbacher <agruen@linbit.com>,
Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH 2/4] idr: reduce the number of MAX_IDR_FREE
Date: Tue, 22 Apr 2014 18:16:19 +0800 [thread overview]
Message-ID: <1398161781-12105-3-git-send-email-laijs@cn.fujitsu.com> (raw)
In-Reply-To: <1398161781-12105-1-git-send-email-laijs@cn.fujitsu.com>
Whe need to prepare MAX_IDR_FREE idr_layers for allocation.
But when idr is not empty, we need atmost (MAX_IDR_LEVEL - 1) idr_layers
to build up and atmost (MAX_IDR_LEVEL - 1) idr_layers to allocate down.
When idr is empty need atmost MAX_IDR_LEVEL layers.
So max((MAX_IDR_LEVEL * 2 - 2), MAX_IDR_LEVEL) idr_layers is enough.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
lib/idr.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/idr.c b/lib/idr.c
index 87c98fc..871991b 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -36,8 +36,13 @@
/* Leave the possibility of an incomplete final layer */
#define MAX_IDR_LEVEL ((MAX_IDR_SHIFT + IDR_BITS - 1) / IDR_BITS)
-/* Number of id_layer structs to leave in free list */
-#define MAX_IDR_FREE (MAX_IDR_LEVEL * 2)
+/*
+ * Number of idr_layer structs to leave in free list.
+ * When idr is not empty, we need atmost (MAX_IDR_LEVEL - 1) idr_layers
+ * to build up and atmost (MAX_IDR_LEVEL - 1) idr_layers to allocate down.
+ * When idr is empty need atmost MAX_IDR_LEVEL layers.
+ */
+#define MAX_IDR_FREE max((MAX_IDR_LEVEL * 2 - 2), MAX_IDR_LEVEL)
static struct kmem_cache *idr_layer_cache;
static DEFINE_PER_CPU(struct idr_layer *, idr_preload_head);
--
1.7.4.4
next prev parent reply other threads:[~2014-04-22 10:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-22 10:16 [PATCH 0/4] idr: idr cleanups Lai Jiangshan
2014-04-22 10:16 ` [PATCH 1/4] idr: proper invalid argument handling Lai Jiangshan
2014-04-22 19:16 ` Andrew Morton
2014-04-22 19:46 ` Andrew Morton
2014-04-22 19:54 ` Tejun Heo
2014-04-22 10:16 ` Lai Jiangshan [this message]
2014-04-22 19:58 ` [PATCH 2/4] idr: reduce the number of MAX_IDR_FREE Tejun Heo
2014-04-23 1:55 ` Lai Jiangshan
2014-04-22 10:16 ` [PATCH 3/4] ida: in-place ida allocation Lai Jiangshan
2014-04-22 20:02 ` Tejun Heo
2014-04-23 1:44 ` Lai Jiangshan
2014-04-22 10:16 ` [PATCH 4/4] idr: reorder the fields Lai Jiangshan
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=1398161781-12105-3-git-send-email-laijs@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=agruen@linbit.com \
--cc=akpm@linux-foundation.org \
--cc=jdelvare@suse.de \
--cc=jlayton@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=monamagarwal123@gmail.com \
--cc=stephen@networkplumber.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®