Skip to content

Commit 15cdce1

Browse files
hramrachtyreld
authored andcommitted
ppc64_cpu: Clean up sysfs smt/control error handling
When the kernel does not support the sysfs interface do not report an error, fall back to the old method silently. Suggested-by: Nathan Lynch<[email protected]> Signed-off-by: Michal Suchanek <[email protected]> Signed-off-by: Tyrel Datwyler <[email protected]>
1 parent b0816b4 commit 15cdce1

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/ppc64_cpu.c

+21-5
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,30 @@ static int is_dscr_capable(void)
364364

365365
/*
366366
* Depends on kernel's CONFIG_HOTPLUG_CPU
367+
* Return -1 for fatal error, -2 to retry.
367368
*/
368369
static int set_smt_control(int smt_state)
369370
{
370371
if (set_attribute(SYS_SMT_CONTROL, "%d", smt_state)) {
371-
/* Silently ignore kernel not supporting this feature */
372-
if (errno != ENODEV)
373-
perror(SYS_SMT_CONTROL);
374-
return -1;
372+
switch (errno) {
373+
case ENOENT:
374+
/*
375+
* The kernel does not have the interface.
376+
* Try the old method.
377+
*/
378+
return -2;
379+
case ENODEV:
380+
/*
381+
* Setting SMT state not supported by this interface.
382+
* On older kernels (before Linux 6.6) the generic interface
383+
* may exist but is not hooked on powerpc resulting in ENODEV
384+
* on kernels that can set SMT using the old interface.
385+
*/
386+
return -2;
387+
default:
388+
perror(SYS_SMT_CONTROL);
389+
return -1;
390+
}
375391
}
376392
return 0;
377393
}
@@ -405,7 +421,7 @@ static int do_smt(char *state, bool numeric)
405421
}
406422

407423
/* Try using smt/control if failing, fall back to the legacy way */
408-
if (set_smt_control(smt_state))
424+
if ((rc = set_smt_control(smt_state)) == -2)
409425
rc = set_smt_state(smt_state);
410426
}
411427

0 commit comments

Comments
 (0)