From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 2069328CF5D for ; Fri, 31 Jul 2026 00:40:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785458424; cv=none; b=SBo30+vZihE2mrviL7Q1lVKqjETGLI2MHnE2AMHnhbEtVsiXBxJbgu1/HiYcG2XI7siuhZEv096vJtcdklOtunNWOkoT2W3z50KNDdB2Q9c69egn9SV5x09XpspISiOmvR5hRdI+FbfYJ/FbirpdVgFtQqyRhod9bFUq+0rLEaA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785458424; c=relaxed/simple; bh=N8pqq9+zTTqDCcP1P5M6i4YErYK+/vAF4Bn3pL79V28=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lh4S9JgcYSLtLPe8C2cEaNtj8JSIwTc5A1X0hmNwzknDK9gqAjpE0uVMAxaUu7NBbq7KGqeeOy3WJ43F0lNJxsQOP+z/wAB/qbti//rEOVvevpYOpB4285Yx8TttKE0N/hZguEzPbpVKvYXVHyzb6em82GKKOkBc55qPZ4NH6wM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hjGZnBlb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hjGZnBlb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C23131F01563; Fri, 31 Jul 2026 00:40:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785458421; bh=zIxjmpeFndeVScXk+3nABVJefeaiIESfMm0645B//54=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hjGZnBlbDBSDa3NZP/mqaBukexH+B7ghDD2Wanro0i9RwNKKOrTX/5kg4sxYELciN /7Kn815akZnZMekCFkKdPT8o+KGdnW6hF2Kz9H8ktVMLUMh3BIeFyYKvsvRNNeQ6kF S8K6pelFkIsagglTJ7ntJnr2BQH2rXtbaqsnYbf76yKCsAiYBpJoYA5p/yp9+bQAc1 aAAhgfcrisBBap6JMtJw4LoU7tYvjxEXoy33HUAHGE6Jss+U4NNSMyNAoU0MDQ1Za8 iltNjLNQajSUByamYg17Xu+RkJQES9igD/0Jk+pOPislINxCMn2zqmQNQwC9W/ypGP qrtCURaOMSwMA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 497E6CE1497; Thu, 30 Jul 2026 17:40:21 -0700 (PDT) From: "Paul E. McKenney" To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner Cc: "Peter Zijlstra (Intel)" , linux-kernel@vger.kernel.org, kernel-team@meta.com, "Paul E. McKenney" , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long Subject: [PATCH RFC 8/9] rtmutex: Use accessor for hrtimer_sleeper ->task field Date: Thu, 30 Jul 2026 17:40:18 -0700 Message-Id: <20260731004019.3530210-8-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The hrtimer_sleeper structure's ->task field is used as a flag to indicate that the associated hrtimer has expired. This means that the hrtimer handler can be storing to this field while other code is loading from it to check for expiry. Note that additional races appear for hrtimers that can be restarted, which could be argued to be a user error. However, that is no reason to let the compiler introduce additional confusion, and to this end, the hrtimer_sleeper_task_get() was introduced, use of which also has the benefit of avoiding open-code access to hrtimer_sleeper innards. Therefore, apply this accessor to rt_mutex_slowlock_block(). KCSAN located this issue. Signed-off-by: Paul E. McKenney Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Will Deacon Cc: Boqun Feng Cc: Waiman Long Cc: Anna-Maria Behnsen Cc: Frederic Weisbecker Cc: Thomas Gleixner --- kernel/locking/rtmutex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 4728631ae71940..5a9534c715b845 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -1644,7 +1644,7 @@ static int __sched rt_mutex_slowlock_block(struct rt_mutex_base *lock, break; } - if (timeout && !timeout->task) { + if (timeout && !hrtimer_sleeper_task_get(timeout)) { ret = -ETIMEDOUT; break; } -- 2.40.1