Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5613500pxb; Mon, 28 Mar 2022 14:59:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUr5/dqWfsdqqylazi9grHAsAAIR/j90ekvmqR4QZF5uHWO5WRNwMmLEbbxjjHYd0k1apA X-Received: by 2002:a17:902:758c:b0:154:667f:e365 with SMTP id j12-20020a170902758c00b00154667fe365mr28379534pll.120.1648504774760; Mon, 28 Mar 2022 14:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648504774; cv=none; d=google.com; s=arc-20160816; b=ie91qjF3gvpduxKqelqcMDHqoIUO4pvSV1DHHGpdO+zCREOollOLaIaS/tNwDKMBEa s8ZTdmZeXl/eg42uTX5UTyRl+D3ApuY9p2yPsxV9W6S6kEFipHqKxyLagQ3J5nz3ePaG haDVMHiifFRLKoxPrgZBXT6PU+HiGXZhphdaLRApSc/yPgHeS7h053Rs5WNX9CodV4P3 KiaKTe5OieAq3fAFKnThJcVb2zknU3Z0Fx070lbvcXAIp4Ek2IurL1kB8rhjfTaB9H7o BcaqKP1rWAEFE0NOFyRuw/EgXjo3kg/FNuVUNIBtaysTBAtIr9t6Of4i11FStF7fDuOo dEKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9Le4xQKMySv+b2NWFljnf8FaQbfxDRiWblYjySJgpRc=; b=G7vzLzIyvBiqstgWfMUls0JFLTkyyyqbeElNjp+rOVP2oW3tLNzU++IsexZxgOM76n SjlMcv2+i42s3QRL9yw3IFT0yFBYf3LyWJu0I/gdkQUcSgdHZsm3xgnjslw3I2sETm6n CA1/vanT8IL9aHJGbEhxLFnupJpRJ5+gjswNCLCfdhHW1MesXBJyAGk4MxEGtnGp/2OR Rij5IXxFqHq7fs0ZvsSR+P/13MapupB04+SehWJO/tBGno6ulI4VkZKe+nWGYUaD9ZBm dFZopIkbTv2Wmgf6+ZHmFwrapu78yvumE8LSs6ImNExfmjkuUxsCGmNtk24Lor7RBON8 rbbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fGe1iyRR; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m4-20020a1709026bc400b00153bfa55a89si13939422plt.116.2022.03.28.14.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:59:34 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fGe1iyRR; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AF73066234; Mon, 28 Mar 2022 14:25:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245732AbiC1Tn6 (ORCPT + 99 others); Mon, 28 Mar 2022 15:43:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241259AbiC1Tns (ORCPT ); Mon, 28 Mar 2022 15:43:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73F3D5C659; Mon, 28 Mar 2022 12:42:07 -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 D1907612B2; Mon, 28 Mar 2022 19:42:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D84CC34100; Mon, 28 Mar 2022 19:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648496526; bh=bk9cWPr/wjcvI1DpKgD6lGJ0CQY4X1di6UU/QY0bodk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fGe1iyRRVDxFQqX0PvvfzczrEp0NXbuzjWIFWXMnLPjgNHIAdLM8v7O3KNtmXdZ9n 6hPKH2LqS3lkoavtpiTJWePb8htCASii73h9tFklkjt+QIFdJFcADTNR/sCGhTnEtY cffgASjjxBMd27j2T4sSMh6m+sjvOfLr+nhxcxG1hZfJTgwm1g31NaIXS3MlWGl1GX iUTeQN75K7ZFpCZk/Bc/hP/Jy97XO97STdonwsRpgrK8EY+VLYo3WZ8b1bGx37a56l 9/0yJpZrMClSB3TkwIpOFpxtvXWKcx96OkBWRntXjnrSAV+KjAKgpw0Lj59pjlsaBe 2lwgpoDRs7/Og== 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.17 06/21] sched/tracing: Report TASK_RTLOCK_WAIT tasks as TASK_UNINTERRUPTIBLE Date: Mon, 28 Mar 2022 15:41:41 -0400 Message-Id: <20220328194157.1585642-6-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220328194157.1585642-1-sashal@kernel.org> References: <20220328194157.1585642-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 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 a76a178f8eb6..36e38434391c 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1630,6 +1630,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