Skip to content

Commit

Permalink
cpu/SMT: Move smt/control simple exit cases earlier
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Tested-by: Zhang Rui <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
mpe authored and KAGA-KOKO committed Jul 28, 2023
1 parent 3f91691 commit c53361c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2841,6 +2841,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"))
Expand All @@ -2850,12 +2856,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;
Expand Down

0 comments on commit c53361c

Please sign in to comment.