Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp659507pxb; Tue, 5 Apr 2022 17:40:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHbPyMxU96DpuEZeJWwr13fblaauNjCC3nW++cn1NEXdA8Y0OYvJ/5J1SbVVhC4JyBrZL+ X-Received: by 2002:a05:6a00:815:b0:4fb:e46:511c with SMTP id m21-20020a056a00081500b004fb0e46511cmr6155486pfk.54.1649205633209; Tue, 05 Apr 2022 17:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649205633; cv=none; d=google.com; s=arc-20160816; b=N9PBGqaSxePea+aEFswOQ6rHyVnWCwWUqrhUNPb5yfsVS3bRFvME+P2mOmgMwlL4Up ElrG3BNxUSZyy2Yxbcadv8ypL1B2/bKSPfiRWrDdp6zITJKwA8YpfV9SimWfvolDfbx6 jHXrd1RHD+JX3xpoATg8GC/mgNkcUm/xFuGXM10rRi9bDqoijp/M8HafIEL99gKtgSpV 1N9HBBH0TLpmI4+d3ezoFasgd+gKUNld5vJeDzecHMNcsFsKT5vgMiiGE5dlAHesgxni Z0Wan2fwU5bBYzztZqnMeNCA0mQQKEytzxHGTYRKCGiVLa33bvck/WhoqA7PounX0HYi Q+zQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FPC5qKgU1vCc0CqqRY4NhJy6zc3p0PvV+2+RJtrtfKw=; b=MJr14zhFUtTLC+o+U8bjQGdZQkzvbDNnUbo28AIzTUFAQNmGYttGvyZaGjRccjiCQE LkxGIl8ib05H+vZl5B6spcls3O42juvqU3/3jhMFHny5FwXDBUbykw04k8FpRPmV9eM+ ZvgkkYP7XXAYv8CMMc/dUj3kMaVNPnXPqSOwQSacuxcEyzUAj3zSTZ3esGb24G8p36j3 tQNcfz7dyCcWhzWLnHZ1/Vu3u1euUT9drbLQ3R0bShf40EFMzmi1Q1HjjfktMGkoIuuw y7GKRRMrB7ihvfklmNqwkDNb5tDj+FFlODOIXxOI5V9SRn31puD8iMjUuO5jzrrxzVNk uQxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qANHCvoK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020a170903228600b00153b2d164c5si4212289plh.205.2022.04.05.17.40.18; Tue, 05 Apr 2022 17:40:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qANHCvoK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390438AbiDENim (ORCPT + 99 others); Tue, 5 Apr 2022 09:38:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344297AbiDEJTJ (ORCPT ); Tue, 5 Apr 2022 05:19:09 -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 AD62A23BEB; Tue, 5 Apr 2022 02:07:27 -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 4A13661573; Tue, 5 Apr 2022 09:07:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B791C385A1; Tue, 5 Apr 2022 09:07:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149646; bh=bGozNgv5tjLJ84Cay1tq/nxVZeU7A+W6BXdShzv6ds8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qANHCvoKEYK9MreRgxDxgNE6OR7+5Jbq20jsYlrSUVACoWH0jRtHgFLiARDc3D5id oae41v9ZYxmhskXL5bJwJHaaEes2ennNxA/Ia+3vBtpvpeI/UzDNmIMOxz2jntUmpV KUu2muM/Z1DOxQ2HPk25YyaqUKSrNwgwkLBIbHuY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Valentin Schneider , "Peter Zijlstra (Intel)" , "Steven Rostedt (Google)" , Sasha Levin Subject: [PATCH 5.16 0789/1017] sched/tracing: Report TASK_RTLOCK_WAIT tasks as TASK_UNINTERRUPTIBLE Date: Tue, 5 Apr 2022 09:28:22 +0200 Message-Id: <20220405070417.674637916@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 084de9b70a77..46ef8c75802f 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1622,6 +1622,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