The patch titled Subject: ipc_idr_alloc refactoring has been added to the -mm tree. Its filename is ipc_idr_alloc-refactoring.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/ipc_idr_alloc-refactoring.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/ipc_idr_alloc-refactoring.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Dmitry Vyukov <dvyukov@xxxxxxxxxx> Subject: ipc_idr_alloc refactoring ipc_idr_alloc refactoring Link: http://lkml.kernel.org/r/20180709151019.1336-8-manfred@xxxxxxxxxxxxxxxx Signed-off-by: Dmitry Vyukov <dvyukov@xxxxxxxxxx> Signed-off-by: Manfred Spraul <manfred@xxxxxxxxxxxxxxxx> Cc: Davidlohr Bueso <dave@xxxxxxxxxxxx> Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Michael Kerrisk <mtk.manpages@xxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- ipc/util.c | 51 +++++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff -puN ipc/util.c~ipc_idr_alloc-refactoring ipc/util.c --- a/ipc/util.c~ipc_idr_alloc-refactoring +++ a/ipc/util.c @@ -193,52 +193,32 @@ static struct kern_ipc_perm *ipc_findkey return NULL; } -#ifdef CONFIG_CHECKPOINT_RESTORE /* * Specify desired id for next allocated IPC object. */ -static inline int ipc_idr_alloc(struct ipc_ids *ids, - struct kern_ipc_perm *new) +static inline int ipc_idr_alloc(struct ipc_ids *ids, struct kern_ipc_perm *new) { - int key; + int key, next_id = -1; - if (ids->next_id < 0) { - key = idr_alloc(&ids->ipcs_idr, new, 0, 0, GFP_NOWAIT); - } else { - key = idr_alloc(&ids->ipcs_idr, new, - ipcid_to_idx(ids->next_id), - 0, GFP_NOWAIT); - ids->next_id = -1; - } - return key; -} +#ifdef CONFIG_CHECKPOINT_RESTORE + next_id = ids->next_id; + ids->next_id = -1; +#endif -static inline void ipc_set_seq(struct ipc_ids *ids, - struct kern_ipc_perm *new) -{ - if (ids->next_id < 0) { /* default, behave as !CHECKPOINT_RESTORE */ + if (next_id < 0) { /* !CHECKPOINT_RESTORE or next_id is unset */ new->seq = ids->seq++; if (ids->seq > IPCID_SEQ_MAX) ids->seq = 0; + key = idr_alloc(&ids->ipcs_idr, new, 0, 0, GFP_NOWAIT); } else { - new->seq = ipcid_to_seqx(ids->next_id); + new->seq = ipcid_to_seqx(next_id); + key = idr_alloc(&ids->ipcs_idr, new, ipcid_to_idx(next_id), + 0, GFP_NOWAIT); } + new->id = SEQ_MULTIPLIER * new->seq + key; + return key; } -#else -#define ipc_idr_alloc(ids, new) \ - idr_alloc(&(ids)->ipcs_idr, (new), 0, 0, GFP_NOWAIT) - -static inline void ipc_set_seq(struct ipc_ids *ids, - struct kern_ipc_perm *new) -{ - new->seq = ids->seq++; - if (ids->seq > IPCID_SEQ_MAX) - ids->seq = 0; -} - -#endif /* CONFIG_CHECKPOINT_RESTORE */ - /** * ipc_addid - add an ipc identifier * @ids: ipc identifier set @@ -278,8 +258,6 @@ int ipc_addid(struct ipc_ids *ids, struc current_euid_egid(&euid, &egid); new->cuid = new->uid = euid; new->gid = new->cgid = egid; - - ipc_set_seq(ids, new); new->deleted = false; /* @@ -317,9 +295,6 @@ int ipc_addid(struct ipc_ids *ids, struc ids->in_use++; if (id > ids->max_id) ids->max_id = id; - - new->id = SEQ_MULTIPLIER * new->seq + id; - return id; } _ Patches currently in -mm which might be from dvyukov@xxxxxxxxxx are include-asm-generic-bugh-clarify-valid-uses-of-warn.patch kernel-hung_taskc-allow-to-set-checking-interval-separately-from-timeout.patch ipc_idr_alloc-refactoring.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html