Skip to content

Commit c53361c

Browse files
mpeKAGA-KOKO
authored andcommitted
cpu/SMT: Move smt/control simple exit cases earlier
Move the simple exit cases, i.e. those which don't depend on the value written, earlier in the function. That makes it clearer that regardless of the input those states cannot 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> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Zhang Rui <rui.zhang@intel.com> Link: https://lore.kernel.org/r/20230705145143.40545-4-ldufour@linux.ibm.com
1 parent 3f91691 commit c53361c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kernel/cpu.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,6 +2841,12 @@ __store_smt_control(struct device *dev, struct device_attribute *attr,
28412841
{
28422842
int ctrlval, ret;
28432843

2844+
if (cpu_smt_control == CPU_SMT_FORCE_DISABLED)
2845+
return -EPERM;
2846+
2847+
if (cpu_smt_control == CPU_SMT_NOT_SUPPORTED)
2848+
return -ENODEV;
2849+
28442850
if (sysfs_streq(buf, "on"))
28452851
ctrlval = CPU_SMT_ENABLED;
28462852
else if (sysfs_streq(buf, "off"))
@@ -2850,12 +2856,6 @@ __store_smt_control(struct device *dev, struct device_attribute *attr,
28502856
else
28512857
return -EINVAL;
28522858

2853-
if (cpu_smt_control == CPU_SMT_FORCE_DISABLED)
2854-
return -EPERM;
2855-
2856-
if (cpu_smt_control == CPU_SMT_NOT_SUPPORTED)
2857-
return -ENODEV;
2858-
28592859
ret = lock_device_hotplug_sysfs();
28602860
if (ret)
28612861
return ret;

0 commit comments

Comments
 (0)