All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Darren Hart <dvhart@infradead.org>,
	Balbir Singh <bsingharora@gmail.com>,
	linux-mm <linux-mm@kvack.org>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] pids: introduce find_get_task_by_vpid helper
Date: Thu, 26 Oct 2017 15:58:25 +0200	[thread overview]
Message-ID: <20171026135825.GA16528@redhat.com> (raw)
In-Reply-To: <1509023278-20604-1-git-send-email-rppt@linux.vnet.ibm.com>

On 10/26, Mike Rapoport wrote:
>
> There are several functions that do find_task_by_vpid() followed by
> get_task_struct(). We can use a helper function instead.

Yes, agreed, I was going to do this many times.

> --- a/kernel/futex.c
> +++ b/kernel/futex.c
> @@ -870,12 +870,7 @@ static struct task_struct *futex_find_get_task(pid_t pid)
>  {
>  	struct task_struct *p;
>  
> -	rcu_read_lock();
> -	p = find_task_by_vpid(pid);
> -	if (p)
> -		get_task_struct(p);
> -
> -	rcu_read_unlock();
> +	p = find_get_task_by_vpid(pid);
>  
>  	return p;

OK, but then I think you should remove futex_find_get_task() and convert
it callers to use the new helper.

> @@ -1103,11 +1103,7 @@ static struct task_struct *ptrace_get_task_struct(pid_t pid)
>  {
>  	struct task_struct *child;
>  
> -	rcu_read_lock();
> -	child = find_task_by_vpid(pid);
> -	if (child)
> -		get_task_struct(child);
> -	rcu_read_unlock();
> +	child = find_get_task_by_vpid(pid);
>  
>  	if (!child)
>  		return ERR_PTR(-ESRCH);

The same. ptrace_get_task_struct() should die imo.

Oleg.

WARNING: multiple messages have this Message-ID (diff)
From: Oleg Nesterov <oleg@redhat.com>
To: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Darren Hart <dvhart@infradead.org>,
	Balbir Singh <bsingharora@gmail.com>,
	linux-mm <linux-mm@kvack.org>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] pids: introduce find_get_task_by_vpid helper
Date: Thu, 26 Oct 2017 15:58:25 +0200	[thread overview]
Message-ID: <20171026135825.GA16528@redhat.com> (raw)
In-Reply-To: <1509023278-20604-1-git-send-email-rppt@linux.vnet.ibm.com>

On 10/26, Mike Rapoport wrote:
>
> There are several functions that do find_task_by_vpid() followed by
> get_task_struct(). We can use a helper function instead.

Yes, agreed, I was going to do this many times.

> --- a/kernel/futex.c
> +++ b/kernel/futex.c
> @@ -870,12 +870,7 @@ static struct task_struct *futex_find_get_task(pid_t pid)
>  {
>  	struct task_struct *p;
>  
> -	rcu_read_lock();
> -	p = find_task_by_vpid(pid);
> -	if (p)
> -		get_task_struct(p);
> -
> -	rcu_read_unlock();
> +	p = find_get_task_by_vpid(pid);
>  
>  	return p;

OK, but then I think you should remove futex_find_get_task() and convert
it callers to use the new helper.

> @@ -1103,11 +1103,7 @@ static struct task_struct *ptrace_get_task_struct(pid_t pid)
>  {
>  	struct task_struct *child;
>  
> -	rcu_read_lock();
> -	child = find_task_by_vpid(pid);
> -	if (child)
> -		get_task_struct(child);
> -	rcu_read_unlock();
> +	child = find_get_task_by_vpid(pid);
>  
>  	if (!child)
>  		return ERR_PTR(-ESRCH);

The same. ptrace_get_task_struct() should die imo.

Oleg.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-10-26 13:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26 13:07 [PATCH] pids: introduce find_get_task_by_vpid helper Mike Rapoport
2017-10-26 13:07 ` Mike Rapoport
2017-10-26 13:58 ` Oleg Nesterov [this message]
2017-10-26 13:58   ` Oleg Nesterov
2017-10-26 19:54   ` Mike Rapoport
2017-10-26 19:54     ` Mike Rapoport

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=20171026135825.GA16528@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bsingharora@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rppt@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.