diff --git a/kernel/pid.c b/kernel/pid.c index b13b624e2c49..c9ef3328a52a 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -146,6 +146,8 @@ void free_pid(struct pid *pid) struct pid *alloc_pid(struct pid_namespace *ns) { + static int try = 0; + bool fail = false; struct pid *pid; enum pid_type type; int i, nr; @@ -153,6 +155,9 @@ struct pid *alloc_pid(struct pid_namespace *ns) struct upid *upid; int retval = -ENOMEM; + if (strncmp(current->comm, "trinity", 7) == 0) + printk("%s: pid_ns level %d\n", __func__, ns->level); + pid = kmem_cache_alloc(ns->pid_cachep, GFP_KERNEL); if (!pid) return ERR_PTR(retval); @@ -163,6 +168,9 @@ struct pid *alloc_pid(struct pid_namespace *ns) for (i = ns->level; i >= 0; i--) { int pid_min = 1; + if (strncmp(current->comm, "trinity", 7) == 0) + printk("%s: '%s' level %d\n", __func__, current->comm, tmp->level); + idr_preload(GFP_KERNEL); spin_lock_irq(&pidmap_lock); @@ -173,12 +181,25 @@ struct pid *alloc_pid(struct pid_namespace *ns) if (idr_get_cursor(&tmp->idr) > RESERVED_PIDS) pid_min = RESERVED_PIDS; + if (fail && strncmp(current->comm, "trinity", 7) == 0) { + fail = false; + nr = -ENOMEM; + goto xxx; + } + /* * Store a null pointer so find_pid_ns does not find * a partially initialized PID (see below). */ + if (strncmp(current->comm, "trinity", 7) == 0) { + printk("BEFORE ->idr_next %u\n", tmp->idr.idr_next); + } nr = idr_alloc_cyclic(&tmp->idr, NULL, pid_min, pid_max, GFP_ATOMIC); + if (strncmp(current->comm, "trinity", 7) == 0) { + printk(" AFTER ->idr_next %u\n", tmp->idr.idr_next); + } +xxx: spin_unlock_irq(&pidmap_lock); idr_preload_end(); @@ -187,6 +208,12 @@ struct pid *alloc_pid(struct pid_namespace *ns) goto out_free; } + if (try == 0 && strncmp(current->comm, "trinity", 7) == 0) { + if (tmp->level == 1) { + fail = true; + } + } + pid->numbers[i].nr = nr; pid->numbers[i].ns = tmp; tmp = tmp->parent; @@ -229,6 +256,9 @@ struct pid *alloc_pid(struct pid_namespace *ns) spin_unlock_irq(&pidmap_lock); kmem_cache_free(ns->pid_cachep, pid); + if (strncmp(current->comm, "trinity", 7) == 0) { + try++; + } return ERR_PTR(retval); }