From: Laurent Dufour <ldufour@linux.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: linux-arch@vger.kernel.org, dave.hansen@linux.intel.com,
x86@kernel.org, mingo@redhat.com, bp@alien8.de,
npiggin@gmail.com, tglx@linutronix.de,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 02/10] cpu/SMT: Move smt/control simple exit cases earlier
Date: Thu, 15 Jun 2023 17:46:27 +0200 [thread overview]
Message-ID: <20230615154635.13660-3-ldufour@linux.ibm.com> (raw)
In-Reply-To: <20230615154635.13660-1-ldufour@linux.ibm.com>
From: Michael Ellerman <mpe@ellerman.id.au>
Move the simple exit cases, ie. which don't depend on the value written,
earlier in the function. That makes it clearer that regardless of the
input those states can not be transitioned out of.
That does have a user-visible effect, in that the error returned will
now always be EPERM/ENODEV for those states, regardless of the value
written. Previously writing an invalid value would return EINVAL even
when in those states.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
kernel/cpu.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 237394e0574a..c67049bb3fc8 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -2482,6 +2482,12 @@ __store_smt_control(struct device *dev, struct device_attribute *attr,
{
int ctrlval, ret;
+ if (cpu_smt_control == CPU_SMT_FORCE_DISABLED)
+ return -EPERM;
+
+ if (cpu_smt_control == CPU_SMT_NOT_SUPPORTED)
+ return -ENODEV;
+
if (sysfs_streq(buf, "on"))
ctrlval = CPU_SMT_ENABLED;
else if (sysfs_streq(buf, "off"))
@@ -2491,12 +2497,6 @@ __store_smt_control(struct device *dev, struct device_attribute *attr,
else
return -EINVAL;
- if (cpu_smt_control == CPU_SMT_FORCE_DISABLED)
- return -EPERM;
-
- if (cpu_smt_control == CPU_SMT_NOT_SUPPORTED)
- return -ENODEV;
-
ret = lock_device_hotplug_sysfs();
if (ret)
return ret;
--
2.41.0
next prev parent reply other threads:[~2023-06-15 15:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 15:46 [PATCH 00/10] Introduce SMT level and add PowerPC support Laurent Dufour
2023-06-15 15:46 ` [PATCH 01/10] cpu/SMT: Move SMT prototypes into cpu_smt.h Laurent Dufour
2023-06-22 8:51 ` Thomas Gleixner
2023-06-15 15:46 ` Laurent Dufour [this message]
2023-06-15 15:46 ` [PATCH 03/10] cpu/SMT: Store the current/max number of threads Laurent Dufour
2023-06-15 15:46 ` [PATCH 04/10] cpu/SMT: Remove topology_smt_supported() Laurent Dufour
2023-06-15 15:46 ` [PATCH 05/10] cpu/SMT: Create topology_smt_threads_supported() Laurent Dufour
2023-06-15 15:46 ` [PATCH 06/10] cpu/SMT: Create topology_smt_thread_allowed() Laurent Dufour
2023-06-15 15:46 ` [PATCH 07/10] cpu/SMT: Allow enabling partial SMT states via sysfs Laurent Dufour
2023-06-22 9:12 ` Thomas Gleixner
2023-06-22 12:14 ` Michael Ellerman
2023-06-15 15:46 ` [PATCH 08/10] powerpc/pseries: Initialise CPU hotplug callbacks earlier Laurent Dufour
2023-06-15 15:46 ` [PATCH 09/10] powerpc: Add HOTPLUG_SMT support Laurent Dufour
2023-06-15 15:46 ` [PATCH 10/10] powerpc/pseries: Honour current SMT state when DLPAR onlining CPUs Laurent Dufour
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=20230615154635.13660-3-ldufour@linux.ibm.com \
--to=ldufour@linux.ibm.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mingo@redhat.com \
--cc=npiggin@gmail.com \
--cc=tglx@linutronix.de \
--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;
as well as URLs for NNTP newsgroup(s).