Bug 215781

Summary: Highmem support broken on kernels greater 5.15.x on ppc32?
Product: Platform Specific/Hardware Reporter: Erhard F. (erhard_f)
Component: PPC-32Assignee: platform_ppc-32
Status: RESOLVED CODE_FIX    
Severity: normal CC: christophe.leroy
Priority: P1    
Hardware: PPC-32   
OS: Linux   
Kernel Version: 5.16.18 Subsystem:
Regression: Yes Bisected commit-id:
Attachments: dmesg (5.16.18, PowerMac G4 DP)
dmesg (5.15.32, PowerMac G4 DP)
kernel .config (5.16.18, PowerMac G4 DP)
kernel .config (5.15.32, PowerMac G4 DP)
dmesg (5.18-rc3, PowerMac G4 DP)

Description Erhard F. 2022-03-30 22:52:20 UTC
Created attachment 300664 [details]
dmesg (5.16.18, PowerMac G4 DP)

Noticed my G4 DP ran a bit sluggish... Turned out it uses only 614664K of 2097152K RAM. Happens on both kernel 5.16.18 and 5.17.1. Kernels 5.15 and before work as expected.

It seems to be a problem with highmem as 5.16.18 and 5.1.7.1 show 0K highmem. CONFIG_HIGHMEM=y is of course set.

Kernel 5.16.18 says:
[...]
Top of RAM: 0x80000000, Total RAM: 0x80000000
Memory hole size: 0MB
Zone ranges:
  DMA      [mem 0x0000000000000000-0x0000000027ffffff]
  Normal   empty
  HighMem  [mem 0x0000000028000000-0x000000007fffffff]
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x0000000000000000-0x000000007fffffff]
Initmem setup node 0 [mem 0x0000000000000000-0x000000007fffffff]
percpu: Embedded 12 pages/cpu s19404 r8192 d21556 u49152
pcpu-alloc: s19404 r8192 d21556 u49152 alloc=12*4096
pcpu-alloc: [0] 0 [0] 1 
Built 1 zonelists, mobility grouping on.  Total pages: 522848
Kernel command line: ro root=/dev/sda5 zswap.max_pool_percent=16 zswap.zpool=z3fold slub_debug=FZP page_poison=1 netconsole=6666@192.168.2.5/eth0,6666@192.168.2.2/70:85:C2:30:EC:01 
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
mem auto-init: stack:__user(zero), heap alloc:off, heap free:off
Kernel virtual memory layout:
  * 0xffbbf000..0xfffff000  : fixmap
  * 0xff400000..0xff800000  : highmem PTEs
  * 0xff115000..0xff400000  : early ioremap
  * 0xe9000000..0xff115000  : vmalloc & ioremap
  * 0xb0000000..0xc0000000  : modules
Memory: 614664K/2097152K available (8828K kernel code, 488K rwdata, 1664K rodata, 1316K init, 381K bss, 1482488K reserved, 0K cma-reserved, 0K highmem)
[...]

On kernel 5.15.23 I got highmem as expected:
[...]
Top of RAM: 0x80000000, Total RAM: 0x80000000
Memory hole size: 0MB
Zone ranges:
  DMA      [mem 0x0000000000000000-0x0000000027ffffff]
  Normal   empty
  HighMem  [mem 0x0000000028000000-0x000000007fffffff]
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x0000000000000000-0x000000007fffffff]
Initmem setup node 0 [mem 0x0000000000000000-0x000000007fffffff]
percpu: Embedded 12 pages/cpu s19404 r8192 d21556 u49152
pcpu-alloc: s19404 r8192 d21556 u49152 alloc=12*4096
pcpu-alloc: [0] 0 [0] 1 
Built 1 zonelists, mobility grouping on.  Total pages: 522848
Kernel command line: ro root=/dev/sda5 zswap.max_pool_percent=16 zswap.zpool=z3fold slub_debug=FZP page_poison=1 netconsole=6666@192.168.2.5/eth0,6666@192.168.2.2/70:85:C2:30:EC:01 
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
mem auto-init: stack:__user(zero), heap alloc:off, heap free:off
Kernel virtual memory layout:
  * 0xffbbf000..0xfffff000  : fixmap
  * 0xff400000..0xff800000  : highmem PTEs
  * 0xff115000..0xff400000  : early ioremap
  * 0xe9000000..0xff115000  : vmalloc & ioremap
  * 0xb0000000..0xc0000000  : modules
Memory: 2056460K/2097152K available (8688K kernel code, 488K rwdata, 1644K rodata, 1316K init, 377K bss, 40692K reserved, 0K cma-reserved, 1441792K highmem)
[...]

For testing I used the kernel .config from 5.15.32 for 5.16.18 via make oldconfig and selecting =n for all questions.
Comment 1 Erhard F. 2022-03-30 22:54:42 UTC
Created attachment 300665 [details]
dmesg (5.15.32, PowerMac G4 DP)
Comment 2 Erhard F. 2022-03-30 22:55:17 UTC
Created attachment 300666 [details]
kernel .config (5.16.18, PowerMac G4 DP)
Comment 3 Erhard F. 2022-03-30 22:55:46 UTC
Created attachment 300667 [details]
kernel .config (5.15.32, PowerMac G4 DP)
Comment 4 Christophe Leroy 2022-03-31 06:21:35 UTC
This problem was introduced in 5.15 by commit 602946ec2f90 ("powerpc: Set max_mapnr correctly")

A similar issue has been opened at https://github.com/linuxppc/issues/issues/399

Following series should fix it: https://patchwork.ozlabs.org/project/linuxppc-dev/list/?state=*&series=286464
Comment 5 Erhard F. 2022-04-18 10:49:43 UTC
Created attachment 300769 [details]
dmesg (5.18-rc3, PowerMac G4 DP)

Meanwhile the fixes landed in 5.16.x, 5.17.x and 5.18-rc3 is also ok. Thanks!