Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1030827lqo; Fri, 17 May 2024 08:43:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWIYYQoCoMcivgpO8icYxoIgzCOEJC+oXjKompG/5kWnZ77DC/C4FRS4nQfrVVcNewXlnUzxPgP6yyhNmcLPBnYswnL8GSHwYqcnIYE/w== X-Google-Smtp-Source: AGHT+IFK0sLZ5pwRBf9+3f4Lk9C8IwPXJoVoLO+Cty7beQ5XGZadjqkE1WDqhlaXI8miwAgc6yqz X-Received: by 2002:a17:903:8c3:b0:1e8:a63b:d427 with SMTP id d9443c01a7336-1ef43f522b1mr280119725ad.49.1715960589391; Fri, 17 May 2024 08:43:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715960589; cv=pass; d=google.com; s=arc-20160816; b=rra4SnVQ1L9iwFsglxw3RYfhX0T5jFKfjfBdxgW0I4X9vI3Xz9AI0uFnpX8alJbuDp e2OJUqre3EFcT9hZRNMqvrVEBeb98772Mn6fyI6CMmdl0HJzKCRH31O7HFtZMip3sZDb iO/R/3YPKUQstbKkvEF4BhGV7fZ+5cHMppzIRJvnZPY9liNDOQaH7V5b0yIt4sK9tbrx naIlq8FleNHX1Jh5aFN6Na6YEi3swiUZABFL2zsAv5wKWuI1p7690ISpRKZCqi/wNYyB UqC3LWMRA32RsaTie4vw71k+AiyLirbG3X6CDgX5fWRTk1YTkYM6BxtZuuGtgFX/dT/z Cceg== 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:dkim-signature; bh=trEXyLmhwduuNGYRyeo73HJ60Sv3fDraWz/Nat3vrHs=; fh=dKsmvODe4oPPXEkqFplZQt6HrErwRxGzxd0u3h799qg=; b=RCeUQ3Q8GUwc9wB9i2fxS12pMmgLIy3IRjy5LuXuEwAOIeGlaEE/oWCp9U7b0uP0J+ /W/3ItfRqiR+HKJdmqhp6KGwRJ+L/OV58zqc2lJub4W1hPH47pWI1nStBqDymRMfsWTH UptRNU7zIoFXjm+yxhxNpRIL6nbeJnsOND849f3oECGXCOIjPpOxQQ7WKFT4dIKLHRit 7VdPpDuDHnvRzUilke5xbCklmskzA2OHRq5U+ANFyaDU/T7Id4SVHOoDP2RSaTDA507F uTFMGzdUSdpQghNqz6fMuU+BimjYyA7n3n9KEHFnUbe+t2xpsRcp7/YrWUGeX/am2gxu oJbg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=grVB+SUq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-182292-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182292-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. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f0733f3835si102839465ad.188.2024.05.17.08.43.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 08:43:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182292-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=grVB+SUq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-182292-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182292-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 038C2B24E51 for ; Fri, 17 May 2024 15:23:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9C4E12E1D0; Fri, 17 May 2024 15:23:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="grVB+SUq" 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 CEEAB12DDB2; Fri, 17 May 2024 15:23:13 +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=1715959393; cv=none; b=PmKvgxyNu6+o62sVFkS3urpiBEEfOnt20bPXMQQRCMxWnYc/7ngJaekswM7jsv0gx8/PboT/0lTjpID9VSAzJVR/GYKQYGvyls5Bv7lee8NUXorRF+q6mPG6QmxCsbHn2NbOCVuXp1uj4XmaJPV7c18oBA7eCer8uBCZnhZoizM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715959393; c=relaxed/simple; bh=dCPBNm5XG7KcpOZZ3bbUTe1uj7ZPUYusD02ZamB9Xa4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fprfqKcI2qXco6tFl/2E82ydm9KNJbDVeav60XX+PkYuERMNJm4nMms2mTKNoyFR8qEyXRUU8BUJjfIrPgFdd5YGgOiA5LlpdxmuJKv8mYQ+Um7/zfomZr/bQUfDkmGvFFiSEZ/7E8KPZPTsQIsRBFpy4qhgQM5ITMa6GGUND0U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=grVB+SUq; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CA4BC32789; Fri, 17 May 2024 15:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715959393; bh=dCPBNm5XG7KcpOZZ3bbUTe1uj7ZPUYusD02ZamB9Xa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=grVB+SUq0oM1ILAxe3WbMaKnAKdugjKkH1Gwb1GCBLLmtrhS8QuHiIvpOlC+J7PRs AR2HieUyfD06cQbBP0VDlltmnho/aaq6s3HlXbUFvmWW57liAJMsHKUKbFQ8azc504 WxsPVVffKLZgMD3PmgjfGjgbhYIq2Ao4tt9AD8AjGoz4RNhOkJt205aIiPAbbUbm00 5HGY2vFZqp2HRJU2dLdVKch+z2yYTA9brKog0aJpHPF847xorD3xKIr9Gj9uUjkC/T +3jscrf3aB5uOrCxE7Q3e8VRrXcGVJIVoH0khAwXl8zgxW8Zk/MDULMNncXwXNQj9r RF948QAhkUimg== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Boqun Feng , Joel Fernandes , Neeraj Upadhyay , Uladzislau Rezki , Zqiang , rcu , "Paul E . McKenney" , Peter Zijlstra Subject: [PATCH 2/2] rcu/tasks: Further comment ordering around current task snapshot on TASK-TRACE Date: Fri, 17 May 2024 17:23:03 +0200 Message-ID: <20240517152303.19689-3-frederic@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240517152303.19689-1-frederic@kernel.org> References: <20240517152303.19689-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Comment the current understanding of barriers and locking role around task snapshot. Signed-off-by: Frederic Weisbecker --- kernel/rcu/tasks.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index 6a9ee35a282e..05413b37dd6e 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -1738,9 +1738,21 @@ static void rcu_tasks_trace_pregp_step(struct list_head *hop) for_each_online_cpu(cpu) { rcu_read_lock(); /* - * RQ must be locked because no ordering exists/can be relied upon - * between rq->curr write and subsequent read sides. This ensures that - * further context switching tasks will see update side pre-GP accesses. + * RQ lock + smp_mb__after_spinlock() before reading rq->curr serve + * two purposes: + * + * 1) Ordering against previous tasks accesses (though already enforced + * by upcoming IPIs and post-gp synchronize_rcu()). + * + * 2) Make sure not to miss latest context switch, because no ordering + * exists/can be relied upon between rq->curr write and subsequent read + * sides. + * + * 3) Make sure subsequent context switching tasks will see update side + * pre-GP accesses. + * + * smp_mb() after reading rq->curr doesn't play a significant role and might + * be considered for removal in the future. */ t = cpu_curr_snapshot(cpu); if (rcu_tasks_trace_pertask_prep(t, true)) -- 2.44.0