mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rik van Riel <riel@surriel.com>
To: Gargi Sharma <gs051095@gmail.com>, linux-kernel@vger.kernel.org
Cc: julia.lawall@lip6.fr, akpm@linux-foundation.org,
	mingo@kernel.org, pasha.tatashin@oracle.com,
	ktkhai@virtuozzo.com, oleg@redhat.com, ebiederm@xmission.com,
	hch@infradead.org
Subject: Re: [PATCH v5 1/2] pid: Replace pid bitmap implementation with IDR API
Date: Tue, 10 Oct 2017 21:24:08 -0400	[thread overview]
Message-ID: <1507685048.21121.181.camel@surriel.com> (raw)
In-Reply-To: <1507677761-15006-2-git-send-email-gs051095@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2450 bytes --]

On Tue, 2017-10-10 at 19:22 -0400, Gargi Sharma wrote:
> This patch replaces the current bitmap implemetation for
> Process ID allocation. Functions that are no longer required,
> for example, free_pidmap(), alloc_pidmap(), etc. are removed.
> The rest of the functions are modified to use the IDR API.
> The change was made to make the PID allocation less complex by
> replacing custom code with calls to generic API.
> 
> Signed-off-by: Gargi Sharma <gs051095@gmail.com>

The patch looks mostly good, just a few style nitpicks remaining.

> @@ -308,8 +165,28 @@ 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 (idr_get_cursor(&tmp->idr) > RESERVED_PIDS)
> +			pid_min = RESERVED_PIDS;
> +
> +		/* Store a null pointer so find_pid_ns does not find
> +		 * a partially initialized PID (see below).
> +		 */

This comment should start with an empty line, just like the one above:

	/*
	 * Store a null pointer so find_pid_ns does not find a
	 * partially initialized PID (see below).
	 */

> @@ -240,18 +230,15 @@ void zap_pid_ns_processes(struct pid_namespace
> *pid_ns)
>  	 *
>  	 */
>  	read_lock(&tasklist_lock);
> -	nr = next_pidmap(pid_ns, 1);
> -	while (nr > 0) {
> -		rcu_read_lock();
> +	nr = 2;
>  
> -		task = pid_task(find_vpid(nr), PIDTYPE_PID);
> +	rcu_read_lock();

I would place the rcu_read_lock() on the line above the
read_lock(&tasklist_lock) and the rcu_read_unlock() below
the read_unlock(&tasklist_lock).

Why? No real reason, except the rcu lock is "a larger lock"
than the read-write lock, and it seems to be how things
are done commonly...

I may be wrong here, and I hope somebody else corrects me
if I am wrong :)

> +	idr_for_each_entry_continue(&pid_ns->idr, pid, nr) {
> +		task = pid_task(pid, PIDTYPE_PID);
>  		if (task && !__fatal_signal_pending(task))
>  			send_sig_info(SIGKILL, SEND_SIG_FORCED,
> task);
> -
> -		rcu_read_unlock();
> -
> -		nr = next_pidmap(pid_ns, nr);
>  	}
> +	rcu_read_unlock();
>  	read_unlock(&tasklist_lock);
>  
>  	/*

-- 
All Rights Reversed.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2017-10-11  1:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-10 23:22 [PATCH v5 0/2] Replacing PID " Gargi Sharma
2017-10-10 23:22 ` [PATCH v5 1/2] pid: Replace pid " Gargi Sharma
2017-10-11  1:24   ` Rik van Riel [this message]
2017-10-10 23:22 ` [PATCH v5 2/2] pid: Remove pidhash Gargi Sharma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1507685048.21121.181.camel@surriel.com \
    --to=riel@surriel.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=gs051095@gmail.com \
    --cc=hch@infradead.org \
    --cc=julia.lawall@lip6.fr \
    --cc=ktkhai@virtuozzo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=pasha.tatashin@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome