Commit 066a9be6c0124edc9527088231f03c6236be375d
Committed by
Linus Torvalds
1 parent
66f1991bc2
Exists in
master
and in
39 other branches
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>
Showing 1 changed file with 13 additions and 11 deletions Side-by-side Diff
lib/idr.c
... | ... | @@ -110,9 +110,10 @@ |
110 | 110 | * @idp: idr handle |
111 | 111 | * @gfp_mask: memory allocation flags |
112 | 112 | * |
113 | - * This function should be called prior to locking and calling the | |
114 | - * idr_get_new* functions. It preallocates enough memory to satisfy | |
115 | - * the worst possible allocation. | |
113 | + * This function should be called prior to calling the idr_get_new* functions. | |
114 | + * It preallocates enough memory to satisfy the worst possible allocation. The | |
115 | + * caller should pass in GFP_KERNEL if possible. This of course requires that | |
116 | + * no spinning locks be held. | |
116 | 117 | * |
117 | 118 | * If the system is REALLY out of memory this function returns 0, |
118 | 119 | * otherwise 1. |
119 | 120 | |
... | ... | @@ -290,10 +291,12 @@ |
290 | 291 | * This is the allocate id function. It should be called with any |
291 | 292 | * required locks. |
292 | 293 | * |
293 | - * If memory is required, it will return -EAGAIN, you should unlock | |
294 | - * and go back to the idr_pre_get() call. If the idr is full, it will | |
295 | - * return -ENOSPC. | |
294 | + * If allocation from IDR's private freelist fails, idr_get_new_above() will | |
295 | + * return -EAGAIN. The caller should retry the idr_pre_get() call to refill | |
296 | + * IDR's preallocation and then retry the idr_get_new_above() call. | |
296 | 297 | * |
298 | + * If the idr is full idr_get_new_above() will return -ENOSPC. | |
299 | + * | |
297 | 300 | * @id returns a value in the range @starting_id ... 0x7fffffff |
298 | 301 | */ |
299 | 302 | int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id) |
300 | 303 | |
... | ... | @@ -318,12 +321,11 @@ |
318 | 321 | * @ptr: pointer you want associated with the id |
319 | 322 | * @id: pointer to the allocated handle |
320 | 323 | * |
321 | - * This is the allocate id function. It should be called with any | |
322 | - * required locks. | |
324 | + * If allocation from IDR's private freelist fails, idr_get_new_above() will | |
325 | + * return -EAGAIN. The caller should retry the idr_pre_get() call to refill | |
326 | + * IDR's preallocation and then retry the idr_get_new_above() call. | |
323 | 327 | * |
324 | - * If memory is required, it will return -EAGAIN, you should unlock | |
325 | - * and go back to the idr_pre_get() call. If the idr is full, it will | |
326 | - * return -ENOSPC. | |
328 | + * If the idr is full idr_get_new_above() will return -ENOSPC. | |
327 | 329 | * |
328 | 330 | * @id returns a value in the range 0 ... 0x7fffffff |
329 | 331 | */ |