Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3009261ybt; Mon, 22 Jun 2020 12:31:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSCS748bpCvzixw9peZ8TSs6kK+ZxmDTNSusLFDwdA00xudqQ2z8dqykGYPMNQK6XVLKnT X-Received: by 2002:a17:906:7b54:: with SMTP id n20mr16832267ejo.144.1592854302356; Mon, 22 Jun 2020 12:31:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592854302; cv=none; d=google.com; s=arc-20160816; b=HZpfyhGw8ZvuVcKCjeqM1jPLGmjGM5D0S5DfZ7y2Wy+WgI+m22grtWTVJefTD7QaPH 63CsPS3VF+ioS4P3d5yTiIBD40hHejdRl1ZJQECr+YY7jaShqnF2/U/CDDICDSwwJboJ BQola1k0+k1XHStrO5LgUJ0ZckpB/f2B1/Rlt34zczGJz8AW+yzMwYxDToQy4i6+q3th MX/T0VStPvKjOwGwC1piqCw1vDwwOx/PlxyoUmzzgfvCjYTr6G9xfumIimZTMQ9d7Ii1 TMUTFd0j25NGEE6gdFxSLPWo4Q2gAf2s50iHevdDsGFz9V9sq3KcYo0ZTEv9B7Y3hPqL Nf7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yZx/xJiu3yLYxBeu4W9X7ae9mJRIdzivgJHXdOhNnmc=; b=Df1wLKdZyp1uogwbfbyKNM8UFfRctzh8rvH18jK1l3VV7MyWmh/X0xybZUjaSRSU6A 11nfnRlV2d61kFpZY8y/6m/OWoiwiXUjiaTEOWae+7EaUVhyY+W3GYJRocT1VE3cTOqA QmsmJuQACTFVPq1nj06j+b4bTFLjb7rWDdcchLOlLX9i22Vl91MI8dnSZmazD4rpWU7A pjBHGBbinUYSo6Yj/EXJYIsvarfGju44hrL2Kdr0TZCuXwSbeYwZZB9ADViA17M5zyVh XUt/WUoA0sTGc6ZNk4uFYysEMZuuqI6yMSNGNSUIogc3SFvwakFK9i9DCyFbSW5K+Tw6 wQ3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=d0aupIxh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si3008580edq.180.2020.06.22.12.31.19; Mon, 22 Jun 2020 12:31:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=d0aupIxh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728579AbgFVT3V (ORCPT + 99 others); Mon, 22 Jun 2020 15:29:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728435AbgFVT3S (ORCPT ); Mon, 22 Jun 2020 15:29:18 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AD40C061573; Mon, 22 Jun 2020 12:29:18 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id d8so7993178plo.12; 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=luurvQftUqxLRFV6JDkDvEysCxnuhg6eK6bYbEBA2A9AZGdjWcwnUJuDxPSaKdNjbP PTWLrt31MZo4bCigbWGY2fjZZEv9gY2kc1TL18kHT7sUh+FTCo/n1MDwn5UmwsJk9PFp tfIVDo9Qahia36zsBBJK7832wmMQsSQZptNUlAKFCikKEauPI8Ruvap/2pnwqcA0QMGd TLMvLG4l0MnpzFtVnBkn7sa/cnt+m9I3ahZ6SiUmPAfo5hpfqnVogGEjGiwxAruKuaw8 cY8bYZJN+nHeYDyn16O4EJ1bq8z0rlKFADndyxVtLhFmzkEfqKL3mj3bhD3yipiKjZYW 6BqQ== X-Gm-Message-State: AOAM530xdSp0JHvfY4pbN2Hdl43EWgPhIpIqAImP2FvrKsfD6VDWkLT1 TStrBYeQksEuKVd/EnKzRY8= 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: --- 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. * -- 2.27.0.111.gc72c7da667-goog