From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f69.google.com (mail-oi0-f69.google.com [209.85.218.69]) by kanga.kvack.org (Postfix) with ESMTP id 582C26B0033 for ; Thu, 26 Oct 2017 09:58:29 -0400 (EDT) Received: by mail-oi0-f69.google.com with SMTP id q4so3437068oic.12 for ; Thu, 26 Oct 2017 06:58:29 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id 22si1565138otu.450.2017.10.26.06.58.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Oct 2017 06:58:28 -0700 (PDT) Date: Thu, 26 Oct 2017 15:58:25 +0200 From: Oleg Nesterov Subject: Re: [PATCH] pids: introduce find_get_task_by_vpid helper Message-ID: <20171026135825.GA16528@redhat.com> References: <1509023278-20604-1-git-send-email-rppt@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1509023278-20604-1-git-send-email-rppt@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Mike Rapoport Cc: Andrew Morton , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Darren Hart , Balbir Singh , linux-mm , lkml On 10/26, Mike Rapoport wrote: > > There are several functions that do find_task_by_vpid() followed by > get_task_struct(). We can use a helper function instead. Yes, agreed, I was going to do this many times. > --- a/kernel/futex.c > +++ b/kernel/futex.c > @@ -870,12 +870,7 @@ static struct task_struct *futex_find_get_task(pid_t pid) > { > struct task_struct *p; > > - rcu_read_lock(); > - p = find_task_by_vpid(pid); > - if (p) > - get_task_struct(p); > - > - rcu_read_unlock(); > + p = find_get_task_by_vpid(pid); > > return p; OK, but then I think you should remove futex_find_get_task() and convert it callers to use the new helper. > @@ -1103,11 +1103,7 @@ static struct task_struct *ptrace_get_task_struct(pid_t pid) > { > struct task_struct *child; > > - rcu_read_lock(); > - child = find_task_by_vpid(pid); > - if (child) > - get_task_struct(child); > - rcu_read_unlock(); > + child = find_get_task_by_vpid(pid); > > if (!child) > return ERR_PTR(-ESRCH); The same. ptrace_get_task_struct() should die imo. Oleg. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932370AbdJZN63 (ORCPT ); Thu, 26 Oct 2017 09:58:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58012 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932231AbdJZN62 (ORCPT ); Thu, 26 Oct 2017 09:58:28 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E2F9E25C4B Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=oleg@redhat.com Date: Thu, 26 Oct 2017 15:58:25 +0200 From: Oleg Nesterov To: Mike Rapoport Cc: Andrew Morton , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Darren Hart , Balbir Singh , linux-mm , lkml Subject: Re: [PATCH] pids: introduce find_get_task_by_vpid helper Message-ID: <20171026135825.GA16528@redhat.com> References: <1509023278-20604-1-git-send-email-rppt@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1509023278-20604-1-git-send-email-rppt@linux.vnet.ibm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 26 Oct 2017 13:58:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/26, Mike Rapoport wrote: > > There are several functions that do find_task_by_vpid() followed by > get_task_struct(). We can use a helper function instead. Yes, agreed, I was going to do this many times. > --- a/kernel/futex.c > +++ b/kernel/futex.c > @@ -870,12 +870,7 @@ static struct task_struct *futex_find_get_task(pid_t pid) > { > struct task_struct *p; > > - rcu_read_lock(); > - p = find_task_by_vpid(pid); > - if (p) > - get_task_struct(p); > - > - rcu_read_unlock(); > + p = find_get_task_by_vpid(pid); > > return p; OK, but then I think you should remove futex_find_get_task() and convert it callers to use the new helper. > @@ -1103,11 +1103,7 @@ static struct task_struct *ptrace_get_task_struct(pid_t pid) > { > struct task_struct *child; > > - rcu_read_lock(); > - child = find_task_by_vpid(pid); > - if (child) > - get_task_struct(child); > - rcu_read_unlock(); > + child = find_get_task_by_vpid(pid); > > if (!child) > return ERR_PTR(-ESRCH); The same. ptrace_get_task_struct() should die imo. Oleg.