Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

idr: reorder the fields

idr_layer->layer is always accessed in read path, move it in the front.

idr_layer->bitmap is moved on the bottom. And rcu_head shares with
bitmap due to they do not be accessed at the same time.

idr->id_free/id_free_cnt/lock are free list fields, and moved to the
bottom. They will be removed in near future.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Lai Jiangshan and committed by
Linus Torvalds
dcbff5d1 15f3ec3f

+8 -5
+8 -5
include/linux/idr.h
··· 29 29 30 30 struct idr_layer { 31 31 int prefix; /* the ID prefix of this idr_layer */ 32 - DECLARE_BITMAP(bitmap, IDR_SIZE); /* A zero bit means "space here" */ 32 + int layer; /* distance from leaf */ 33 33 struct idr_layer __rcu *ary[1<<IDR_BITS]; 34 34 int count; /* When zero, we can release it */ 35 - int layer; /* distance from leaf */ 36 - struct rcu_head rcu_head; 35 + union { 36 + /* A zero bit means "space here" */ 37 + DECLARE_BITMAP(bitmap, IDR_SIZE); 38 + struct rcu_head rcu_head; 39 + }; 37 40 }; 38 41 39 42 struct idr { 40 43 struct idr_layer __rcu *hint; /* the last layer allocated from */ 41 44 struct idr_layer __rcu *top; 42 - struct idr_layer *id_free; 43 45 int layers; /* only valid w/o concurrent changes */ 44 - int id_free_cnt; 45 46 int cur; /* current pos for cyclic allocation */ 46 47 spinlock_t lock; 48 + int id_free_cnt; 49 + struct idr_layer *id_free; 47 50 }; 48 51 49 52 #define IDR_INIT(name) \