Tejun Heo
d5c7409f79
idr: implement idr_preload[_end]() and idr_alloc()
...
The current idr interface is very cumbersome.
* For all allocations, two function calls - idr_pre_get() and
idr_get_new*() - should be made.
* idr_pre_get() doesn't guarantee that the following idr_get_new*()
will not fail from memory shortage. If idr_get_new*() returns
-EAGAIN, the caller is expected to retry pre_get and allocation.
* idr_get_new*() can't enforce upper limit. Upper limit can only be
enforced by allocating and then freeing if above limit.
* idr_layer buffer is unnecessarily per-idr. Each idr ends up keeping
around MAX_IDR_FREE idr_layers. The memory consumed per idr is
under two pages but it makes it difficult to make idr_layer larger.
This patch implements the following new set of allocation functions.
* idr_preload[_end]() - Similar to radix preload but doesn't fail.
The first idr_alloc() inside preload section can be treated as if it
were called with @gfp_mask used for idr_preload().
* idr_alloc() - Allocate an ID w/ lower and upper limits. Takes
@gfp_flags and can be used w/o preloading. When used inside
preloaded section, the allocation mask of preloading can be assumed.
If idr_alloc() can be called from a context which allows sufficiently
relaxed @gfp_mask, it can be used by itself. If, for example,
idr_alloc() is called inside spinlock protected region, preloading can
be used like the following.
idr_preload(GFP_KERNEL);
spin_lock(lock);
id = idr_alloc(idr, ptr, start, end, GFP_NOWAIT);
spin_unlock(lock);
idr_preload_end();
if (id < 0)
error;
which is much simpler and less error-prone than idr_pre_get and
idr_get_new*() loop.
The new interface uses per-pcu idr_layer buffer and thus the number of
idr's in the system doesn't affect the amount of memory used for
preloading.
idr_layer_alloc() is introduced to handle idr_layer allocations for
both old and new ID allocation paths. This is a bit hairy now but the
new interface is expected to replace the old and the internal
implementation eventually will become simpler.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-27 19:10:14 -08:00
..
2013-02-26 09:24:48 -08:00
2013-02-08 13:16:17 -05:00
2013-01-28 18:17:25 -05:00
2012-12-20 14:00:13 -08:00
2013-02-21 15:27:22 -08:00
2013-02-13 08:35:43 -08:00
2013-01-03 15:41:20 +01:00
2013-01-02 17:36:10 -08:00
2013-02-14 00:22:52 +01:00
2013-02-09 15:22:14 +00:00
2013-02-20 11:00:43 -08:00
2013-02-11 18:58:34 +00:00
2013-02-22 23:31:31 -05:00
2013-02-27 19:10:09 -08:00
2013-02-26 11:41:08 -08:00
2013-02-24 14:37:22 -05:00
2012-12-03 16:36:52 +02:00
2013-02-05 04:07:35 +01:00
2012-11-30 12:01:30 -05:00
2013-02-13 06:16:08 -08:00
2013-02-15 09:52:29 +01:00
2013-02-26 11:09:17 -08:00
2013-02-16 13:34:10 -08:00
2013-01-02 17:36:10 -08:00
2012-12-24 16:34:11 +00:00
2013-02-22 09:20:11 -08:00
2013-02-21 12:11:44 -08:00
2013-02-08 13:16:17 -05:00
2013-02-25 16:00:49 -08:00
2013-02-21 15:27:22 -08:00
2013-01-29 11:47:06 +01:00
2013-02-23 17:50:14 -08:00
2013-01-03 14:34:06 -08:00
2012-12-14 13:06:41 +10:30
2013-01-23 09:32:30 -08:00
2013-01-03 15:57:16 -08:00
2013-01-14 13:29:15 -05:00
2012-12-10 15:49:57 -05:00
2012-12-02 00:05:12 +00:00
2013-01-11 14:54:56 -08:00
2013-02-21 17:22:19 -08:00
2012-12-17 17:15:16 -08:00
2012-12-11 17:22:26 -08:00
2012-12-06 14:58:56 -05:00
2013-02-26 02:46:13 -05:00
2012-12-19 07:18:35 -08:00
2013-02-15 18:52:45 -08:00
2013-02-23 17:50:12 -08:00
2012-12-06 14:33:02 +01:00
2013-02-21 17:22:16 -08:00
2013-01-24 12:05:18 -08:00
2013-01-24 11:09:28 -08:00
2013-01-31 22:15:36 +01:00
2013-01-31 19:57:30 -08:00
2013-02-13 06:00:53 -08:00
2013-02-23 17:50:10 -08:00
2013-02-14 09:21:15 -05:00
2013-02-21 17:22:15 -08:00
2013-02-21 17:22:15 -08:00
2013-02-21 17:22:15 -08:00
2012-12-06 01:22:31 +00:00
2013-02-21 17:22:16 -08:00
2013-02-25 16:46:44 -08:00
2013-01-26 17:37:17 +01:00
2012-11-29 00:01:25 -05:00
2013-01-11 14:54:54 -08:00
2013-02-02 01:29:32 +01:00
2013-02-11 18:49:51 -05:00
2012-12-12 17:38:32 -08:00
2013-01-09 08:26:53 -08:00
2013-02-26 02:46:09 -05:00
2013-02-27 19:10:11 -08:00
2013-01-18 15:25:53 -08:00
2012-11-26 19:17:44 +09:00
2012-12-21 20:23:41 +00:00
2013-02-21 12:05:51 -08:00
2012-11-29 03:30:34 -08:00
2013-01-29 10:48:30 +01:00
2012-12-11 09:28:09 +01:00
2013-02-14 20:00:53 +05:30
2012-12-24 09:36:38 -07:00
2013-01-07 22:04:14 -08:00
2013-01-17 12:19:09 -08:00
2012-11-28 11:54:40 +01:00
2013-02-21 09:38:18 -08:00
2013-01-18 14:05:56 -08:00
2013-02-26 02:46:08 -05:00
2013-01-21 14:07:44 -05:00
2012-12-20 14:04:11 -08:00
2012-12-11 13:43:45 +09:00
2013-01-24 09:04:04 +01:00
2012-11-28 21:49:02 -05:00
2013-02-23 17:50:12 -08:00
2013-02-27 19:10:11 -08:00
2012-11-28 21:49:02 -05:00
2013-02-26 20:16:07 -08:00
2012-12-20 22:34:00 +00:00
2012-12-20 22:04:07 +00:00
2012-11-26 13:41:19 -06:00
2012-12-11 13:44:36 -05:00
2013-02-22 23:31:31 -05:00
2013-01-30 11:02:06 -05:00
2013-01-21 13:22:35 -05:00
2013-02-26 03:10:52 +11:00
2012-12-18 15:02:12 -08:00
2013-01-22 10:23:35 +01:00
2013-02-19 18:19:48 -08:00
2012-12-06 10:39:54 +01:00
2013-02-22 08:20:05 +01:00
2013-01-06 11:48:11 +00:00
2013-01-06 11:41:12 +00:00
2013-02-21 10:45:01 +01:00
2013-02-23 17:50:16 -08:00
2013-02-23 17:50:17 -08:00
2012-12-18 15:02:15 -08:00
2013-02-26 20:16:07 -08:00
2013-01-25 21:03:54 -08:00
2013-01-25 11:17:31 -08:00
2012-11-28 11:36:32 +01:00
2012-11-23 12:23:40 +01:00
2013-02-27 19:10:14 -08:00
2013-02-15 09:41:42 +01:00
2013-02-06 15:59:47 -05:00
2013-02-06 15:48:09 -05:00
2013-02-23 21:00:06 -05:00
2012-12-14 13:05:26 +10:30
2013-02-11 14:16:26 -05:00
2013-01-29 13:59:57 -05:00
2013-02-19 08:06:01 +01:00
2013-01-23 09:31:01 -08:00
2013-01-11 14:54:54 -08:00
2013-02-06 10:47:28 +01:00
2012-12-09 00:20:28 -05:00
2013-01-04 16:11:45 -08:00
2013-01-30 22:41:13 -05:00
2013-02-05 00:48:46 +01:00
2013-01-28 12:17:25 +01:00
2013-01-10 11:44:38 -06:00
2013-02-09 16:29:20 -05:00
2013-01-27 19:23:27 +01:00
2013-01-21 17:17:57 +10:30
2013-01-29 19:32:58 -08:00
2012-12-16 15:40:50 -08:00
2013-02-04 15:35:26 -08:00
2012-11-28 10:33:03 -08:00
2013-01-21 13:22:36 -05:00
2013-02-23 17:50:19 -08:00
2013-02-24 13:07:18 -08:00
2013-02-01 17:47:04 -08:00
2012-11-26 14:28:51 -08:00
2013-01-25 15:30:23 -05:00
2013-01-06 01:11:25 -08:00
2012-12-17 21:55:56 -05:00
2013-02-22 19:25:09 -08:00
2012-11-30 11:48:05 +01:00
2012-12-17 13:39:11 -08:00
2013-02-02 00:01:15 +01:00
2013-02-23 17:50:14 -08:00
2013-02-23 17:50:20 -08:00
2013-02-23 17:50:13 -08:00
2012-12-12 17:38:33 -08:00
2013-01-02 17:32:13 -08:00
2013-01-28 18:42:10 -05:00
2013-02-23 17:50:19 -08:00
2012-12-01 10:07:54 +00:00
2013-02-23 17:50:17 -08:00
2013-02-23 17:50:23 -08:00
2013-02-23 17:50:11 -08:00
2013-02-05 20:38:48 +11:00
2013-02-23 17:50:20 -08:00
2013-01-21 17:18:20 +10:30
2012-12-14 13:06:40 +10:30
2013-01-21 13:55:14 -05:00
2013-01-21 13:55:14 -05:00
2013-01-04 16:11:45 -08:00
2012-12-25 18:45:06 -05:00
2013-02-15 15:17:11 -05:00
2013-02-19 13:18:13 -05:00
2013-02-11 19:19:33 -05:00
2013-02-13 06:16:06 -08:00
2012-12-06 00:30:46 +01:00
2013-02-13 06:15:29 -08:00
2013-02-13 06:15:28 -08:00
2012-12-11 17:22:27 -08:00
2012-12-12 17:38:34 -08:00
2013-01-17 19:11:14 -08:00
2012-11-23 22:01:15 +00:00
2013-01-07 22:05:02 -08:00
2013-02-13 10:11:53 +00:00
2012-12-11 17:30:16 +00:00
2012-12-19 16:15:17 +00:00
2013-02-13 10:09:31 +00:00
2012-11-30 08:41:50 -08:00
2012-12-11 17:22:27 -08:00
2012-11-26 11:33:18 -08:00
2013-02-23 00:30:08 +01:00
2013-02-23 17:50:17 -08:00
2013-02-14 15:55:23 +01:00
2013-02-23 17:50:15 -08:00
2013-02-21 17:22:19 -08:00
2013-02-21 13:41:04 -08:00
2013-02-25 21:18:18 -08:00
2013-02-05 11:54:06 +01:00
2012-12-17 17:15:18 -08:00
2013-02-08 18:28:02 +01:00
2013-01-14 15:11:50 -05:00
2012-12-25 16:10:05 -08:00
2012-12-25 16:10:05 -08:00
2013-01-17 17:39:33 -08:00
2013-01-23 14:39:19 +00:00
2013-02-23 17:50:16 -08:00
2013-02-23 17:50:16 -08:00
2013-02-21 12:05:51 -08:00
2013-02-13 09:40:35 -08:00
2013-02-21 17:38:49 -08:00
2013-02-21 13:41:04 -08:00
2013-01-24 15:37:26 +01:00
2013-01-03 15:57:14 -08:00
2013-01-11 10:20:50 -08:00
2013-01-20 12:26:05 -08:00
2012-11-27 23:29:12 -02:00
2013-02-26 09:34:29 -08:00
2013-02-08 13:14:40 +00:00
2013-01-24 23:24:56 -05:00
2013-01-23 13:44:00 -05:00
2013-01-11 14:54:56 -08:00
2013-01-28 22:25:21 -08:00
2013-02-14 17:11:09 +00:00
2012-12-18 15:02:12 -08:00
2013-01-30 11:01:53 -05:00
2013-02-23 17:50:17 -08:00
2013-02-21 12:05:51 -08:00
2013-01-16 12:13:20 -08:00
2013-02-27 19:10:10 -08:00
2013-02-27 19:10:11 -08:00
2013-01-14 18:16:59 -05:00
2013-02-19 08:43:34 +01:00
2013-01-15 23:03:00 -08:00
2013-02-13 10:13:58 -08:00
2012-12-11 17:22:25 -08:00
2013-02-03 15:09:26 -05:00
2013-02-15 15:17:11 -05:00
2012-12-18 15:02:13 -08:00
2012-12-18 15:02:14 -08:00
2012-12-18 15:02:14 -08:00
2013-02-21 17:22:20 -08:00
2013-02-14 15:29:37 +01:00
2012-12-07 12:48:00 -05:00
2013-02-10 19:41:08 -05:00
2013-02-07 15:15:00 -08:00
2012-12-13 12:00:02 -08:00
2012-12-17 17:15:17 -08:00
2013-02-13 12:15:50 -08:00
2012-12-24 09:36:38 -07:00
2013-02-09 22:30:44 +01:00
2013-02-23 17:50:22 -08:00
2013-01-29 19:36:53 -08:00
2013-02-14 09:21:15 -05:00
2013-01-25 21:51:13 +01:00
2013-02-13 13:22:15 -05:00
2013-01-28 11:19:06 -07:00
2012-12-12 15:34:48 +08:00
2012-12-18 15:02:13 -08:00
2013-02-05 00:48:46 +01:00
2013-02-21 14:58:40 -08:00
2013-01-27 19:23:31 +01:00
2013-02-04 15:40:28 -08:00
2013-01-15 22:43:15 -08:00
2013-02-13 10:13:58 -08:00
2013-01-18 16:15:27 -08:00
2012-12-11 17:22:27 -08:00
2012-12-09 00:20:28 -05:00
2013-02-08 18:28:04 +01:00
2013-01-25 15:06:01 -08:00
2013-01-26 22:11:41 -08:00
2013-02-14 00:22:58 +01:00
2013-02-13 17:00:32 +10:30
2013-02-23 17:50:15 -08:00
2013-02-23 17:50:16 -08:00
2013-01-08 16:15:57 -08:00
2013-01-08 16:15:57 -08:00
2013-02-08 12:13:43 +10:00
2013-01-27 20:35:47 +01:00
2012-11-30 11:47:57 +01:00
2013-01-31 19:56:35 -05:00
2012-12-19 22:24:55 +01:00
2013-02-08 10:05:02 +02:00
2013-02-13 19:29:12 -08:00
2012-12-11 17:22:21 -08:00