Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1287552pxb; Fri, 21 Jan 2022 14:25:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJz++kPqXbxedOTZSstzwbDdajvs9vIOjb0gnPABCXTJ8RhCwilWznPooCroUiAKOv4UFl72 X-Received: by 2002:a17:902:bb87:b0:148:a2e8:2798 with SMTP id m7-20020a170902bb8700b00148a2e82798mr5255222pls.159.1642803933296; Fri, 21 Jan 2022 14:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642803933; cv=none; d=google.com; s=arc-20160816; b=TbKREN936nXPToOc+S0UtqyHXUNXImdBn1bqoKCj/ZkTLF72bGAvb4mvcUOGv1AI6b qJosFQj82+NgkiKTEkJwcoV2ru6tglIwAKuc3Dvfp6oEo6G6yrReh9CA3SE36lYDfLIn cW35W7Ve6PbcG50K2aeto5IZtNZLczSdzKLdA1ogJgT0CuNsNwxgXy80HwEPFy1db60R knmsWtifjb6a2fPfQL08f7eiOoV8zjdGP3m4lFHA2OASKx4Mls7H1hlEYSvSveYExgB7 +K6eikD7ukChVA8RnSoNV+/8+7ReKjOEcGeKYUyOcuzPRWewJXOJ+tpuH7EYJTB01pY1 Jm6A== 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; bh=hlfLEZf/QwaCJlShu5BgdhlaWI7m/jBz0OygsIEodjo=; b=HvicaZTMaS3Sl6DhGrNzZQGbOtAa64b2iy1YNf0JNe/9jdHg5fpop7BGXeG2QIkVN5 aiO1iueZ9dr6mnx4cAN4S+caCI/8Ne0osBWOhP/OMpAUzJ4EcsIbnaTLjAYluDwVqDge +SwxgA6ncZHaO4Y/IXepedICyX1sp01ZzayCk0CcizMWlI8DtBo/AH/2jTkW5Dr5QygY 3ZL8oSbPSVKMBCOEFiBGKpB0l0PtED2qApqwfTUC9ZKp30bwiJc7SZeadDlivDElL60H X8QG01+VguvSS9xjr9X93rwIXKsbvCJOsApomyWD6hFY3xPU9k2dfZLQVEBCDSWG1ngv NI8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot14si8703608pjb.88.2022.01.21.14.25.21; Fri, 21 Jan 2022 14:25:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376987AbiATQZ6 (ORCPT + 99 others); Thu, 20 Jan 2022 11:25:58 -0500 Received: from foss.arm.com ([217.140.110.172]:44070 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376986AbiATQZz (ORCPT ); Thu, 20 Jan 2022 11:25:55 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 62DA71396; Thu, 20 Jan 2022 08:25:55 -0800 (PST) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.196.57]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EE9823F73D; Thu, 20 Jan 2022 08:25:52 -0800 (PST) From: Valentin Schneider To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Abhijeet Dharmapurikar , Dietmar Eggemann , Steven Rostedt , Peter Zijlstra , Ingo Molnar , Vincent Guittot , Thomas Gleixner , Sebastian Andrzej Siewior , Juri Lelli , Daniel Bristot de Oliveira , Kees Cook , Andrew Morton , "Eric W. Biederman" , Alexey Gladkov , "Kenta.Tada@sony.com" , Randy Dunlap , Ed Tsai Subject: [PATCH v3 2/2] sched/tracing: Report TASK_RTLOCK_WAIT tasks as TASK_UNINTERRUPTIBLE Date: Thu, 20 Jan 2022 16:25:20 +0000 Message-Id: <20220120162520.570782-3-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220120162520.570782-1-valentin.schneider@arm.com> References: <20220120162520.570782-1-valentin.schneider@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- include/linux/sched.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index d00837d12b9d..068270ff04b8 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.25.1