Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pid: move pidfd_get_pid() to pid.c

process_madvise syscall needs pidfd_get_pid function to translate pidfd to
pid so this patch move the function to kernel/pid.c.

Suggested-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jann Horn <jannh@google.com>
Cc: Brian Geffon <bgeffon@google.com>
Cc: Daniel Colascione <dancol@google.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: John Dias <joaodias@google.com>
Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oleksandr Natalenko <oleksandr@redhat.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: SeongJae Park <sj38.park@gmail.com>
Cc: SeongJae Park <sjpark@amazon.de>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Sonny Rao <sonnyrao@google.com>
Cc: Tim Murray <timmurray@google.com>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Florian Weimer <fw@deneb.enyo.de>
Cc: <linux-man@vger.kernel.org>
Link: http://lkml.kernel.org/r/20200302193630.68771-5-minchan@kernel.org
Link: http://lkml.kernel.org/r/20200622192900.22757-3-minchan@kernel.org
Link: https://lkml.kernel.org/r/20200901000633.1920247-3-minchan@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Minchan Kim and committed by
Linus Torvalds
1aa92cd3 0726b01e

+20 -19
+1
include/linux/pid.h
··· 77 77 struct file; 78 78 79 79 extern struct pid *pidfd_pid(const struct file *file); 80 + struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags); 80 81 81 82 static inline struct pid *get_pid(struct pid *pid) 82 83 {
-19
kernel/exit.c
··· 1474 1474 return retval; 1475 1475 } 1476 1476 1477 - static struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags) 1478 - { 1479 - struct fd f; 1480 - struct pid *pid; 1481 - 1482 - f = fdget(fd); 1483 - if (!f.file) 1484 - return ERR_PTR(-EBADF); 1485 - 1486 - pid = pidfd_pid(f.file); 1487 - if (!IS_ERR(pid)) { 1488 - get_pid(pid); 1489 - *flags = f.file->f_flags; 1490 - } 1491 - 1492 - fdput(f); 1493 - return pid; 1494 - } 1495 - 1496 1477 static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop, 1497 1478 int options, struct rusage *ru) 1498 1479 {
+19
kernel/pid.c
··· 520 520 return idr_get_next(&ns->idr, &nr); 521 521 } 522 522 523 + struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags) 524 + { 525 + struct fd f; 526 + struct pid *pid; 527 + 528 + f = fdget(fd); 529 + if (!f.file) 530 + return ERR_PTR(-EBADF); 531 + 532 + pid = pidfd_pid(f.file); 533 + if (!IS_ERR(pid)) { 534 + get_pid(pid); 535 + *flags = f.file->f_flags; 536 + } 537 + 538 + fdput(f); 539 + return pid; 540 + } 541 + 523 542 /** 524 543 * pidfd_create() - Create a new pid file descriptor. 525 544 *