diff options
author | Naohiro Aota <naota@elisp.net> | 2010-10-26 14:23:03 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 16:52:18 -0700 |
commit | 066a9be6c0124edc9527088231f03c6236be375d (patch) | |
tree | 49350239a1505bb08ed67a19ad2a15466f7b7526 /lib/idr.c | |
parent | 66f1991bc2357436498ac990302b6f5bf403d7ef (diff) | |
download | linux-066a9be6c0124edc9527088231f03c6236be375d.tar.gz linux-066a9be6c0124edc9527088231f03c6236be375d.tar.bz2 linux-066a9be6c0124edc9527088231f03c6236be375d.zip |
idr: fix idr_pre_get() locking description
Despite the idr_pre_get() kernel-doc, there are some cases where you can
call idr_pre_get() from within locked regions. Add a description for such
cases.
See also: http://lkml.org/lkml/2010/9/16/462
[akpm@linux-foundation.org: cleanups, grammatical fixes]
Signed-off-by: Naohiro Aota <naota@elisp.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/idr.c')
-rw-r--r-- | lib/idr.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/idr.c b/lib/idr.c index 5e0966be0f7c..e35850d3004a 100644 --- a/lib/idr.c +++ b/lib/idr.c @@ -110,9 +110,10 @@ static void idr_mark_full(struct idr_layer **pa, int id) * @idp: idr handle * @gfp_mask: memory allocation flags * - * This function should be called prior to locking and calling the - * idr_get_new* functions. It preallocates enough memory to satisfy - * the worst possible allocation. + * This function should be called prior to calling the idr_get_new* functions. + * It preallocates enough memory to satisfy the worst possible allocation. The + * caller should pass in GFP_KERNEL if possible. This of course requires that + * no spinning locks be held. * * If the system is REALLY out of memory this function returns 0, * otherwise 1. @@ -290,9 +291,11 @@ static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id) * This is the allocate id function. It should be called with any * required locks. * - * If memory is required, it will return -EAGAIN, you should unlock - * and go back to the idr_pre_get() call. If the idr is full, it will - * return -ENOSPC. + * If allocation from IDR's private freelist fails, idr_get_new_above() will + * return -EAGAIN. The caller should retry the idr_pre_get() call to refill + * IDR's preallocation and then retry the idr_get_new_above() call. + * + * If the idr is full idr_get_new_above() will return -ENOSPC. * * @id returns a value in the range @starting_id ... 0x7fffffff */ @@ -318,12 +321,11 @@ EXPORT_SYMBOL(idr_get_new_above); * @ptr: pointer you want associated with the id * @id: pointer to the allocated handle * - * This is the allocate id function. It should be called with any - * required locks. + * If allocation from IDR's private freelist fails, idr_get_new_above() will + * return -EAGAIN. The caller should retry the idr_pre_get() call to refill + * IDR's preallocation and then retry the idr_get_new_above() call. * - * If memory is required, it will return -EAGAIN, you should unlock - * and go back to the idr_pre_get() call. If the idr is full, it will - * return -ENOSPC. + * If the idr is full idr_get_new_above() will return -ENOSPC. * * @id returns a value in the range 0 ... 0x7fffffff */ |