From patchwork Mon Mar 2 19:36:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 11416207 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 5DCFA924 for ; Mon, 2 Mar 2020 19:36:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2071B2080C for ; Mon, 2 Mar 2020 19:36:53 +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="Qngfc7kD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2071B2080C 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 669E96B0008; Mon, 2 Mar 2020 14:36:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 61CB86B000C; Mon, 2 Mar 2020 14:36:50 -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 531BB6B000D; Mon, 2 Mar 2020 14:36:50 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id 3B0106B0008 for ; Mon, 2 Mar 2020 14:36:50 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 04C0F16E2E for ; Mon, 2 Mar 2020 19:36:50 +0000 (UTC) X-FDA: 76551429780.22.rat03_75d384fda7c15 X-Spam-Summary: 2,0,0,a81a6d5dedb60955,d41d8cd98f00b204,minchan.kim@gmail.com,,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.210.195:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: rat03_75d384fda7c15 X-Filterd-Recvd-Size: 5914 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Mon, 2 Mar 2020 19:36:49 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id q9so206096pfs.5 for ; Mon, 02 Mar 2020 11:36:49 -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=CAuMT51bd2tPZq5AmNznMJxSdkpdINt7X9+EcbWTH9c=; b=Qngfc7kD/lQSumCWFxpAqPzefGO/9bxaitrChg4vLFdSK1L1Q7wGmkyyv1AjrjzI7m AOaWowDalt1ETXKpq2oK2AZtCOt/lTlNicrt04FuObfW734BiJoSfgLB+MwH3k0LTPXV fth+eqkYXRt1R6Ar4Y/dyeA/5jw0oiYHDxqDiu1aLgkVNZfussho1t563flM2VPHZklK hxx3betvqjiki7SXAUyx5SbIqyAjvKvnx9McT/oaJeXtT8FJPrPzR9uJFJAqWYuR5s4m zhrBXYTDOFPkR0tTqnc4zWIgM9LKY/G44kvXhi4vTKFYQEoPiSp9i9vISnIXGZWFcsoa Kf6Q== 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=CAuMT51bd2tPZq5AmNznMJxSdkpdINt7X9+EcbWTH9c=; b=bEJEfqnBiI7IGMCt+5FrJPnbjn9OQUFtmp32fpAITdzO4yIDu/e5BF2ro9qM6jMVsS XG5o22AEtf35SbrFyafK2bjJ6tav+mM+41ZO0ezAvOMgaY+f0XPSzHpiMvNzxqbwOlpW gEfr3wQanjzc8w5XJ0sD61NVe8OrjIsD1xGRLEUbU8u58NoOsSR4CDdJmRG2iYJAnua6 r/p/JbOKykgvCAx0relM8Tsxja+bhT4c1Vk1cbaFJFGQbHtxb+t/FGF9Sk1xR0XwusqL RmcznBlxwJ/cNegWahDYQO8mQswTV4DLarQFqv6wRsIv1YUAO1yqtITqoP3kQKPBMYLi ONtA== X-Gm-Message-State: ANhLgQ2YMZ0c5GFoseVL0Mif8gdQIW/AXq6eS5Q0LeVtpV1MFI8zHHFA vRLzrPZJbE4Nmxp57xXsmL0= X-Google-Smtp-Source: ADFU+vtNTGw0O0BZ3Z3bAo+W/YdJ+VqxqzAEvQMOOjmVfJ07p6EQ0TGFmHTrPNVwtIVNv7ajfyHprA== X-Received: by 2002:a62:ce48:: with SMTP id y69mr578428pfg.8.1583177808587; Mon, 02 Mar 2020 11:36:48 -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 hg6sm35441pjb.22.2020.03.02.11.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2020 11:36:47 -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 , Jann Horn , alexander.h.duyck@linux.intel.com, sj38.park@gmail.com, Minchan Kim , Christoph Hellwig , Christian Brauner Subject: [PATCH v7 4/7] pid: move pidfd_get_pid function to pid.c Date: Mon, 2 Mar 2020 11:36:27 -0800 Message-Id: <20200302193630.68771-5-minchan@kernel.org> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog In-Reply-To: <20200302193630.68771-1-minchan@kernel.org> References: <20200302193630.68771-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 Reviewed-by: Suren Baghdasaryan Suggested-by: Alexander Duyck Reviewed-by: Alexander Duyck Signed-off-by: Minchan Kim Reviewed-by: Vlastimil Babka Acked-by: Christian Brauner --- 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 764960fabfa1..8cad838c26d6 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1471,23 +1471,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. *