From patchwork Mon Jun 22 19:28:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 11618791 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 4547C912 for ; Mon, 22 Jun 2020 19:29:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 09E492073E for ; Mon, 22 Jun 2020 19:29:21 +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="d0aupIxh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 09E492073E 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 DDFFE6B0008; Mon, 22 Jun 2020 15:29:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CDD806B000A; Mon, 22 Jun 2020 15:29:19 -0400 (EDT) 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 B92286B000C; Mon, 22 Jun 2020 15:29:19 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0098.hostedemail.com [216.40.44.98]) by kanga.kvack.org (Postfix) with ESMTP id 9D4246B0008 for ; Mon, 22 Jun 2020 15:29:19 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 62C8A22016C for ; Mon, 22 Jun 2020 19:29:19 +0000 (UTC) X-FDA: 76957836438.04.body35_181494826e35 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 341658170260 for ; Mon, 22 Jun 2020 19:29:19 +0000 (UTC) X-Spam-Summary: 2,0,0,0f7ecce748b1617f,d41d8cd98f00b204,minchan.kim@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:967:973:982:988:989:1260:1263:1311:1314:1345:1359:1431:1437:1515:1535:1543:1711:1730:1747:1777:1792:2198:2199:2393:2525:2559:2563:2682:2685:2859:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3354:3865:3867:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4117:4321:4605:5007:6261:6653:6742:6743:7514:7875:7903:8599:8957:9025:9592:10004:10913:11026:11658:11914:12043:12296:12297:12517:12519:12555:12679:12783:12895:12986:13846:13894:14096:14181:14394:14721:14849:21080:21094:21323:21324:21444:21451:21627:21939:21990:30054:30062:30064,0,RBL:209.85.214.195:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: body35_181494826e35 X-Filterd-Recvd-Size: 6946 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Mon, 22 Jun 2020 19:29:18 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id d12so2015691ply.1 for ; Mon, 22 Jun 2020 12:29:18 -0700 (PDT) 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=yZx/xJiu3yLYxBeu4W9X7ae9mJRIdzivgJHXdOhNnmc=; b=d0aupIxhn/FLHpBpdH0gcA+xKWtWIytAq0I1cOCDzgpj3aVoyfPoYMOonaPxhXLiwD yZ28ZuPwULQfqiNeE4/HS1JThab4ZmnHX8xrKEJy1f6P3yrKoyv5IfDyeVcgAvgJzTCV Zs/UF0zlwmfCGyR5P9laCu5HxXQ89Uba9YUqbYyknlQJ99NeCtpftlCb8CG3kjYYNmAl ooxlZ74ngTTpC95X+P7TvBWHQybJdQstLjFRMeQ4vrBy8Y+DV4J5I/sWQqwnoMLtYkg4 cAF7k5tPc5drdC3gE7FPbKTvq9iQiaiLhRtqoCIALzDCIAJ8YPyEswzeQEgqqEfyg69W RLhA== 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=yZx/xJiu3yLYxBeu4W9X7ae9mJRIdzivgJHXdOhNnmc=; b=VC3kzJVaefbsQ/kbEuCfwIh/R8G+/bNr8kQJfbawkyuJ4oakfCdwu3CP0I44vbJvak wMqnGlBc39DdUQV9TPG9P5AYMWTmNEhN49TVmz01fNliVcjMqZS3Zg84hi9lXdAghkH8 uCCzjedGKGDJCoH0GZUqoF8vsZaPx8Xxs+bNXVJEgwk/yzxc7RjaOBr9Z59zDQ/iQpQH y82RCd/RmLTj1y39wP9gJBmtg5SZdj7zhbvjB+jhbh2aNuJVJiAh0sCAHxSVN33UqBQC 72h8tI83DyehJSZd5NmQyR5Od3aFMGPLgEnl2NiUuAgtSRsLWnyytRTgg1Jt2BbmrDsv lLhQ== X-Gm-Message-State: AOAM531snqbYLKKa9EX06+CQxrtSieMY3T77iVA7SuExASTWzRc020nP Lbdraq3b3+ZHSJn2WQcQXnc= X-Google-Smtp-Source: ABdhPJwHJM4Ndj1kL9SxsYssjyeNpOvrkStklgev1hE+d9lOsEaIWOk0EsCCmknPMMW3ePgOf2akJg== X-Received: by 2002:a17:90a:cf17:: with SMTP id h23mr20123616pju.139.1592854157967; Mon, 22 Jun 2020 12:29:17 -0700 (PDT) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:1:3e01:2939:5992:52da]) by smtp.gmail.com with ESMTPSA id mu17sm264603pjb.53.2020.06.22.12.29.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 12:29:16 -0700 (PDT) From: Minchan Kim To: Andrew Morton Cc: LKML , Christian Brauner , linux-mm , linux-api@vger.kernel.org, oleksandr@redhat.com, Suren Baghdasaryan , Tim Murray , 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, David Rientjes , Arjun Roy , Minchan Kim , Vlastimil Babka , Jens Axboe , Daniel Colascione , Kirill Tkhai , SeongJae Park , linux-man@vger.kernel.org Subject: [PATCH v8 2/4] pid: move pidfd_get_pid() to pid.c Date: Mon, 22 Jun 2020 12:28:58 -0700 Message-Id: <20200622192900.22757-3-minchan@kernel.org> X-Mailer: git-send-email 2.27.0.111.gc72c7da667-goog In-Reply-To: <20200622192900.22757-1-minchan@kernel.org> References: <20200622192900.22757-1-minchan@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 341658170260 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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. Link: http://lkml.kernel.org/r/20200302193630.68771-5-minchan@kernel.org Signed-off-by: Minchan Kim Reviewed-by: Suren Baghdasaryan Suggested-by: Alexander Duyck Reviewed-by: Alexander Duyck Acked-by: Christian Brauner Reviewed-by: Vlastimil Babka Cc: Jens Axboe Cc: Jann Horn Cc: Brian Geffon Cc: Daniel Colascione Cc: Joel Fernandes Cc: Johannes Weiner Cc: John Dias Cc: Kirill Tkhai Cc: Michal Hocko Cc: Oleksandr Natalenko Cc: Sandeep Patil Cc: SeongJae Park Cc: SeongJae Park Cc: Shakeel Butt Cc: Sonny Rao Cc: Tim Murray Cc: Christian Brauner Cc: Acked-by: David Rientjes --- 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 176d6cf80e7c..86e0e7cb7872 100644 --- a/include/linux/pid.h +++ b/include/linux/pid.h @@ -77,6 +77,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 00d77e5ba700..8acb702e8241 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1475,23 +1475,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 f1496b757162..3122043fe364 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -518,6 +518,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. *