foundObjects / zram-swap

A simple zram swap service for modern systemd Linux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problems with 8gb RPi 4

ScallyBag opened this issue · comments

Hi,

Your script runs perfectly on a Raspberry Pi 4 with 4gb of ram, but doesn’t show correctly with the new 8gb version. (I’m running the beta boot from SSD which your script run alongside with no problems with the 4gb RPi 4)

Here’s 3 commands:

Al@MAME:~ $ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 223.6G  0 disk 
├─sda1   8:1    0   256M  0 part /boot
└─sda2   8:2    0 223.3G  0 part /
zram0  254:0    0   9.7G  0 disk

Al@MAME:~ $ sudo cat /proc/swaps
Filename                                Type            Size    Used    Priority
Al@MAME:~ $

Al@MAME:~ $ free -h
              total        used        free      shared  buff/cache   available
Mem:          7.7Gi       798Mi       5.6Gi       8.0Mi       1.3Gi       6.7Gi
Swap:            0B          0B          0B

In the 4gb version your zram shows in the sudo cat /proc/swaps & the free -h commands.
I deliberately set my swapsize to zero to avoid confusion.

Any ideas?

Thanks,

Alan Cooper.

Follow the debugging instructions from the README -- as root (or with sudo) start the script with the -x flag: zram-swap.sh -x start and look for the failure.

Hi,
Thanks for your answer:

Here’s the output from your command:

Al@RPi4-SSD:~/RPi4/zram-swap $ sudo ./zram-swap.sh -x start
+ _zram_fraction=1/2
+ _zram_algorithm=lz4
+ _comp_factor=
+ _zram_fixedsize=
+ [ -f /etc/default/zram-swap ]
+ . /etc/default/zram-swap
+ _zram_fraction=1/2
+ _zram_algorithm=lz4
+ [ -z  ]
+ _comp_factor=2.5
+ _main start
+ modprobe zram
+ grep -q zram /proc/swaps
+ _init
+ [ -n  ]
+ LC_ALL=C free+ 
grep -e ^Mem:
+ sed -e s/^Mem: *// -e s/  *.*//
+ totalmem=8115540
+ calc 8115540 * 2.5 * 1/2 * 1024
+ n=0
+ awk BEGIN{printf "%.0f", 8115540 * 2.5 * 1/2 * 1024}
+ mem=10387891200
+ _device=
+ seq 3
+ calc 2 0.1 * 1
+ n=2
+ shift
+ awk BEGIN{printf "%.2f", 0.1 * 1}
+ sleep 0.10
+ zramctl -f -s 10387891200 -a lz4
+ _device=/dev/zram1
+ [ -b /dev/zram1 ]
+ break
+ [ -b /dev/zram1 ]
+ trap _rem_zdev /dev/zram1 EXIT
+ mkswap /dev/zram1
Setting up swapspace version 1, size = 9.7 GiB (10387890176 bytes)
no label, UUID=24b54dfc-38c9-4362-8496-ea766bd0296f

