On 09/27, Gargi Sharma wrote:
>
> @@ -309,7 +168,22 @@ struct pid *alloc_pid(struct pid_namespace *ns)
>       tmp = ns;
>       pid->level = ns->level;
>       for (i = ns->level; i >= 0; i--) {
> -             nr = alloc_pidmap(tmp);
> +             int pid_min = 1;
> +             idr_preload(GFP_KERNEL);
> +             spin_lock_irq(&pidmap_lock);
> +
> +             /*
> +              * init really needs pid 1, but after reaching the maximum
> +              * wrap back to RESERVED_PIDS
> +              */
> +             if (tmp->idr.idr_next > RESERVED_PIDS)
> +                     pid_min = RESERVED_PIDS;
> +
> +             nr = idr_alloc_cyclic(&tmp->idr, pid, pid_min,
> +                                   pid_max, GFP_ATOMIC);
> +             spin_unlock_irq(&pidmap_lock);
> +             idr_preload_end();
> +
>               if (nr < 0) {
>                       retval = nr;
>                       goto out_free;
> @@ -346,12 +220,14 @@ struct pid *alloc_pid(struct pid_namespace *ns)
>       return pid;
>  
>  out_unlock:
> -     spin_unlock_irq(&pidmap_lock);
>       put_pid_ns(ns);
> +     spin_unlock_irq(&pidmap_lock);

Why? No need to move put_pid_ns() under pidmap_lock, please remove this 
change...

>  void __init pidhash_init(void)
>  {
> +     unsigned int pidhash_size;
> +
>       pid_hash = alloc_large_system_hash("PID", sizeof(*pid_hash), 0, 18,
>                                          HASH_EARLY | HASH_SMALL | HASH_ZERO,
>                                          &pidhash_shift, NULL,
>                                          0, 4096);
> +     pidhash_size = 1U << pidhash_shift;
>  }

Hmm, this change makes no sense. And the next patch kills pidhash_init()
altogether.

Oleg.

Reply via email to