Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1110670ybf; Fri, 28 Feb 2020 14:24:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyYfD6IkNKiYPnLsN9SjA/x5TmQ2xUooYEgMA7BmnSl2XtDpbt45l34YEIUXWYTpfh2xQJj X-Received: by 2002:a9d:5a09:: with SMTP id v9mr4877956oth.214.1582928667346; Fri, 28 Feb 2020 14:24:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582928667; cv=none; d=google.com; s=arc-20160816; b=CgxUwERTq5nQQRfqmQ2ZdNV8FbfJGv0vp4OrOJQ842ux69K/jt7fh/6BYEDdHwYCNJ rDI+ujn0pmXN+9OvLYla2X+dpF5LdILEIiPa+eEcgNDYO0XseIAv/sJD/JKjfkcXvAL0 Kj1kziE5k6cV1+gO7CT5AL/PVnB/RzM03o4B3p1uviRgguytuflDHY+nY9ca4iwA8fCU Z3WlkPx7pIEwPdBHxgRJwqh5d95PqRpP+ZbNunD84rIhG+3818/PCMHtdOEvsNH7EBAN j5paWIeXP7vDMfAdvl/rgFXnJ2cufvM1ayRJHYu84ayHjUvLQUG/w6SXNAuNl49TGDVt fBDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=3leODBZgI1wn5rT6+IG8JL0u+wwlT+mFgWEDYIowxnM=; b=V3BdHPuR7GpM28K88fKnZe0+y8HWaDKz2B5BAs/wdQTBnycoKyKx2V4rNQ5I/zwKRQ 7AYNzSKCjVeD5cUw2tHCtI6YFllATlpEowX5ZFbyHHr3GkkVv7/AKIVFIPDpb8km8PQT RTxY7Il7vRYpksq8VYIOvzJ0c18iKqb4LWIP9jy50+RvjQ0Uj4eqOlLUrfgzehRDni9G Rf0+Jer382PfRCxWdh9Lff/qndABv3FSluYzzclXkcOE3uwJfuYmCqS2Q6xpLSI7q+2C DJOYDZ4Mt1QJRDqKHWY5fx2R+DSSSpRSzLF1SGTH/UsTWtDxeNL8WO6xCtxCLK79q+0q 2LlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QqFkXbni; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k205si2516445oib.64.2020.02.28.14.24.15; Fri, 28 Feb 2020 14:24:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QqFkXbni; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726400AbgB1WWx (ORCPT + 99 others); Fri, 28 Feb 2020 17:22:53 -0500 Received: from mail-vs1-f66.google.com ([209.85.217.66]:38101 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726151AbgB1WWx (ORCPT ); Fri, 28 Feb 2020 17:22:53 -0500 Received: by mail-vs1-f66.google.com with SMTP id r18so2976386vso.5 for ; Fri, 28 Feb 2020 14:22:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3leODBZgI1wn5rT6+IG8JL0u+wwlT+mFgWEDYIowxnM=; b=QqFkXbni803CbMFsPllFF8VtTlmkShHFA0dBvma1pHpI17Ow/D6B3s8kfNeZ1W8Qks UeIOZ3z5ogst2O0WGHULt8GfrR2MFyniXs5Tic7mTIICJGgi2VO0J2Crwiokrw4vcR6m 3YeRgKcluhVO8rIamGWPRwE48ofPWx3iYlQfXUcdlYRXdVufOY1RwlOdIFftRpLdHN68 vYTAP1QeN/JaSnnEOzCNZjsJXmf5bObEavHcEljWuC+V8MK2uoP/JJ4VQkXLLsIxamSq 0JMyyeZ+JnFUH05Bh8wdNrJrwWVL8nQNIHhCesC7vrJ9au4a6fj07MD7++eTZPFNfDUi Mzmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3leODBZgI1wn5rT6+IG8JL0u+wwlT+mFgWEDYIowxnM=; b=gn2kKsVwB+CRfbQzNSrYFqhWcPqdI4tMO149xAByM8XkM6iluDuRdqTLF+b8myH7kW fd9qgXw8KSD2EcBjyS6UqqrE0pgmGm/9eDOX416hhrEp2Rq2bedveBDdNlYgJdwlAseY b20DPl8TTbv4FflQ80Q9G6fooRv3Ik4W5g/PWS1fExywEt1GXfDy6+2JIhxNHd4KbuVu BWNJu0qXYy+aIiegtQZwID0l0oI4lHVuk19O+275sfQZ3ntFx2Rqj0WF3X9ZpB0PnGSp o0fIbimD7K8p3FAk9byMjjUbLw1rjkxjQ42fYbgljCknsZ3KSK88eNMWqAeYaBEa4RsD ZUKw== X-Gm-Message-State: ANhLgQ11b4jvtgqavMepIfdTEPrcp27Rki/SXoRt0cguZMac40ucllto 04s/kEI+8mzD8dyPgzyUGS5ceOb8jp6UMnDFtNUujA== X-Received: by 2002:a05:6102:303a:: with SMTP id v26mr3987849vsa.119.1582928571863; Fri, 28 Feb 2020 14:22:51 -0800 (PST) MIME-Version: 1.0 References: <20200219014433.88424-1-minchan@kernel.org> <20200219014433.88424-5-minchan@kernel.org> In-Reply-To: <20200219014433.88424-5-minchan@kernel.org> From: Suren Baghdasaryan Date: Fri, 28 Feb 2020 14:22:40 -0800 Message-ID: Subject: Re: [PATCH v6 4/7] pid: move pidfd_get_pid function to pid.c To: Minchan Kim Cc: Andrew Morton , LKML , linux-mm , linux-api@vger.kernel.org, oleksandr@redhat.com, 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 , Christoph Hellwig , Christian Brauner Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 18, 2020 at 5:44 PM Minchan Kim wrote: > > 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 > --- > 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. > * > -- > 2.25.0.265.gbab2e86ba0-goog > Reviewed-by: Suren Baghdasaryan