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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54DEDC433EF for ; Mon, 28 Mar 2022 19:45:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343883AbiC1Trd (ORCPT ); Mon, 28 Mar 2022 15:47:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343815AbiC1Tqc (ORCPT ); Mon, 28 Mar 2022 15:46:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E523310D9; Mon, 28 Mar 2022 12:43:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C58ED612B3; Mon, 28 Mar 2022 19:43:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67DF6C34110; Mon, 28 Mar 2022 19:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648496589; bh=EEzSTtJhiB4vfmd+xlsYP6HL/LckkspU9kimszDf3zY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KZjy+baOLo1bYYHuw9N97F1amyfIVRYUfkTe8h8oX27QjuIq4K4sQCqfUUYPm/v96 UVd3SBIgkViARol4dTIhbzgobeYRz6RxBhgBC19Lnxtncw8u8Sok+3+YMOPts7y7CH pSPZJwpUa0ymMwz26jUUn1V2b1zMTKb0ARSSnvKi3V21WUrEdrvt255nDx/+QdQ03U 8XRb/jbSnnnFF49fAihfwShHV2d8ffrOg4pYLaBqe01qjy8bG4qrblRsTsjNGJfXV8 yhHqwpkzKYAJYSXdIKMJTjb4x3Vsymg0pP7XnioYdjekLsyFNX5JSkkysWt8fZaYtJ ilE9hqjObFybA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Valentin Schneider , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Peter Zijlstra , Steven Rostedt , Sasha Levin , mingo@redhat.com Subject: [PATCH AUTOSEL 5.15 06/16] sched/tracing: Report TASK_RTLOCK_WAIT tasks as TASK_UNINTERRUPTIBLE Date: Mon, 28 Mar 2022 15:42:49 -0400 Message-Id: <20220328194300.1586178-6-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220328194300.1586178-1-sashal@kernel.org> References: <20220328194300.1586178-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Valentin Schneider [ Upstream commit 25795ef6299f07ce3838f3253a9cb34f64efcfae ] TASK_RTLOCK_WAIT currently isn't part of TASK_REPORT, thus a task blocking on an rtlock will appear as having a task state == 0, IOW TASK_RUNNING. The actual state is saved in p->saved_state, but reading it after reading p->__state has a few issues: o that could still be TASK_RUNNING in the case of e.g. rt_spin_lock o ttwu_state_match() might have changed that to TASK_RUNNING As pointed out by Eric, adding TASK_RTLOCK_WAIT to TASK_REPORT implies exposing a new state to userspace tools which way not know what to do with them. The only information that needs to be conveyed here is that a task is waiting on an rt_mutex, which matches TASK_UNINTERRUPTIBLE - there's no need for a new state. Reported-by: Uwe Kleine-König Signed-off-by: Valentin Schneider Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Steven Rostedt (Google) Link: https://lore.kernel.org/r/20220120162520.570782-3-valentin.schneider@arm.com Signed-off-by: Sasha Levin --- include/linux/sched.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index 8fcf76fed984..031588cd2ccb 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1626,6 +1626,14 @@ static inline unsigned int __task_state_index(unsigned int tsk_state, if (tsk_state == TASK_IDLE) state = TASK_REPORT_IDLE; + /* + * We're lying here, but rather than expose a completely new task state + * to userspace, we can make this appear as if the task has gone through + * a regular rt_mutex_lock() call. + */ + if (tsk_state == TASK_RTLOCK_WAIT) + state = TASK_UNINTERRUPTIBLE; + return fls(state); } -- 2.34.1