From: Mike Rapoport <rppt@linux.vnet.ibm.com> To: Oleg Nesterov <oleg@redhat.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 22:54:47 +0300 [thread overview] Message-ID: <20171026195442.GA10558@rapoport-lnx> (raw) In-Reply-To: <20171026135825.GA16528@redhat.com> On Thu, Oct 26, 2017 at 03:58:25PM +0200, Oleg Nesterov wrote: > 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. Agree. My cocci script was too simple :) > > @@ -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. Yeah, we could just return -ESRCH in ptrace_get_task_struct users instead of all the ERR_PTR and PTR_ERR conversions... > Oleg. > -- Sincerely yours, Mike.
WARNING: multiple messages have this Message-ID (diff)
From: Mike Rapoport <rppt@linux.vnet.ibm.com> To: Oleg Nesterov <oleg@redhat.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 22:54:47 +0300 [thread overview] Message-ID: <20171026195442.GA10558@rapoport-lnx> (raw) In-Reply-To: <20171026135825.GA16528@redhat.com> On Thu, Oct 26, 2017 at 03:58:25PM +0200, Oleg Nesterov wrote: > 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. Agree. My cocci script was too simple :) > > @@ -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. Yeah, we could just return -ESRCH in ptrace_get_task_struct users instead of all the ERR_PTR and PTR_ERR conversions... > Oleg. > -- Sincerely yours, Mike. -- 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>
next prev parent reply other threads:[~2017-10-26 19:55 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 2017-10-26 13:58 ` Oleg Nesterov 2017-10-26 19:54 ` Mike Rapoport [this message] 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=20171026195442.GA10558@rapoport-lnx \ --to=rppt@linux.vnet.ibm.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=oleg@redhat.com \ --cc=peterz@infradead.org \ --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: linkBe 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.