From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F9E5C433F5 for ; Fri, 6 May 2022 03:23:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E39C6B0071; Thu, 5 May 2022 23:23:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 593016B0073; Thu, 5 May 2022 23:23:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 434096B0074; Thu, 5 May 2022 23:23:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 351B56B0071 for ; Thu, 5 May 2022 23:23:22 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0C00420EF9 for ; Fri, 6 May 2022 03:23:22 +0000 (UTC) X-FDA: 79433872644.20.D23AEF5 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf25.hostedemail.com (Postfix) with ESMTP id 2E1EDA000A for ; Fri, 6 May 2022 03:23:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651807400; x=1683343400; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=gJAhDIHMWpivM5Pb0+lUmlrgmemgOFXzFUKg/utqTFs=; b=RnYy6HJaoO9CInFtFVVwHoX8UtKjycyT9qhBKdWnezX2VOJJh9aUr2PE wc5cDIO4dxssquxaA2H7mglFEiDWlACBkaouTRsFWBuAivQp2sK67yFen rAloqYGJ5eOY5AIerjC12VKwwoyiQH/Z3TGssxRSRKjkrQirnp8hHijAQ O9HF5CDzDMzsNYjMyviuc3653mZDALFCE0ynPKjVBFO7Xi+jUkL5f7Pu0 i7mjrL+Z44p+c3VYox0Ou6nYV7Y4YBUYyxdZu/ekrqwd2aQWRhHbdd4R+ eabUTmynXt/3tpxs4jJlcQmI03jVXhRawMxRA3FnE5ToHKnwBu4eShjD1 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="331322241" X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="331322241" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 20:23:19 -0700 X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="517828846" Received: from fulaizha-mobl1.ccr.corp.intel.com ([10.254.213.163]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 20:23:16 -0700 Message-ID: Subject: Re: [PATCH v2 1/4] mm/migration: reduce the rcu lock duration From: "ying.huang@intel.com" To: Miaohe Lin , akpm@linux-foundation.org, mike.kravetz@oracle.com, naoya.horiguchi@nec.com Cc: hch@lst.de, dhowells@redhat.com, cl@linux.com, david@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Fri, 06 May 2022 11:23:14 +0800 In-Reply-To: <20220425132723.34824-2-linmiaohe@huawei.com> References: <20220425132723.34824-1-linmiaohe@huawei.com> <20220425132723.34824-2-linmiaohe@huawei.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=RnYy6HJa; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf25.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2E1EDA000A X-Rspam-User: X-Stat-Signature: hcrfrzwxnt547bzdkx7qctdwobwqre6u X-HE-Tag: 1651807385-569890 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: On Mon, 2022-04-25 at 21:27 +0800, Miaohe Lin wrote: > rcu_read_lock is required by grabbing the task refcount but it's not > needed for ptrace_may_access. So we could release the rcu lock after > task refcount is successfully grabbed to reduce the rcu holding time. > > Reviewed-by: Muchun Song > Reviewed-by: Christoph Hellwig > Signed-off-by: Miaohe Lin > Cc: Huang Ying > Cc: David Howells > Cc: Christoph Lameter > --- >  mm/migrate.c | 3 +-- >  1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index b2678279eb43..b779646665fe 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1902,17 +1902,16 @@ static struct mm_struct *find_mm_struct(pid_t pid, nodemask_t *mem_nodes) >   return ERR_PTR(-ESRCH); >   } >   get_task_struct(task); > + rcu_read_unlock(); >   > >   /* >   * Check if this process has the right to modify the specified >   * process. Use the regular "ptrace_may_access()" checks. >   */ >   if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) { > - rcu_read_unlock(); >   mm = ERR_PTR(-EPERM); >   goto out; >   } > - rcu_read_unlock(); >   > >   mm = ERR_PTR(security_task_movememory(task)); >   if (IS_ERR(mm)) Hi, Miaohe, Please check the previous discussion and verify whether the original reported race condition is stll valid by yourself before resending this patch again. If you find that the original race condition isn't possible now, please add the analysis in your change log. Best Regards, Huang, Ying