Message from syslogd@RPi4-SSD at Jun 15 09:45:48 ...
 kernel:[ 2564.820045] Internal error: Oops: 207 [#2] SMP ARM

Message from syslogd@RPi4-SSD at Jun 15 09:45:48 ...
 kernel:[ 2564.820456] Process mkswap (pid: 1530, stack limit = 0xa032c19e)

Message from syslogd@RPi4-SSD at Jun 15 09:45:48 ...
 kernel:[ 2564.820472] Stack: (0xcf9dfaa8 to 0xcf9e0000)

-snip-

Thanks,

Al.

It looks like there's something wrong with that kernel; Calling mkswap is causing a kernel oops and crashing while attempting to create the swap device. Unfortunately there's nothing I can do about this, something is going wrong in kernel code here. I'd report this to whoever's responsible for that kernel and give them a reproduction case so they can investigate.

If you can reproduce this on other kernels let me know, maybe something I'm doing is highlighting a failure case that needs to be reported upstream.

I thought of one thing you could try -- it might be that the zram device is created but isn't actually ready when the script tries to call mkswap.

Try adding a line before line 89 of zram-swap.sh that just does a sleep 5 and see what happens. If that fixes things for you try walking that value down from 5 to 4, 3, 2, 1, 0.5, etc. I'll add a delay statement to the script if that solves your issue. Either edit the installed script in /usr/local/sbin or edit the copy in the cloned git repo and re-run the installer.

Let me know if that works.

Hi,

It doesn’t appear to have helped:

Al@RPi4-SSD:~/RPi4/zram-swap $ sudo zram-swap.sh -x start
+ _zram_fraction=1/2
+ _zram_algorithm=lz4
+ _comp_factor=
+ _zram_fixedsize=
+ [ -f /etc/default/zram-swap ]
+ . /etc/default/zram-swap
+ _zram_fraction=1/2
+ _zram_algorithm=lz4
+ [ -z  ]
+ _comp_factor=2.5
+ _main start
+ modprobe zram
+ grep -q zram /proc/swaps
+ _init
+ [ -n  ]
+ LC_ALL=C free
+ grep -e+ sed -e ^Mem: s/^Mem: *// -e
 s/  *.*//
+ totalmem=8115540
+ calc 8115540 * 2.5 * 1/2 * 1024
+ n=0
+ awk BEGIN{printf "%.0f", 8115540 * 2.5 * 1/2 * 1024}
+ mem=10387891200
+ _device=
+ seq 3
+ calc 2 0.1 * 1
+ n=2
+ shift
+ awk BEGIN{printf "%.2f", 0.1 * 1}
+ sleep 0.10
+ zramctl -f -s 10387891200 -a lz4
+ _device=/dev/zram2
+ [ -b /dev/zram2 ]
+ break
+ [ -b /dev/zram2 ]
+ trap _rem_zdev /dev/zram2 EXIT
+ mkswap /dev/zram2
Setting up swapspace version 1, size = 9.7 GiB (10387890176 bytes)
no label, UUID=666e03fc-e857-489e-8226-e270f6895fd8

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605168] Internal error: Oops: 207 [#3] SMP ARM

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605661] Process mkswap (pid: 1140, stack limit = 0x5c493af1)

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605681] Stack: (0xd1a9baa8 to 0xd1a9c000)

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605701] baa0:                   d39bcb20 d182f008 d1a9bb18 de5af450 d1a9badc d1a9bac8

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605727] bac0: c0621734 67a6ac41 d1a9bb18 00000000 c1204f88 d182f008 d1ed3800 d1877800

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605753] bae0: bf08f400 d1869000 d1a9bb4c d1a9baf8 bf08c998 bf07f05c c02a63ac c08a17cc

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605779] bb00: 00000001 ef218b00 ffffd1bf d8f493b0 00000000 c1204f88 00000040 67a6ac41

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605805] bb20: 00000008 d1f09600 d1877800 00001000 00000000 00000000 00001000 00001000

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605830] bb40: d1a9bbac d1a9bb50 bf08d184 bf08c660 00000001 d1f09600 c020bc48 bf08f198

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605856] bb60: 00000000 00000000 00000000 c1204f88 d8f493b0 00001000 00000000 67a6ac41

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605881] bb80: c020bbec c1204f88 d1f09600 d1a9bbb4 ef218b00 00000000 ffffffff d8f493b0

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605906] bba0: d1a9bbec d1a9bbb0 c0640a54 bf08cfdc c037d524 00000000 00000000 00000000

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605932] bbc0: 00000000 67a6ac41 c1204f88 d1f09600 00000008 00000800 d1a9be60 00000000

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605958] bbe0: d1a9bc5c d1a9bbf0 c0640c8c c0640960 c13595e4 c0637e7c 00000000 c1204f88

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.605983] bc00: d1f09600 00001000 d8f493b0 00000000 00000000 d8f493b0 d1a9bc5c d1a9bc28

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606009] bc20: c0637e7c c0637cd0 d1a9bc33 67a6ac41 d1a9bc5c d3634b80 d1f09600 00000801

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606034] bc40: 00000800 d1a9be60 00000000 d8f493b0 d1a9bc84 d1a9bc60 c043f11c c0640c44

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606060] bc60: 00000001 d3634b80 d3634b80 00000800 ef414bc8 d1a9be60 d1a9bcec d1a9bc88

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606085] bc80: c043f404 c043ef94 d1a9be60 d8f493b0 d1a9bcd4 c04439c8 00001000 c1204f88

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606111] bca0: c043d748 d1a9be60 00000800 ef414bc8 0026b2aa 00000000 c03828ec 67a6ac41

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606136] bcc0: 20000013 ef414bc8 00000000 d8f493b0 d1a9be60 c04439c8 d1a9be60 00000000

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606162] bce0: d1a9bd24 d1a9bcf0 c043f904 c043f158 c043d748 d1a9bd00 ffffffff ef414cd0

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606188] bd00: 00000000 d1a9bd90 ef414cd0 00000001 d1a9be60 00000000 d1a9bd34 d1a9bd28

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606213] bd20: c0442cb8 c043f820 d1a9bd4c d1a9bd38 c038159c c0442ca0 d8f493b0 00000000

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606239] bd40: d1a9bdfc d1a9bd50 c0382c04 c0381584 00000002 c0c0db08 00000001 c1204f88

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606264] bd60: c043e364 c043ce9c 00000000 c12a4a10 c1204fb4 ef414cd0 c0381578 00000002

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606289] bd80: d1a9a010 ffffffff ffffffff c0440001 d8f493b0 d1a9bec0 ef414cd0 00000c00

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606315] bda0: d1a9be14 d1a9bdb0 c0376820 c0383fe0 00000c00 00000c00 d8f493b0 21b95785

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606340] bdc0: c1204f88 d1a9a030 00000c00 67a6ac41 00001000 ef414cd0 c1204f88 d1a9be60

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606366] bde0: 7fffffff 00000000 00000000 00000001 d1a9be34 d1a9be00 c0382ea4 c03829c8

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606391] be00: d1a9be00 d1a9be00 d1a9be08 d1a9be08 c0000000 67a6ac41 d1a9be14 d1a9be60

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606417] be20: ef414cd0 ef414bc8 d1a9be44 d1a9be38 c0442c68 c0382e4c d1a9be5c d1a9be48

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606442] be40: c0384ed8 c0442c5c ef414cd0 c1204f88 d1a9bed4 d1a9be60 c037ad78 c0384eb4

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606468] be60: 7fffffff 00000000 00000000 00000000 ffffffff 7fffffff 00000001 00000000

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606493] be80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606518] bea0: d1a9bf2c 67a6ac41 c03f8360 ffffffff ef414cd0 d1e8b840 00000000 00000000

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606544] bec0: 00000000 00000076 d1a9bf0c d1a9bed8 c037c20c c037ac94 ffffffff 7fffffff

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606569] bee0: 00000001 00000000 00000000 ffffffff 7fffffff ef414bc8 c02011c4 d1a9a000

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606595] bf00: d1a9bf34 d1a9bf10 c0442674 c037c1b8 ffffffff 7fffffff d1a9a000 d1e8b840

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606620] bf20: 00000000 00000000 d1a9bf64 d1a9bf38 c0436be4 c0442654 ffffffff 7fffffff

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606646] bf40: 00000000 c041cc50 d1e8b840 d1e8b840 00000000 00000076 d1a9bf94 d1a9bf68

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606671] bf60: c0436c9c c0436b88 ffffffff 7fffffff 00000000 00000c00 b6fdd598 00000000

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606697] bf80: 00000003 00000000 d1a9bfa4 d1a9bf98 c0436fa8 c0436c5c 00000000 d1a9bfa8

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606722] bfa0: c0201000 c0436f98 00000000 00000003 00000003 b6ef5808 0000006c 00000000

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606747] bfc0: 00000000 00000003 00000000 00000076 00000000 00000000 00000000 00033c98

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.606773] bfe0: 00033dd0 bef58198 00012cf0 b6e7b8a4 60000010 00000003 00000000 00000000

