s390/pai: Simplify pai_init() and always return -ENODEV on failure
PATCH 1/1 s390/pai: Simplify pai_init() and always return -ENODEV on failure
Code simplification and remove variable state.
Return -ENODEV in all failures to indicate the PAI PMUs are not available.
--- arch/s390/kernel/perf_pai.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
arch/s390/kernel/perf_pai.c +5 -7
@@ -1304,7 +1304,7 @@ static int pai_offline_cpu(unsigned int cpu)static int __init pai_init (void ) { -int state, rc; +int rc;/* Setup s390dbf facility */ paidbg =debug_register ("pai" ,1 ,1 ,128 );
@@ -1315,23 +1315,21 @@ static int __init pai_init(void)debug_register_view (paidbg, &debug_sprintf_view);/* CPUHP_BP_PREPARE_DYN --> before CPU is brought online */ - state =cpuhp_setup_state (CPUHP_BP_PREPARE_DYN ,"perf/pai:prepare" , - pai_online_cpu, pai_offline_cpu); - rc = state <0 ? state :0 ; + rc =cpuhp_setup_state (CPUHP_BP_PREPARE_DYN ,"perf/pai:prepare" , + pai_online_cpu, pai_offline_cpu);if (rc <0 ) goto out_debug; - rc = -ENODEV ;if (!paipmu_setup ()) goto out_cpuhp;return 0 ; out_cpuhp: -cpuhp_remove_state (state); +cpuhp_remove_state (rc); out_debug:debug_unregister_view (paidbg, &debug_sprintf_view);debug_unregister (paidbg); -return rc; +return -ENODEV ; }device_initcall (pai_init);
Signature · 1 line
2.55.0
Quoted 5 lines · Thomas Richter
Code simplification and remove variable state.
Return-ENODEVin all failures to indicate the PAI PMUs are not available.Signed-off-by Thomas Richter <[email protected]>
Looks good to me.
Heiko Carstens
maintainerQuoted 3 lines · Thomas Richter
Code simplification and remove variable state.
Return-ENODEVin all failures to indicate the PAI PMUs are not available.
Why do you want to hide different error / return codes? That makes debugging in case of an error more difficult.
Quoted 7 lines · Heiko Carstens
Quoted 3 lines · Thomas Richter
Code simplification and remove variable state.
Return-ENODEVin all failures to indicate the PAI PMUs are not available.Why do you want to hide different error / return codes? That makes debugging in case of an error more difficult.
Well, hiding was not the intent.
The kernel common code does a lot of checks at event creation, then calls the PMU event_init() call back to install the event. When this fails the return code is checked and further action depends on this return code. See
perf_init_event()
+--> perf_try_event_init()
+--> PMU->event_init()See include/linux/perf_event.h for return code meanings.
When we return the value from cpuhp_setup_state(), it must no be -ENOENT and some other values. Because those are used for postprocessing.
Thats why I always return -ENODEV, meaning event is valid for PMU, but PMU not operational. I thouhgt this might fit best.
Signature · 9 lines
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany -- IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
Heiko Carstens
maintainerQuoted 20 lines · Thomas Richter
Quoted 7 lines · Heiko Carstens
Quoted 3 lines · Thomas Richter
Code simplification and remove variable state.
Return-ENODEVin all failures to indicate the PAI PMUs are not available.Why do you want to hide different error / return codes? That makes debugging in case of an error more difficult.
Well, hiding was not the intent.
The kernel common code does a lot of checks at event creation, then calls the PMU
event_init()call back to install the event. When this fails the return code is checked and further action depends on this return code. See
perf_init_event()+--> perf_try_event_init() +--> PMU->event_init()
Quoted 7 lines
See
include/linux/perf_event.hfor return code meanings.When we return the value from
cpuhp_setup_state(), it must no be-ENOENTand some other values. Because those are used for postprocessing.Thats why I always return
-ENODEV, meaning event is valid for PMU, but PMU not operational. I thouhgt this might fit best.
But what does have pai_init() to do with anything of the above? pai_init() is called via init_call() mechanism.
Quoted 23 lines · Heiko Carstens
Quoted 22 lines · Thomas Richter
Quoted 7 lines · Heiko Carstens
Quoted 3 lines · Thomas Richter
Code simplification and remove variable state.
Return-ENODEVin all failures to indicate the PAI PMUs are not available.Why do you want to hide different error / return codes? That makes debugging in case of an error more difficult.
Well, hiding was not the intent.
The kernel common code does a lot of checks at event creation, then calls the PMU
event_init()call back to install the event. When this fails the return code is checked and further action depends on this return code. See
perf_init_event()+--> perf_try_event_init() +--> PMU->event_init()See
include/linux/perf_event.hfor return code meanings.
Quoted 8 lines
Quoted 5 lines
When we return the value from
cpuhp_setup_state(), it must no be-ENOENTand some other values. Because those are used for postprocessing.Thats why I always return
-ENODEV, meaning event is valid for PMU, but PMU not operational. I thouhgt this might fit best.But what does have
pai_init()to do with anything of the above?pai_init()is called viainit_call()mechanism.
Ahh well, that is correct... lets drop it. Sorry for the noise.
Signature · 9 lines
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany -- IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294