diff options
Diffstat (limited to 'ipc/util.c')
-rw-r--r-- | ipc/util.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ipc/util.c b/ipc/util.c index 71f3f3982fc8..d126d156efc6 100644 --- a/ipc/util.c +++ b/ipc/util.c @@ -220,9 +220,14 @@ static inline int ipc_idr_alloc(struct ipc_ids *ids, struct kern_ipc_perm *new) */ if (next_id < 0) { /* !CHECKPOINT_RESTORE or next_id is unset */ + int max_idx; + + max_idx = max(ids->in_use*3/2, ipc_min_cycle); + max_idx = min(max_idx, ipc_mni); /* allocate the idx, with a NULL struct kern_ipc_perm */ - idx = idr_alloc(&ids->ipcs_idr, NULL, 0, 0, GFP_NOWAIT); + idx = idr_alloc_cyclic(&ids->ipcs_idr, NULL, 0, max_idx, + GFP_NOWAIT); if (idx >= 0) { /* |