Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1452536rdb; Fri, 16 Feb 2024 17:28:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVpcAMV6k41tTMfGlJEEH8tG1nurya54LdKLwhulz74b/Hi4JXNRHC9RcFA2TrQEJGzqJxLxemW5AkRxMX6d/J4rt26k/TdAZNzKsmoHQ== X-Google-Smtp-Source: AGHT+IEP3CiiOUk7P5Ake6BB/6J6CNlqISGoB9mJWJ43W8suJUvYRV9OuOzsUYdisxfVTdWFRN23 X-Received: by 2002:a05:6870:5b1b:b0:21e:4ef2:201f with SMTP id ds27-20020a0568705b1b00b0021e4ef2201fmr4294814oab.37.1708133305478; Fri, 16 Feb 2024 17:28:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708133305; cv=pass; d=google.com; s=arc-20160816; b=IZV+FKRgHUHfJiXtvHGgyMBmdNrNvtkdvhfKXDOoqDU1BjBdm6SauBQHjhU1ymgPjF WY/QYv/Ppv6d8u3ICjwZYgqbSUBBBB8oROb+n1ls94h4OSzhfh1rtsctODrGOjCPzgZA FfI2KC1vkePpiLb4PQ1FqoprkdLZxZNHfAThbINwl2OzrCwi03UIfXcxP4ONy8ifYNgC j1fTHL2cHtbxSrWkVSLUGL9UO1UGaWDoijr5e0XLd8/SbgRXjedvjOZ4ePLbj+eGSbig hh4b8Yy0BRtjShwVHe04DuYVqzcQ1tglMvIBAvRRuQtyxOjOJ9hWwwt3TM2PUW6o5B8c C2Wg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:feedback-id:dkim-signature; bh=iO0FGo+JHvvXIFJUwYJqm/v2xV/l0hzo3O16zP5UEz0=; fh=pUJXpYKZJA5KPqlBJjhsw0gTxnegXo4HmgydtDHY5kU=; b=hRRRwCuG0Bamk3FkCFdzyi+yTcvrC7ToVblcBWOHpitcvu1z2DQ3cIKRFznTi4jqtQ 7oBMHmd+vVHK6K245Wkx9/eMJ1TeYkHMXZ7l8bpm7bnpawHZ7oEk34LQeM7EG+sJpNgU Zh6UMlkwuLcd7FRjBg6kuI/oQI659kifEtUziDeV8fgdudiHsTVhElT0WZ45i3pijnWy PySFhrl2NG06DN3mYkXnlvnIi9EBo5CO/QiDt1H3/He0WGERpj0XP/fhs7HrcNjPFvrr MlqxDn7joCITZUWZ9JhmnZh4Tu/KlQ9rv3xVcSaY9mhAIPkrXxk7oTUYeCHf/4qmpWHM DCaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VoWXBY72; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-69642-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69642-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u190-20020a6385c7000000b005dc42755289si712004pgd.488.2024.02.16.17.28.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 17:28:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69642-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VoWXBY72; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-69642-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69642-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 27AEA284379 for ; Sat, 17 Feb 2024 01:28:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2BDB71BF20; Sat, 17 Feb 2024 01:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VoWXBY72" Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F93217745; Sat, 17 Feb 2024 01:28:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708133283; cv=none; b=J0pScchgqqM5G3gxZGBIJk6GrtCXzrq4dk+t/fthw5eR8oNWWblZBpIb4PdmmdnqghLY6epm5Z1hFLd/2a5585R+tJQxjpal+WHtK5UjszOGWULIG5RQ+LYpLo8nuiQQPRbcZtMmgv+rNr/d6nnJ0sfEcaZibS1RBHATqqxMnCk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708133283; c=relaxed/simple; bh=T+CUzhbVEdJ9yuhSl92mWeUi9ua4EdFF8tCRqQ8HMkg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r0Bied3p/OZfueqLIBUVd+KWHpkDUKPcMnHxKs6BD+cu930RY3f8WFsEgTJgmWzKWZkecOzrvEoHnHPof5rBuTTwwz2m6PAAxSbS5TD0ZdgO+KfsDZT8LWMgGrc0fPB2U9n3Yemld3aiNlKV/7rtjbVYtZZ55UPqFAMfeG0a5z8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VoWXBY72; arc=none smtp.client-ip=209.85.219.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-6868823be58so5007756d6.0; Fri, 16 Feb 2024 17:28:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708133280; x=1708738080; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:feedback-id:from:to:cc:subject :date:message-id:reply-to; bh=iO0FGo+JHvvXIFJUwYJqm/v2xV/l0hzo3O16zP5UEz0=; b=VoWXBY72iTUwW5E9/gDaellDfrbbDTP0Wu8Upy2H3OPRSzdrpKMTjTZkVUcI8o8wXu dfrhnmtdllVNzP2UVTkrTfA45+DBxNJS/DAzByREtFSHCBtRY0ToCJabjr5OrmCCSIrL 953lDekAyucvqe4SJ+IRh+GEjxFKbsfu3EkulYGa/QjHL2JTKf23gFdl6lm6Yc3WG8DS UiDe+nPGTqjJBaqjyE9Yo55GDCN4EotUV+XNUHmnCBsQiHv84PCN4rEVB83qjnw6R0NC Le9vc+P2kNLTn95/T3/4+dKSR/UK2+qbRkdGDuLz3x6z7IY2eu8NnrxFNB64I8ShilJF TvaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708133280; x=1708738080; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:feedback-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=iO0FGo+JHvvXIFJUwYJqm/v2xV/l0hzo3O16zP5UEz0=; b=AxnUMla2alhS1FF+ubw9CYZlsY/cyaODm4jFdiEW65SrZGoqTkAkph9Tie7rMOkVga nrZwsmRZP3xmj4BOugA3orONCKmQ6xYaAD10cBajOAoVYXa8b/ei5yCwQvPf68WS0kg/ r/QiYE3a6uZ1ezjabv0M4YWTEc3UyFLJ7IspzGg6nNikMfAKuIWm1zknEEn/SOirlM9v glhMRspBv0PQC/2NxzNa1LmNH0fKJFXm2zYm+81GFQ4ZOU9mjbOQMlWU9Mjh5eN57L++ eFjA+uQfjGwfRLwQBQPhMT8YtoLvyrUtNs0hJhAodrNGFDnMY/02y5PbLV25rwKwH9wz XWPg== X-Forwarded-Encrypted: i=1; AJvYcCU9N30kzAOX2QNNNJ0Uu/ThywrocX6uGrVXXrvxjxjOI+gFl9FApHhSka0aeQD8C/N+Q1rTPgJ/tLYMjWXjdCzeVPmg X-Gm-Message-State: AOJu0Yw0yL4eCm3VvWBvRhSms0ySzNsSPyXRA9Uvf7llU+E5w61T3yAI zpQEO+Nb5+UnynnQM4axZ/nX/HwXNmZNWwmxE7VAU+z0O6onUBYI X-Received: by 2002:a0c:e24b:0:b0:68c:a4a8:b134 with SMTP id x11-20020a0ce24b000000b0068ca4a8b134mr5789764qvl.45.1708133280142; Fri, 16 Feb 2024 17:28:00 -0800 (PST) Received: from fauth2-smtp.messagingengine.com (fauth2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id er19-20020a056214191300b0068f304336f5sm487340qvb.36.2024.02.16.17.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 17:27:59 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfauth.nyi.internal (Postfix) with ESMTP id AC5FC1200064; Fri, 16 Feb 2024 20:27:58 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 16 Feb 2024 20:27:58 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdefgdefgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhepgffhffevhffhvdfgjefgkedvlefgkeegveeuheelhfeivdegffejgfetuefg heeinecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnodhmvghsmhhtphgruhhthhhp vghrshhonhgrlhhithihqdeiledvgeehtdeigedqudejjeekheehhedvqdgsohhquhhnrd hfvghngheppehgmhgrihhlrdgtohhmsehfihigmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 16 Feb 2024 20:27:57 -0500 (EST) From: Boqun Feng To: linux-kernel@vger.kernel.org, rcu@vger.kernel.org Cc: Neeraj Upadhyay , "Paul E. McKenney" , Chen Zhongjin , Yang Jihong , Boqun Feng , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan , Zqiang Subject: [PATCH v2 2/6] rcu-tasks: Add data to eliminate RCU-tasks/do_exit() deadlocks Date: Fri, 16 Feb 2024 17:27:37 -0800 Message-ID: <20240217012745.3446231-3-boqun.feng@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217012745.3446231-1-boqun.feng@gmail.com> References: <20240217012745.3446231-1-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-Transfer-Encoding: 8bit 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 adds the data structures that will be needed to rely on these quiescent states and to eliminate these deadlocks. 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 --- include/linux/sched.h | 2 ++ kernel/rcu/tasks.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index ffe8f618ab86..5eeebed2dd9b 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -858,6 +858,8 @@ struct task_struct { u8 rcu_tasks_idx; int rcu_tasks_idle_cpu; struct list_head rcu_tasks_holdout_list; + int rcu_tasks_exit_cpu; + struct list_head rcu_tasks_exit_list; #endif /* #ifdef CONFIG_TASKS_RCU */ #ifdef CONFIG_TASKS_TRACE_RCU diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index 732ad5b39946..b7d5f2757053 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -32,6 +32,7 @@ typedef void (*postgp_func_t)(struct rcu_tasks *rtp); * @rtp_irq_work: IRQ work queue for deferred wakeups. * @barrier_q_head: RCU callback for barrier operation. * @rtp_blkd_tasks: List of tasks blocked as readers. + * @rtp_exit_list: List of tasks in the latter portion of do_exit(). * @cpu: CPU number corresponding to this entry. * @rtpp: Pointer to the rcu_tasks structure. */ @@ -46,6 +47,7 @@ struct rcu_tasks_percpu { struct irq_work rtp_irq_work; struct rcu_head barrier_q_head; struct list_head rtp_blkd_tasks; + struct list_head rtp_exit_list; int cpu; struct rcu_tasks *rtpp; }; -- 2.43.0