From patchwork Wed Feb 19 01:44:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 11390195 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7813192A for ; Wed, 19 Feb 2020 01:44:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 446EC24654 for ; Wed, 19 Feb 2020 01:44:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dP4zgAzS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 446EC24654 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6F1846B000A; Tue, 18 Feb 2020 20:44:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 679386B000C; Tue, 18 Feb 2020 20:44:46 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 567226B000D; Tue, 18 Feb 2020 20:44:46 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0178.hostedemail.com [216.40.44.178]) by kanga.kvack.org (Postfix) with ESMTP id 3EBBB6B000A for ; Tue, 18 Feb 2020 20:44:46 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D0F80181AEF0B for ; Wed, 19 Feb 2020 01:44:45 +0000 (UTC) X-FDA: 76505182530.29.cry36_63bc137b25009 X-Spam-Summary: 2,0,0,0a8afb2252ff8053,d41d8cd98f00b204,minchan.kim@gmail.com,:akpm@linux-foundation.org:linux-kernel@vger.kernel.org::linux-api@vger.kernel.org:oleksandr@redhat.com:surenb@google.com:timmurray@google.com:dancol@google.com:sspatil@google.com:sonnyrao@google.com:bgeffon@google.com:mhocko@suse.com:hannes@cmpxchg.org:shakeelb@google.com:joaodias@google.com:joel@joelfernandes.org:sj38.park@gmail.com:alexander.h.duyck@linux.intel.com:jannh@google.com:minchan@kernel.org:hch@infradead.org:christian@brauner.io,RULES_HIT:41:69:355:379:541:800:960:973:982:988:989:1260:1311:1314:1345:1359:1431:1437:1515:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3867:4321:4605:5007:6261:6653:6742:6743:7875:7903:9592:10004:11026:11658:11914:12043:12296:12297:12517:12519:12555:12895:13894:14096:14181:14394:14721:21080:21324:21444:21451:21627:21990:30054:30062,0,RBL:209.85.216.68:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100,CacheIP:none ,Bayesia X-HE-Tag: cry36_63bc137b25009 X-Filterd-Recvd-Size: 5869 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Wed, 19 Feb 2020 01:44:45 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id n96so1859828pjc.3 for ; Tue, 18 Feb 2020 17:44:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zcb6D3u81fCeQ2AWI9laxyN/xHYitLuojX9wxAp2vtU=; b=dP4zgAzSfngeY16XyCngdzYL3pA1g5T7uI7IbBGs38Cq9dhKFWbybu8yMh8d3nAD4l /smEEZHCE8hdOT1p5Ki7jOPlAOMdxzFeVJpT9MyA6I06e+Qa2TrhbleCy3DxunYXCIB5 D8GzFREe6yi8L2+5EabIqS4RtkmKjOH3XX5gBw386Q6653dNSqn6QYCGdDD6ky9ct7PC hmsAWGl1MPwo1xiXi9NkuxlWWdOk8VEPVGoPVf5vp15fDxY1BhsrwI64d3tyXz0oU8dJ 15XR2gKbskMrpyjLEm1yKNrut0+p2Rmv43IVU9hL6gPIA/zlWyZ7DJr/gZUvxZP//EY5 +3qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=zcb6D3u81fCeQ2AWI9laxyN/xHYitLuojX9wxAp2vtU=; b=UVIFcxA5iDsy4uF6dkkBiSHOKqik6AmCnRgVixxCkfsBDfOrAPiOgKvNKsbswlQiCZ sp8tRn3MsIpEFemaTtZobtNdOBTPOCX6kXP21A2SxGLRtu+3GVXmwV0U287d6MP7s4uX wA+K9c82HaXlss2LrXkGd4rIkDv1EqH+IcJMbAl8Tw8xg4u1crzZJ0sPf8gBLd60ZXzv zKaZ9OGOJOWN6rUzur+46UhjUKAjyY8btB6QeUz2gdgOxnYLXaYF+Tasddo9ERoYfue/ E3KrjFUo27pyFC67EEA5ct0quY2rB9xT1XmDKzgNqEaaX8qbL3PQc0FCV26O6oigu7wf 4Vug== X-Gm-Message-State: APjAAAWYRoDXNkGnAahmJMC/BkVL18fVNg34rejvc/VmXjmsGXeOE4Kp WlauP2ZjHL7GlL9MntzEDL4= X-Google-Smtp-Source: APXvYqwB1UZyTj2FO+7mAGa5Fn4Vvj4rqp0gh1on14j7stLGrsDNA8wBC6nZZTSkwSGyGrI+AfiauQ== X-Received: by 2002:a17:902:740c:: with SMTP id g12mr24779284pll.166.1582076684396; Tue, 18 Feb 2020 17:44:44 -0800 (PST) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:1:3e01:2939:5992:52da]) by smtp.gmail.com with ESMTPSA id t186sm221192pgd.26.2020.02.18.17.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 17:44:43 -0800 (PST) From: Minchan Kim To: Andrew Morton Cc: LKML , linux-mm , linux-api@vger.kernel.org, oleksandr@redhat.com, Suren Baghdasaryan , Tim Murray , Daniel Colascione , Sandeep Patil , Sonny Rao , Brian Geffon , Michal Hocko , Johannes Weiner , Shakeel Butt , John Dias , Joel Fernandes , sj38.park@gmail.com, alexander.h.duyck@linux.intel.com, Jann Horn , Minchan Kim , Christoph Hellwig , Christian Brauner Subject: [PATCH v6 4/7] pid: move pidfd_get_pid function to pid.c Date: Tue, 18 Feb 2020 17:44:30 -0800 Message-Id: <20200219014433.88424-5-minchan@kernel.org> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog In-Reply-To: <20200219014433.88424-1-minchan@kernel.org> References: <20200219014433.88424-1-minchan@kernel.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: process_madvise syscall needs pidfd_get_pid function to translate pidfd to pid so this patch move the function to kernel/pid.c. Cc: Christoph Hellwig Cc: Christian Brauner Suggested-by: Alexander Duyck Reviewed-by: Alexander Duyck Signed-off-by: Minchan Kim Reviewed-by: Suren Baghdasaryan --- include/linux/pid.h | 1 + kernel/exit.c | 17 ----------------- kernel/pid.c | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/include/linux/pid.h b/include/linux/pid.h index 998ae7d24450..993f68cb45c2 100644 --- a/include/linux/pid.h +++ b/include/linux/pid.h @@ -75,6 +75,7 @@ extern const struct file_operations pidfd_fops; struct file; extern struct pid *pidfd_pid(const struct file *file); +struct pid *pidfd_get_pid(unsigned int fd); static inline struct pid *get_pid(struct pid *pid) { diff --git a/kernel/exit.c b/kernel/exit.c index 0b81b26a872a..43375f9d8bbc 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1470,23 +1470,6 @@ static long do_wait(struct wait_opts *wo) return retval; } -static struct pid *pidfd_get_pid(unsigned int fd) -{ - struct fd f; - struct pid *pid; - - f = fdget(fd); - if (!f.file) - return ERR_PTR(-EBADF); - - pid = pidfd_pid(f.file); - if (!IS_ERR(pid)) - get_pid(pid); - - fdput(f); - return pid; -} - static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop, int options, struct rusage *ru) { diff --git a/kernel/pid.c b/kernel/pid.c index 0f4ecb57214c..360ba480a2a9 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -496,6 +496,23 @@ struct pid *find_ge_pid(int nr, struct pid_namespace *ns) return idr_get_next(&ns->idr, &nr); } +struct pid *pidfd_get_pid(unsigned int fd) +{ + struct fd f; + struct pid *pid; + + f = fdget(fd); + if (!f.file) + return ERR_PTR(-EBADF); + + pid = pidfd_pid(f.file); + if (!IS_ERR(pid)) + get_pid(pid); + + fdput(f); + return pid; +} + /** * pidfd_create() - Create a new pid file descriptor. *