Message from syslogd@RPi4-SSD at Jun 16 16:52:12 ...
 kernel:[  181.608044] Code: e0844084 e1a04204 e0883004 e5939018 (e5991000) 
^Z
[1]+  Stopped                 sudo zram-swap.sh -x start

Al.

Unfortunately as far as I can tell this is outside of my control; there's something going wrong in that kernel that I've never seen before. I'd make a bug report to the RPi kernel maintainer about it and see what they can do to help. If they can help you narrow down a workaround for something I'm doing I'd be happy to add it but without the same hardware and OS here I have no way to reproduce this.

commented

It works on the 64bit Kernel

hostnamectl | grep Kernel
            Kernel: Linux 5.4.51-v8+
lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0     179:0    0  7.5G  0 disk 
├─mmcblk0p1 179:1    0  256M  0 part /boot
└─mmcblk0p2 179:2    0  7.2G  0 part /
zram0       254:0    0  600M  0 disk [SWAP]
zram1       254:1    0  500M  0 disk /opt/zram/zram1
zram2       254:2    0  500M  0 disk /opt/zram/zram2
sudo cat /proc/swaps
Filename                                Type            Size    Used    Priority
/var/swap                               file            102396  0       -2
/dev/zram0                              partition       614396  0       75
free -h
              total        used        free      shared  buff/cache   available
Mem:          7.7Gi       673Mi       6.3Gi       2.0Mi       782Mi       6.9Gi
Swap:         699Mi          0B       699Mi
zramctl
NAME       ALGORITHM DISKSIZE  DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram2 lzo-rle       500M 16.4M  7.1K   76K       4 /opt/zram/zram2
/dev/zram1 lzo-rle       500M 26.7M  613K    1M       4 /opt/zram/zram1
/dev/zram0 lzo-rle       600M    4K   87B   12K       4 [SWAP]