[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191016153606.2326-5-christian.brauner@ubuntu.com>
Date: Wed, 16 Oct 2019 17:36:06 +0200
From: Christian Brauner <christian.brauner@...ntu.com>
To: oleg@...hat.com, linux-kernel@...r.kernel.org
Cc: aarcange@...hat.com, akpm@...ux-foundation.org,
christian@...lner.me, cyphar@...har.com, elena.reshetova@...el.com,
guro@...com, jannh@...gle.com, ldv@...linux.org,
linux-api@...r.kernel.org, linux-kselftest@...r.kernel.org,
mhocko@...e.com, mingo@...nel.org, peterz@...radead.org,
shuah@...nel.org, tglx@...utronix.de, viro@...iv.linux.org.uk,
Christian Brauner <christian.brauner@...ntu.com>
Subject: [PATCH v2 5/5] pid: use task_alive() in pidfd_open()
Use the new task_alive() helper in pidfd_open(). This simplifies the
code and avoids taking rcu_read_{lock,unlock}() and leads to overall
nicer code.
Cc: Oleg Nesterov <oleg@...hat.com>
Signed-off-by: Christian Brauner <christian.brauner@...ntu.com>
---
/* v1 */
patch not present
/* v2 */
patch introduced
---
kernel/pid.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/kernel/pid.c b/kernel/pid.c
index 70ad4a9f728c..1f425b6c4c47 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -497,7 +497,7 @@ static int pidfd_create(struct pid *pid)
*/
SYSCALL_DEFINE2(pidfd_open, pid_t, pid, unsigned int, flags)
{
- int fd, ret;
+ int fd;
struct pid *p;
if (flags)
@@ -510,13 +510,11 @@ SYSCALL_DEFINE2(pidfd_open, pid_t, pid, unsigned int, flags)
if (!p)
return -ESRCH;
- ret = 0;
- rcu_read_lock();
- if (!pid_task(p, PIDTYPE_TGID))
- ret = -EINVAL;
- rcu_read_unlock();
+ if (task_alive(p, PIDTYPE_TGID))
+ fd = pidfd_create(p);
+ else
+ fd = -EINVAL;
- fd = ret ?: pidfd_create(p);
put_pid(p);
return fd;
}
--
2.23.0
Powered by blists - more mailing lists