From nobody Wed Feb 5 20:33:06 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 623A6236A6E; Wed, 15 Jan 2025 09:17:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736932641; cv=none; b=Xe3HgVC8GP8RfsbjXN01G9fnRm/gqVeKT2dR39OBiYGaHtojS97YshfQCIr9Zo78B/hne+HfUNsRIVFeIsXox1a8Ti2BzzeNjlzbXRsLo+xIAILpePOD9Sw5q0V2x5ScCqAqyWNs9OSRCappaInyN29aFpw7E37tU5tRoRXDMiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736932641; c=relaxed/simple; bh=YpXKpQQETMEmck3HRcQgEFFRwFZHoi9KmOPEyl8Wx3Y=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=GT5FLHX0itslXrckDCMzSOcN3E4aBlmx/onISLjVzzlVyrnb9h+tuZrqQUroNpSnu4m2D4ilAIlBqv+P6mbBLkB4/H9W9PBzgQyk6LdFfmS+nU7/ScNOIBp1k/R/MUgXx+lySMB9sbFvJ8t84RqEgO2O9Q7iemZdLxnYD2X9lx0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dlGFdvD0; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=TkuXBraQ; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dlGFdvD0"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="TkuXBraQ" Date: Wed, 15 Jan 2025 09:17:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1736932637; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o3BvKjOchkbshnRxwXidXW47mEpAST2MS2fWuciW6QE=; b=dlGFdvD0H5dFeF+VofUWz8sQXRRQr1RiXqTCTeN9DTd8XviKstmAjGdow/rRURKCPVWyO7 sSshdI5JJ/TGoxZsSLpdtGJTxxpzj1/VBeBQWa67tNQ2AbQFAuA0RFvORQTit4woZ0Deyo JkVoeoLTC1tV+Qrvponb5RsrGu62/AP4xsyR7ZMUlp6InJhY/4k3ggkVjx77fd0kJN1AL7 IY2TDmMUiUrQblioFXgFI5yHFsBucchrhPXVwYk5MdeLuhrTMPX1GG0RJY/q2B16KgHCGf Ds4lkvICMc+uZzHJGijfd+9dnGfvL2bkUVIcJCKKO3O61gRfF7fVy2/4kNzU6w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1736932637; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o3BvKjOchkbshnRxwXidXW47mEpAST2MS2fWuciW6QE=; b=TkuXBraQQWDqsoFZM53ker37kXPxAGl4lS/VkFRABAajO/8eo1lUxm05v29B/+BaN7trr6 xl7APbdRp60gnsAA== From: "tip-bot2 for K Prateek Nayak" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] x86/itmt: Move the "sched_itmt_enabled" sysctl to debugfs Cc: Peter Zijlstra , K Prateek Nayak , Tim Chen , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20241223043407.1611-4-kprateek.nayak@amd.com> References: <20241223043407.1611-4-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <173693263689.31546.15174865187592950218.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/core branch of tip: Commit-ID: d04013a4b21bd5a4e10c42f71ed1e5e299cacdfe Gitweb: https://git.kernel.org/tip/d04013a4b21bd5a4e10c42f71ed1e5e29= 9cacdfe Author: K Prateek Nayak AuthorDate: Mon, 23 Dec 2024 04:34:02=20 Committer: Peter Zijlstra CommitterDate: Mon, 13 Jan 2025 14:10:24 +01:00 x86/itmt: Move the "sched_itmt_enabled" sysctl to debugfs "sched_itmt_enabled" was only introduced as a debug toggle for any funky ITMT behavior. Move the sysctl controlled from "/proc/sys/kernel/sched_itmt_enabled" to debugfs at "/sys/kernel/debug/x86/sched_itmt_enabled" with a notable change that a cat on the file will return "Y" or "N" instead of "1" or "0" to indicate that feature is enabled or disabled respectively. Either "0" or "N" (or any string that kstrtobool() interprets as false) can be written to the file will disable the feature, and writing either "1" or "Y" (or any string that kstrtobool() interprets as true) will enable it back when the platform supports ITMT ranking. Since ITMT is x86 specific (and PowerPC uses SD_ASYM_PACKING too), the toggle was moved to "/sys/kernel/debug/x86/" as opposed to "/sys/kernel/debug/sched/" Suggested-by: Peter Zijlstra Signed-off-by: K Prateek Nayak Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Tim Chen Link: https://lore.kernel.org/r/20241223043407.1611-4-kprateek.nayak@amd.com --- arch/x86/kernel/itmt.c | 56 +++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/arch/x86/kernel/itmt.c b/arch/x86/kernel/itmt.c index ee43d1b..9cea1fc 100644 --- a/arch/x86/kernel/itmt.c +++ b/arch/x86/kernel/itmt.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -34,45 +35,38 @@ static bool __read_mostly sched_itmt_capable; * of higher turbo frequency for cpus supporting Intel Turbo Boost Max * Technology 3.0. * - * It can be set via /proc/sys/kernel/sched_itmt_enabled + * It can be set via /sys/kernel/debug/x86/sched_itmt_enabled */ bool __read_mostly sysctl_sched_itmt_enabled; =20 -static int sched_itmt_update_handler(const struct ctl_table *table, int wr= ite, - void *buffer, size_t *lenp, loff_t *ppos) +static ssize_t sched_itmt_enabled_write(struct file *filp, + const char __user *ubuf, + size_t cnt, loff_t *ppos) { - unsigned int old_sysctl; - int ret; + ssize_t result; + bool orig; =20 guard(mutex)(&itmt_update_mutex); =20 - if (!sched_itmt_capable) - return -EINVAL; - - old_sysctl =3D sysctl_sched_itmt_enabled; - ret =3D proc_dointvec_minmax(table, write, buffer, lenp, ppos); + orig =3D sysctl_sched_itmt_enabled; + result =3D debugfs_write_file_bool(filp, ubuf, cnt, ppos); =20 - if (!ret && write && old_sysctl !=3D sysctl_sched_itmt_enabled) { + if (sysctl_sched_itmt_enabled !=3D orig) { x86_topology_update =3D true; rebuild_sched_domains(); } =20 - return ret; + return result; } =20 -static struct ctl_table itmt_kern_table[] =3D { - { - .procname =3D "sched_itmt_enabled", - .data =3D &sysctl_sched_itmt_enabled, - .maxlen =3D sizeof(unsigned int), - .mode =3D 0644, - .proc_handler =3D sched_itmt_update_handler, - .extra1 =3D SYSCTL_ZERO, - .extra2 =3D SYSCTL_ONE, - }, +static const struct file_operations dfs_sched_itmt_fops =3D { + .read =3D debugfs_read_file_bool, + .write =3D sched_itmt_enabled_write, + .open =3D simple_open, + .llseek =3D default_llseek, }; =20 -static struct ctl_table_header *itmt_sysctl_header; +static struct dentry *dfs_sched_itmt; =20 /** * sched_set_itmt_support() - Indicate platform supports ITMT @@ -98,9 +92,15 @@ int sched_set_itmt_support(void) if (sched_itmt_capable) return 0; =20 - itmt_sysctl_header =3D register_sysctl("kernel", itmt_kern_table); - if (!itmt_sysctl_header) + dfs_sched_itmt =3D debugfs_create_file_unsafe("sched_itmt_enabled", + 0644, + arch_debugfs_dir, + &sysctl_sched_itmt_enabled, + &dfs_sched_itmt_fops); + if (IS_ERR_OR_NULL(dfs_sched_itmt)) { + dfs_sched_itmt =3D NULL; return -ENOMEM; + } =20 sched_itmt_capable =3D true; =20 @@ -131,10 +131,8 @@ void sched_clear_itmt_support(void) =20 sched_itmt_capable =3D false; =20 - if (itmt_sysctl_header) { - unregister_sysctl_table(itmt_sysctl_header); - itmt_sysctl_header =3D NULL; - } + debugfs_remove(dfs_sched_itmt); + dfs_sched_itmt =3D NULL; =20 if (sysctl_sched_itmt_enabled) { /* disable sched_itmt if we are no longer ITMT capable */