Fixing infinite loop on SCLP READ SCP INFO error
cover Fixing infinite loop on SCLP READ SCP INFO error
Aborting on SCLP READ SCP INFO error leads to a deadloop.
The loop is:abort() -> exit() -> smp_teardown() -> smp_query_num_cpus() -> sclp_get_cpu_num() -> assert() -> abort()
Since smp_setup() is done after sclp_read_info() inside setup() this loop only happens when only the start processor is running. Let sclp_get_cpu_num() return 1 in this case.
Pierre Morel (1):
s390x: sclp: consider monoprocessor on read_info error
lib/s390x/sclp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/1 s390x: sclp: consider monoprocessor on read_info error
When we can not read SCP information we can not abort during sclp_get_cpu_num() because this function is called during exit and calling it will lead to an infnite loop.
The loop is:abort() -> exit() -> smp_teardown() -> smp_query_num_cpus() -> sclp_get_cpu_num() -> assert() -> abort()
Since smp_setup() is done after sclp_read_info() inside setup() this loop happens when only the start processor is running. Let sclp_get_cpu_num() return 1 in this case.
--- lib/s390x/sclp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/s390x/sclp.c +3 -2
@@ -119,8 +119,9 @@ void sclp_read_info(void)int sclp_get_cpu_num (void ) { -assert (read_info); -return read_info->entries_cpu; +if (read_info) +return read_info->entries_cpu; +return 1 ; }CPUEntry *sclp_get_cpu_entries (void )
Signature · 1 line
2.31.1
Re: [kvm-unit-tests PATCH 1/1] s390x: sclp: consider monoprocessor on read_info error
Quoted 11 lines · On Mon, 24 Apr 2023 19:42:18 +0200 Pierre Morel <[email protected]> wrote:
When we can not read SCP information we can not abort during
sclp_get_cpu_num()because this function is called during exit and calling it will lead to an infnite loop.The loop is:
abort()->exit()->smp_teardown()->smp_query_num_cpus()->sclp_get_cpu_num()->assert()->abort()Since
smp_setup()is done aftersclp_read_info()insidesetup()this loop happens when only the start processor is running. Letsclp_get_cpu_num()return 1 in this case.
looks good to me, but please add a comment to explain that this is only supposed to happen in exceptional circumstances
Quoted 23 lines
Fixes 52076a63d569 ("s390x: Consolidate sclp read info")Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/sclp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)lib/s390x/sclp.c +3
-2@@ -119,8 +119,9 @@ void sclp_read_info(void)int sclp_get_cpu_num (void ) { -assert (read_info); -return read_info->entries_cpu; +if (read_info) +return read_info->entries_cpu; +return 1 ; }CPUEntry *sclp_get_cpu_entries (void )
Re: [kvm-unit-tests PATCH 1/1] s390x: sclp: consider monoprocessor on read_info error
Quoted 11 lines · Claudio Imbrenda
Quoted 8 lines · On Mon, 24 Apr 2023 19:42:18 +0200 Pierre Morel <[email protected]> wrote:
When we can not read SCP information we can not abort during
sclp_get_cpu_num()because this function is called during exit and calling it will lead to an infnite loop.The loop is:
abort()->exit()->smp_teardown()->smp_query_num_cpus()->sclp_get_cpu_num()->assert()->abort()
Quoted 5 lines
Quoted 3 lines
Since
smp_setup()is done aftersclp_read_info()insidesetup()this loop happens when only the start processor is running. Letsclp_get_cpu_num()return 1 in this case.looks good to me, but please add a comment to explain that this is only supposed to happen in exceptional circumstances
Is this ok like this:
"
Read SCP information can fails if the SCLP buffer length is too small for the information to return which happens for example when defining 248 CPUs.
When SCLP read SCP information did fail during setup, we can currently not abort because the function sclp_get_cpu_num(), called during exit, asserts on the previous success of SCLP read SCP information.
The loop is:abort() -> exit() -> smp_teardown() -> smp_query_num_cpus() -> sclp_get_cpu_num() -> assert() -> abort()
Since smp_setup() is done after sclp_read_info() inside setup() this loop happens when only the start processor is running.
Since only one processor is running and we know it, we do not need to make the SCLP call in sclp_get_cpu_num() and can safely return 1. "
Quoted 23 lines
Quoted 23 lines
Fixes 52076a63d569 ("s390x: Consolidate sclp read info")Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/sclp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)lib/s390x/sclp.c +3
-2@@ -119,8 +119,9 @@ void sclp_read_info(void)int sclp_get_cpu_num (void ) { -assert (read_info); -return read_info->entries_cpu; +if (read_info) +return read_info->entries_cpu; +return 1 ; }CPUEntry *sclp_get_cpu_entries (void )
Re: [kvm-unit-tests PATCH 1/1] s390x: sclp: consider monoprocessor on read_info error
Quoted 5 lines · Pierre Morel
Quoted 3 lines · Claudio Imbrenda
On Mon, 24 Apr 2023 19:42:18 +0200
Pierre Morel <[email protected]> wrote:
How is this considered to be a fix and not a workaround?
Set the variable response bit in the control mask and vary the length based on stfle 140. See __init sclp_early_read_info() in drivers/s390/char/sclp_early_core.c
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Fixes 52076a63d569 ("s390x: Consolidate sclp read info")Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/sclp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)lib/s390x/sclp.c +3
-2@@ -119,8 +119,9 @@ void sclp_read_info(void)int sclp_get_cpu_num (void ) { -assert (read_info); -return read_info->entries_cpu; +if (read_info) +return read_info->entries_cpu; +return 1 ; }CPUEntry *sclp_get_cpu_entries (void )
Re: [kvm-unit-tests PATCH 1/1] s390x: sclp: consider monoprocessor on read_info error
Quoted 11 lines · Janosch Frank
Quoted 5 lines · Pierre Morel
Quoted 3 lines · Claudio Imbrenda
On Mon, 24 Apr 2023 19:42:18 +0200
Pierre Morel <[email protected]> wrote:How is this considered to be a fix and not a workaround?
Set the variable response bit in the control mask and vary the length based on stfle 140. See
__initsclp_early_read_info()indrivers/s390/char/sclp_early_core.c
Yes it is something to do anyway.
Still in case of error we will need this fix or workaround.
Quoted 24 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Fixes 52076a63d569 ("s390x: Consolidate sclp read info")Signed-off-by Pierre Morel <[email protected]>---
lib/s390x/sclp.c| 5 +++--1 file changed, 3 insertions(+), 2 deletions(-)lib/s390x/sclp.c +3
-2@@ -119,8 +119,9 @@ void sclp_read_info(void) int sclp_get_cpu_num(void) { - assert(read_info); - return read_info->entries_cpu; + if (read_info) + return read_info->entries_cpu; + return 1; } CPUEntry *sclp_get_cpu_entries(void)
Re: [kvm-unit-tests PATCH 1/1] s390x: sclp: consider monoprocessor on read_info error
Quoted 8 lines · On Tue, 25 Apr 2023 13:45:13 +0200 Pierre Morel <[email protected]> wrote:
Quoted 7 lines · Janosch Frank
Quoted 5 lines · Pierre Morel
Quoted 3 lines · Claudio Imbrenda
On Mon, 24 Apr 2023 19:42:18 +0200
Pierre Morel <[email protected]> wrote:
Quoted 6 lines
Quoted 6 lines
How is this considered to be a fix and not a workaround?
Set the variable response bit in the control mask and vary the length based on stfle 140. See
__initsclp_early_read_info()indrivers/s390/char/sclp_early_core.c
I agree that the SCLP needs to be fixed
Quoted 5 lines
Yes it is something to do anyway.
Still in case of error we will need this fix or workaround.
and I agree that we need this fix anyway
therefore the comment should be more generic and just mention the fact that the test would hang if an abort happens before SCLP Read SCP Information has completed.
Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Fixes 52076a63d569 ("s390x: Consolidate sclp read info")Signed-off-by Pierre Morel <[email protected]>---
lib/s390x/sclp.c| 5 +++--1 file changed, 3 insertions(+), 2 deletions(-)lib/s390x/sclp.c +3
-2@@ -119,8 +119,9 @@ void sclp_read_info(void) int sclp_get_cpu_num(void) { - assert(read_info); - return read_info->entries_cpu; + if (read_info) + return read_info->entries_cpu; + return 1; } CPUEntry *sclp_get_cpu_entries(void)
Re: [kvm-unit-tests PATCH 1/1] s390x: sclp: consider monoprocessor on read_info error
Quoted 18 lines · Claudio Imbrenda
Quoted 6 lines · On Tue, 25 Apr 2023 13:45:13 +0200 Pierre Morel <[email protected]> wrote:
Quoted 5 lines · Janosch Frank
Quoted 4 lines · Pierre Morel
Quoted 3 lines · Claudio Imbrenda
On Mon, 24 Apr 2023 19:42:18 +0200
Pierre Morel <[email protected]> wrote:Quoted 6 lines
Quoted 6 lines
How is this considered to be a fix and not a workaround?
Set the variable response bit in the control mask and vary the length based on stfle 140. See
__initsclp_early_read_info()indrivers/s390/char/sclp_early_core.cI agree that the SCLP needs to be fixed
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Yes it is something to do anyway.
Still in case of error we will need this fix or workaround.
and I agree that we need this fix anyway
therefore the comment should be more generic and just mention the fact that the test would hang if an abort happens before SCLP Read SCP Information has completed.
OK
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Fixes 52076a63d569 ("s390x: Consolidate sclp read info")Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/sclp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)lib/s390x/sclp.c +3
-2@@ -119,8 +119,9 @@ void sclp_read_info(void) int sclp_get_cpu_num(void) { - assert(read_info); - return read_info->entries_cpu; + if (read_info) + return read_info->entries_cpu; + return 1; } CPUEntry *sclp_get_cpu_entries(void)
Re: [kvm-unit-tests PATCH 1/1] s390x: sclp: consider monoprocessor on read_info error
In reply to Janosch FrankQuoted 8 lines · Janosch Frank
Quoted 5 lines · Pierre Morel
Quoted 3 lines · Claudio Imbrenda
On Mon, 24 Apr 2023 19:42:18 +0200
Pierre Morel <[email protected]> wrote:How is this considered to be a fix and not a workaround?
For me it was a fix because in the previous version the sclp failed but the abort did work and this patch does not fix sclp but the abort.