From nobody Tue Apr 7 13:46:40 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 671C838F922 for ; Wed, 25 Feb 2026 09:52:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772013176; cv=none; b=Z5AhLr5BO3rYW1J+m/H+GgpF6XRfrFlEjNS+8C5RzztDNnfX4WK9MidoNSqUbysA1u3AAvujkibS5BLbPOJwVLmyEakPK3Uu4XI3qrUS20fB+CGbEUn3V583ouqkwodQSZ46MKqtYIUypbEO2K6tvnaxXVjc46KuE32fy6ODvls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772013176; c=relaxed/simple; bh=MDrEFgcwxr4RQmTHk+YJ5HbbpzMh6vpOEfDu2mLU91w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CPQdqPn5233a3nIIqaRtUutWY2IzZ+lV32OnVBTjL2X9g7kheWAm0UwRj7fegyuZtvP67hXmyFYuH0sVOrfQeAvTtiantQwVUFkOreOonkOKScrjuBCAa6hDSnAh+Na/8GRXL+asMqtctHkSbdr89YgfR8ojsbJ7XKs95GahDEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=aWarasNR; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aWarasNR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772013174; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kO0zoFWYPRbDr8YKYEjZMgyeFmg69CxtJKAzgYm3eLM=; b=aWarasNRR3jnJZO2MPT0Gv2BMfMIMb3qXS7LsIxOnueBRMALLibzDNal2KcgEDw9CgGTyP bocSgWvWsKpoFzZNve2z2NdTIqbIdqENm8sBIW5rGNOsC5oxWzRvQ+1/bJYsi6PsFPlDvm WG1S8y9m/oSUBRK1+jSuG+eHNxYuKt4= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-395-ghaZjbg-McKL45C9Q17gmg-1; Wed, 25 Feb 2026 04:52:51 -0500 X-MC-Unique: ghaZjbg-McKL45C9Q17gmg-1 X-Mimecast-MFC-AGG-ID: ghaZjbg-McKL45C9Q17gmg_1772013169 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AA8231956088; Wed, 25 Feb 2026 09:52:49 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.34.216]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6F5781800370; Wed, 25 Feb 2026 09:52:44 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Tejun Heo , Andrea Righi , Steven Rostedt , Nam Cao , Juri Lelli , Ingo Molnar , Peter Zijlstra , sched-ext@lists.linux.dev Cc: Gabriele Monaco , Tomas Glozar , Clark Williams , John Kacur , linux-trace-kernel@vger.kernel.org Subject: [PATCH v6 14/16] sched_ext: Export task_is_scx_enabled() for verification Date: Wed, 25 Feb 2026 10:51:20 +0100 Message-ID: <20260225095122.80683-15-gmonaco@redhat.com> In-Reply-To: <20260225095122.80683-1-gmonaco@redhat.com> References: <20260225095122.80683-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" When a sched_ext scheduler is loaded, depending on the configuration, it can handle also fair tasks, however it isn't trivial to understand if a certain task is currently handled by fair or ext outside of scheduler code. This can be a problem when writing verification or observability tools like RV monitors. Export a task_is_scx_enabled() to allow quick classification by using the scx state SCX_TASK_ENABLED. To: Tejun Heo To: Andrea Righi Signed-off-by: Gabriele Monaco --- include/linux/sched/ext.h | 2 ++ kernel/sched/ext.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/linux/sched/ext.h b/include/linux/sched/ext.h index bcb962d5ee7d..68e5aff95159 100644 --- a/include/linux/sched/ext.h +++ b/include/linux/sched/ext.h @@ -232,6 +232,7 @@ void print_scx_info(const char *log_lvl, struct task_st= ruct *p); void scx_softlockup(u32 dur_s); bool scx_hardlockup(int cpu); bool scx_rcu_cpu_stall(void); +bool task_is_scx_enabled(struct task_struct *p); =20 #else /* !CONFIG_SCHED_CLASS_EXT */ =20 @@ -240,6 +241,7 @@ static inline void print_scx_info(const char *log_lvl, = struct task_struct *p) {} static inline void scx_softlockup(u32 dur_s) {} static inline bool scx_hardlockup(int cpu) { return false; } static inline bool scx_rcu_cpu_stall(void) { return false; } +static inline bool task_is_scx_enabled(struct task_struct *p) { return fal= se; } =20 #endif /* CONFIG_SCHED_CLASS_EXT */ =20 diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index 62b1f3ac5630..1e48bc3cde15 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -3772,6 +3772,14 @@ bool task_should_scx(int policy) return policy =3D=3D SCHED_EXT; } =20 +/* + * Used by verification/observability tools like RV monitors. + */ +bool task_is_scx_enabled(struct task_struct *p) +{ + return scx_get_task_state(p) =3D=3D SCX_TASK_ENABLED; +} + bool scx_allow_ttwu_queue(const struct task_struct *p) { struct scx_sched *sch; --=20 2.53.0