s390/pai: Reduce excessive debug feature size
Heiko Carstens
maintainerPATCH 1/1 s390/pai: Reduce excessive debug feature size
The pai debug feature is registered with 256 areas, where each area contains 32 pages. This sums up to a total of 32MiB. The code does not use any debug exceptions, which means that 255 of those areas are never used. In addition all existing debug feature calls have a lower level (5) than the default level (3).
This in turn means that without user interaction the debug feature is unused.
Reduce the number of areas to 1, and also reduce the number of pages for the remaining area to 1. Since user interaction is required, the user can also increase the size of the remaining area, instead of wasting memory by default.
This reduces the total size of the debug feature to 4KiB.
--- arch/s390/kernel/perf_pai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/perf_pai.c +1 -1
@@ -1221,7 +1221,7 @@ static int __init paipmu_setup(void)static int __init pai_init (void ) {/* Setup s390dbf facility */ - paidbg =debug_register ("pai" ,32 ,256 ,128 ); + paidbg =debug_register ("pai" ,1 ,1 ,128 );if (!paidbg) {pr_err ("Registration of s390dbf pai failed\n" );return -ENOMEM ;
Signature · 1 line
2.53.0
Quoted 27 lines · Heiko Carstens
The pai debug feature is registered with 256 areas, where each area contains 32 pages. This sums up to a total of 32MiB. The code does not use any debug exceptions, which means that 255 of those areas are never used. In addition all existing debug feature calls have a lower level (5) than the default level (3).
This in turn means that without user interaction the debug feature is unused.
Reduce the number of areas to 1, and also reduce the number of pages for the remaining area to 1. Since user interaction is required, the user can also increase the size of the remaining area, instead of wasting memory by default.
This reduces the total size of the debug feature to 4KiB.
Fixes a3f8423622ef ("s390/pai_crypto: Add PAI crypto characteristics table for parameters")Signed-off-by Heiko Carstens <[email protected]>--- arch/s390/kernel/perf_pai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/kernel/perf_pai.c +0
-0
arch/s390/kernel/perf_pai.c static int __init paipmu_setup(void) · line 1227
Quoted 8 lines
arch/s390/kernel/perf_pai.c +1
-1@@ -1221,7 +1221,7 @@ static int __init paipmu_setup(void)static int __init pai_init (void ) {/* Setup s390dbf facility */ - paidbg =debug_register ("pai" ,32 ,256 ,128 ); + paidbg =debug_register ("pai" ,1 ,1 ,128 );if (!paidbg) {pr_err ("Registration of s390dbf pai failed\n" );return -ENOMEM ;
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
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing CPU hotplug handling causes uninitialized per-CPU pointers to be dereferenced when task-bound perf events migrate to newly onlined CPUs. --
--- Patch [1]: [PATCH] s390/pai: Reduce excessive debug feature size --- commit 07fb6d75462afb53888116fff8b2fe4b2e6d8db6
Author: Heiko Carstens <[email protected]>
s390/pai: Reduce excessive debug feature size
The pai debug feature is registered with 256 areas, where each area contains 32 pages. This sums up to a total of 32MiB. The code does not use any debug exceptions, which means that 255 of those areas are never used.
arch/s390/kernel/perf_pai.c static int __init paipmu_setup(void) · line 1224
Quoted 10 lines
arch/s390/kernel/perf_pai.c +1
-1@@ -1221,7 +1221,7 @@ static int __init paipmu_setup(void)static int __init pai_init (void ) {/* Setup s390dbf facility */ - paidbg =debug_register ("pai" ,32 ,256 ,128 ); + paidbg =debug_register ("pai" ,1 ,1 ,128 );
[Severity: High]
This is a pre-existing issue, but does the PAI PMU code handle CPU hotplugging correctly?
If pai_alloc() only allocates PMU tracking structures for currently online CPUs:
arch/s390/kernel/perf_pai.c:pai_alloc() {
...
for_each_online_cpu(cpu) {
rc = pai_alloc_cpu(event, cpu);
if (rc) {
...
}And a task with an active PAI event migrates to a newly onlined CPU where structures were not allocated, won't mp->mapptr be NULL here:
arch/s390/kernel/perf_pai.c:pai_add() {
...
struct pai_map *cpump = mp->mapptr;
struct paiext_cb *pcb = cpump->paiext_cb;
unsigned long ccd;
if (++cpump->active_events == 1) {
...
}Could this lead to a NULL pointer dereference when accessing cpump->paiext_cb or cpump->active_events?
Quoted 3 lines
arch/s390/kernel/perf_pai.c +0
-0if (!paidbg) {pr_err ("Registration of s390dbf pai failed\n" );return -ENOMEM ;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 14 lines · Heiko Carstens
The pai debug feature is registered with 256 areas, where each area contains 32 pages. This sums up to a total of 32MiB. The code does not use any debug exceptions, which means that 255 of those areas are never used. In addition all existing debug feature calls have a lower level (5) than the default level (3).
This in turn means that without user interaction the debug feature is unused.
Reduce the number of areas to 1, and also reduce the number of pages for the remaining area to 1. Since user interaction is required, the user can also increase the size of the remaining area, instead of wasting memory by default.
Quoted 7 lines
This reduces the total size of the debug feature to 4KiB.
Fixes a3f8423622ef ("s390/pai_crypto: Add PAI crypto characteristics table for parameters")Signed-off-by Heiko Carstens <[email protected]>--- arch/s390/kernel/perf_pai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thank you!