mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
idr: make idr_get_next() good for rcu_read_lock()
Make one small adjustment to idr_get_next(): take the height from the top layer (stable under RCU) instead of from the root (unprotected by RCU), as idr_find() does: so that it can be used with RCU locking. Copied comment on RCU locking from idr_find(). Signed-off-by: Hugh Dickins <[email protected]> Acked-by: KAMEZAWA Hiroyuki <[email protected]> Acked-by: Li Zefan <[email protected]> Cc: Eric Dumazet <[email protected]> Acked-by: Tejun Heo <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
0e79dedde9
commit
9f7de8275b
1 changed files with 5 additions and 3 deletions
|
|
@ -595,8 +595,10 @@ EXPORT_SYMBOL(idr_for_each);
|
|||
* Returns pointer to registered object with id, which is next number to
|
||||
* given id. After being looked up, *@nextidp will be updated for the next
|
||||
* iteration.
|
||||
*
|
||||
* This function can be called under rcu_read_lock(), given that the leaf
|
||||
* pointers lifetimes are correctly managed.
|
||||
*/
|
||||
|
||||
void *idr_get_next(struct idr *idp, int *nextidp)
|
||||
{
|
||||
struct idr_layer *p, *pa[MAX_LEVEL];
|
||||
|
|
@ -605,11 +607,11 @@ void *idr_get_next(struct idr *idp, int *nextidp)
|
|||
int n, max;
|
||||
|
||||
/* find first ent */
|
||||
n = idp->layers * IDR_BITS;
|
||||
max = 1 << n;
|
||||
p = rcu_dereference_raw(idp->top);
|
||||
if (!p)
|
||||
return NULL;
|
||||
n = (p->layer + 1) * IDR_BITS;
|
||||
max = 1 << n;
|
||||
|
||||
while (id < max) {
|
||||
while (n > 0 && p) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue