Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp473928rdb; Thu, 22 Feb 2024 09:13:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXNSkmVilirLys5NKQOy5MXL7u05Et0xJxCbu9SM+QtA4lr6E9QYpHFwTU8zNFbsuWSPnAvJkda3arP4y4uW1M0EAO27yKAO6nR5kJ/zg== X-Google-Smtp-Source: AGHT+IF9tU39DFZRxnwyMaAmfxji4TxFRD/AG9HXhx12DV6uZ9SVHnTVJSOoRI28PNfrm9mt/Snl X-Received: by 2002:a17:90b:3805:b0:299:5913:db1b with SMTP id mq5-20020a17090b380500b002995913db1bmr11777955pjb.14.1708622037802; Thu, 22 Feb 2024 09:13:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708622037; cv=pass; d=google.com; s=arc-20160816; b=vsM750I39vTUQcQiQT+CGY0wqbSCdyytjCubKow/XHf5aT64MtQMcIVBvMozRoHA4g l04m9PEdkWPmcehKNFjra3UYaWPLSXrOEOPCXZJgKpNF3OvhBptLU5DpDhtWL1gjXeO7 q2+lm3xYUXfdKxZ/QMVUGQrQqtRucEkIYpiSD2Yv8cakUpFVAia5e+Ocx2WLkuOfLET5 VzottO2P+i84esFoIwhfxl6yIybq0anfsEqBRzw5Mc3fsr3BPuYA1nshACfs9IFYGQpK NDqGKOJwhTc07gPrSqBfXQ6eAVnHtKwNoxhJcD0UstCmwQbUdalsy2Kn/i5WE8DR1t1y 8cPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9cxXePosc4U+S5r5Ah3ibP8+oMQ2hNnJ6eJwH4f9frQ=; fh=+N4XTqpkIIcOvZNq2MD1S56jk47n8hyaOBWWbjM7dp8=; b=WjQ8zIUTTT0k0r1jGUe42HGcLhcDs1tyGzEZEoLjnck6olP+fcZvXAIXJtK9Q27BzJ 7i8scVJ5iHG0wtCpe5Wy9Li35D0NSZlrlSK+Lf0xxEWompm4IHALDuA9OKY/9+jV7Fn1 1jVEOJfX2GMpcDIHoMU24lac3wO3vqU4sx2yto8sXL9SOIJ6Hb4rp5fDOX/v4q4xKAfo HbbFHXpoCHFRd/od5eZWnvSO+CcLn4xfUJtCrvHfvI5AVZ3cTTCanO1PQkgqlsJWNg9v dSuaM2vtHIAtLSX22AG2g0SmnHsoKSzQjDYYiD8MMWiGgPS3bDmnddcA5KFUmk09KuFv WXfg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V2hZtdag; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76902-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76902-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id sj4-20020a17090b2d8400b002995b9d7859si10184459pjb.36.2024.02.22.09.13.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:13:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76902-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V2hZtdag; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76902-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76902-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id F3EA9B295CE for ; Thu, 22 Feb 2024 16:46:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22B7F153BE9; Thu, 22 Feb 2024 16:46:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V2hZtdag" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A519153BCE; Thu, 22 Feb 2024 16:46:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708620385; cv=none; b=GWN5b4y8TtqkFYUwTM0v8X/ew5kfKe2XkLpstsGDJwHjx7tMLjvRJbEBKW04pn5BHC0db+lRf5Ru3r5PppiYO5Ac+fQljKaoG34T6U/mQvhkF1eXlmo2/w6dHvnE3V2dyfTRahQOl+lZ3CquBz4qolWPavCO75XFKmhmqXrK1LU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708620385; c=relaxed/simple; bh=SI8rgYcy5xVxInz1JaUkz/QQn9h0SltRhO+47i1XgD8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DtU3uxztiW1w8Qr6Xq0fdIdSzb388NACmqk4wvbPzS9S+szoFdJVue0YXPS6Jsb9KVD4jvnsGqAieRBlEHPS9qFyt9uXFKGMBksNvCloHUhBalOmb9wHTkYty/kg/8Qc/umeap3RJpSASPi0i9DXBGdwF7DFiH4M90NJsJe1X28= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V2hZtdag; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44DB9C433F1; Thu, 22 Feb 2024 16:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708620384; bh=SI8rgYcy5xVxInz1JaUkz/QQn9h0SltRhO+47i1XgD8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V2hZtdagF4x/ThTGHsvbfuxY821HtZKKrSpuhXcjcr+v0IMIA+2ndb+kn7Wer2lm/ JQIs3+EKD0ptoaXKJgg0/riqZhSbiNUfVr+GnCCuCa5ShgmCrkOTZko0rrGcoFdBV9 QfqMeLDnZPIACmP2smETS1U7Sh2Rx5uYuoGG5KtT7bTd9lF41XxL1zNdLQts1Ys1Gr SQS7Q0u1PIXOY5no77ne28og5+P6D+dZ0l6vM4ohMXxv8xRi4mWWNEt7PB5OAkItUL hmvqytwlvirNbRDBdp9FazG7p+616hZQh85y78bTVeVdobQNbLQFZL50WHpcv5IBHQ VaTEWJDc2mWMQ== Date: Thu, 22 Feb 2024 17:46:22 +0100 From: Frederic Weisbecker To: Boqun Feng Cc: linux-kernel@vger.kernel.org, rcu@vger.kernel.org, Neeraj Upadhyay , "Paul E. McKenney" , Chen Zhongjin , Yang Jihong , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang Subject: Re: [PATCH v2 5/6] rcu-tasks: Eliminate deadlocks involving do_exit() and RCU tasks Message-ID: References: <20240217012745.3446231-1-boqun.feng@gmail.com> <20240217012745.3446231-6-boqun.feng@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240217012745.3446231-6-boqun.feng@gmail.com> Le Fri, Feb 16, 2024 at 05:27:40PM -0800, Boqun Feng a ?crit : > From: "Paul E. McKenney" > > Holding a mutex across synchronize_rcu_tasks() and acquiring > that same mutex in code called from do_exit() after its call to > exit_tasks_rcu_start() but before its call to exit_tasks_rcu_stop() > results in deadlock. This is by design, because tasks that are far > enough into do_exit() are no longer present on the tasks list, making > it a bit difficult for RCU Tasks to find them, let alone wait on them > to do a voluntary context switch. However, such deadlocks are becoming > more frequent. In addition, lockdep currently does not detect such > deadlocks and they can be difficult to reproduce. > > In addition, if a task voluntarily context switches during that time > (for example, if it blocks acquiring a mutex), then this task is in an > RCU Tasks quiescent state. And with some adjustments, RCU Tasks could > just as well take advantage of that fact. > > This commit therefore eliminates these deadlock by replacing the > SRCU-based wait for do_exit() completion with per-CPU lists of tasks > currently exiting. A given task will be on one of these per-CPU lists for > the same period of time that this task would previously have been in the > previous SRCU read-side critical section. These lists enable RCU Tasks > to find the tasks that have already been removed from the tasks list, > but that must nevertheless be waited upon. > > The RCU Tasks grace period gathers any of these do_exit() tasks that it > must wait on, and adds them to the list of holdouts. Per-CPU locking > and get_task_struct() are used to synchronize addition to and removal > from these lists. > > Link: https://lore.kernel.org/all/20240118021842.290665-1-chenzhongjin@huawei.com/ > > Reported-by: Chen Zhongjin > Reported-by: Yang Jihong > Signed-off-by: Paul E. McKenney > Tested-by: Yang Jihong > Tested-by: Chen Zhongjin > Signed-off-by: Boqun Feng Reviewed-by: Frederic Weisbecker