public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cao Ruichuang <create0818@163.com>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org
Cc: akinzler <bugzilla@kernel.org>
Subject: [PATCH] x86/itmt: Keep ITMT enabled when debugfs is unavailable
Date: Sat, 11 Apr 2026 19:17:31 +0800	[thread overview]
Message-ID: <20260411111731.33822-1-create0818@163.com> (raw)

SCHED_MC_PRIO should not depend on DEBUG_FS for its runtime behavior.

debugfs_create_file*() intentionally returns -ENODEV when CONFIG_DEBUG_FS
is disabled so callers can distinguish "debugfs unavailable" from a real
error. sched_set_itmt_support() currently treats that case as fatal and
returns an error before enabling ITMT support.

As a result, systems built with SCHED_MC_PRIO=y and DEBUG_FS=n silently
lose ITMT scheduling support even though the two debugfs files created in
itmt.c are only a debug toggle and a debug view of core priorities.

Treat -ENODEV from the debugfs helpers as "no debugfs support" and keep
going. Continue to fail on real debugfs creation errors.

Fixes: d04013a4b21b ("x86/itmt: Move the "sched_itmt_enabled" sysctl to debugfs")
Reported-by: akinzler <bugzilla@kernel.org>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220638
Signed-off-by: Cao Ruichuang <create0818@163.com>
---
Testing:
- latest-tree local compile validation with `CONFIG_DEBUG_FS=n` succeeded
  (`CC arch/x86/kernel/itmt.o`)

Note:
- meaningful local runtime validation is not currently possible here because
  the available host and guest CPUs are older Ivy Bridge parts, not
  ITMT-capable Intel hybrid systems

 arch/x86/kernel/itmt.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/itmt.c b/arch/x86/kernel/itmt.c
index 243a769fdd9..c3e40df7da7 100644
--- a/arch/x86/kernel/itmt.c
+++ b/arch/x86/kernel/itmt.c
@@ -100,6 +100,8 @@ static struct dentry *dfs_sched_core_prio;
  */
 int sched_set_itmt_support(void)
 {
+	int ret;
+
 	guard(mutex)(&itmt_update_mutex);
 
 	if (sched_itmt_capable)
@@ -110,16 +112,29 @@ int sched_set_itmt_support(void)
 						    arch_debugfs_dir,
 						    &sysctl_sched_itmt_enabled,
 						    &dfs_sched_itmt_fops);
-	if (IS_ERR_OR_NULL(dfs_sched_itmt)) {
+	if (IS_ERR(dfs_sched_itmt)) {
+		ret = PTR_ERR(dfs_sched_itmt);
 		dfs_sched_itmt = NULL;
+		if (ret != -ENODEV)
+			return ret;
+	} else if (!dfs_sched_itmt) {
 		return -ENOMEM;
 	}
 
 	dfs_sched_core_prio = debugfs_create_file("sched_core_priority", 0644,
 						  arch_debugfs_dir, NULL,
 						  &sched_core_priority_fops);
-	if (IS_ERR_OR_NULL(dfs_sched_core_prio)) {
+	if (IS_ERR(dfs_sched_core_prio)) {
+		ret = PTR_ERR(dfs_sched_core_prio);
 		dfs_sched_core_prio = NULL;
+		if (ret != -ENODEV) {
+			debugfs_remove(dfs_sched_itmt);
+			dfs_sched_itmt = NULL;
+			return ret;
+		}
+	} else if (!dfs_sched_core_prio) {
+		debugfs_remove(dfs_sched_itmt);
+		dfs_sched_itmt = NULL;
 		return -ENOMEM;
 	}
 
-- 
2.39.5 (Apple Git-154)


             reply	other threads:[~2026-04-11 11:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-11 11:17 Cao Ruichuang [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-04-11  0:41 [PATCH] x86/itmt: Keep ITMT enabled when debugfs is unavailable Cao Ruichuang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260411111731.33822-1-create0818@163.com \
    --to=create0818@163.com \
    --cc=bp@alien8.de \
    --cc=bugzilla@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox