-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPI Zero 2W incorrect memory size #5975
Comments
Here are the logs of executing the same commands on my Raspberry Pi Zero W. These are coherent with a device with ~500MB of ram with ~64MB separated for the GPU split.
|
Can you identify the exact update which caused this. See: If you click on each commit the end of the url contains a git hash. Run |
Some before and after comparisons would be useful - that looks to be all after. I note that you've opted into the 64-bit kernel (and perhaps even the 64-bit OS - it's hard to tell). This is not recommended on a Zero 2 W because it will eat into your limited RAM. |
The issue was introduced at the commit e632362b0399b4ce331aacd9386685bc60938ab7
Free before the commit (using commit af3ab905d42829d4ce860f19a0e049c3bcdbe35f):
Free after appling the commit e632362b0399b4ce331aacd9386685bc60938ab7:
|
Indeed I am running Raspberry Pi OS 64 bit version, but I do not see how it affects the topic at hand. |
Ah - so was this the kernel update rather than the firmware? You should be able to confirm this by copying You can check firmware and kernel versions after a reboot with:
|
Do you care about how much usable RAM your Z2W has? |
Note that as well as having unavoidably larger page tables, lower code density, etc., there is a common 64-bit kernel that runs on Pi 3s, 4s, 5 and Z2W. This means that your Z2W has used some of its RAM to hold support for booting a Pi 5 to the point where it can access its SD card, USB, and Ethernet interfaces. kernel7.img is only for Pi 3s and Z2W, therefore it is much smaller. Note also that the 64-bit kernels are GZIP compressed - uncompressed they are roughly 25MB. |
I have run out of time for the moment, but copying either set of files from the "bad" commit to the "good" one does not appear to solve the issue. I am missing to test the other permutation. |
Correct, that affects memory utilization, not the amount of memory available to the system, that is the issue I am suffering. |
I'd expect copying firmware from "bad" to "good" would either have no effect (i.e. it's not a firmware issue) or to make memory available worsen (i.e. it is a firmware issue). Can you confirm which result you had ("solving" wasn't an expected outcome from this test). |
The results from the improvised experiment:
After seeing the results, I do believe the issue is with the new 6.6 kernel and not with the firmware. |
start*.elf and fixup*.dat should always be of the same version, so not booting is reasonable. I've transferred this issue to the linux repo as that appears to be the cause of the increased memory. As @pelwell says, it is worth testing how much of the increased memory is due to 64-bit kernel (which now also supports pi5, which the 32-bit kernel does not). Is your OS 32-bit or 64-bit? If it's 32-bit then booting without |
Currently I'm running "Raspberry Pi OS (64-bit) : Raspberry Pi OS Lite". What tests and versions would be intriguing to execute? I am open for suggestions. |
Although I've never quite got 460M for total mem, my results are close, seeing a ~60M drop when switching to the 6.6 kernel - whether by rpi-update or building my own. Looking at the start of the /proc/iomem output with some annotations is instructive. Before:
After:
Here you can clearly see that the third The obvious next question is what that area is reserved for. The answer is "software IO TLB" - DMA bounce buffers:
This memory is used as a staging post for DMA transfers when the target memory is out of range of the DMA controller. There is no such allocation in the 6.1 kernel, which is puzzling. I'll have to dig deeper. By the way, the |
The extra 64MB usage is caused by this commit: 370645f Prior to this, the initialisation of the swiotlb buffers was smart - if all of RAM is addressable by the DMA controller(s) then no bounce buffers are required. This is certainly true on a Z2W with only 512MB, so you save the 64MB carve-out. The above commit, which appeared in Linux 6.5, says that bounce buffers may be required if DMA transfers are not cache-line-aligned, so it is better to have the bounce buffers unconditionally allocated. The DMA_BOUNCE_UNALIGNED_KMALLOC option is turned on by the arm64 Kconfig file. I don't see any way to opt-out without modifying the kernel source - as a config setting without a description it isn't one you can alter from a defconfig file. Needless to say, the 32-bit (ARCH=arm) Kconfig files don't set DMA_BOUNCE_UNALIGNED_KMALLOC - yet another reason you would be better off with a 32-bit build. |
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
This is an interesting and related read https://lwn.net/Articles/940973/#:~:text=The%20kernel's%20software%20I%2FO,as%20newer%20peripherals%20came%20along. |
Given that 6.1 was quite happy without this option being defined, we opted to not enable it on 6.6 - see 3e0065d. This change will be in future releases, but if you wait about 40 minutes (until around 15:10GMT) you should be able to install an early build of this beta kernel by running For the record, this is the same RAM usage information taken from 6.6 with the patch applied (and without my oversized kernel log buffer):
|
The patch series described there is in our 6.6 kernel (it wasn't in 6.5 and prior ones). |
Seeing that this is not the only project with this issue, maybe the functionality could be kept with a smaller fix just be setting the kernel boot parameter of "swiotlb=0" as they did in the Yocto project for qemu images. |
That's not a bad solution, but this works for us for now. |
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
See: raspberrypi/linux#5974 kernel: brcmfmac: Fix 802.1x See: raspberrypi/linux#5973 kernel: Add IQaudio CodecZero to hat_map.dts See: raspberrypi/linux#5972 kernel: arm64/Kconfig: Don't set DMA_BOUNCE_UNALIGNED_KMALLOC See: raspberrypi/linux#5975
See: raspberrypi/linux#5974 kernel: brcmfmac: Fix 802.1x See: raspberrypi/linux#5973 kernel: Add IQaudio CodecZero to hat_map.dts See: raspberrypi/linux#5972 kernel: arm64/Kconfig: Don't set DMA_BOUNCE_UNALIGNED_KMALLOC See: raspberrypi/linux#5975
Can confirm the fix is working.
Thank you everyone for the support. |
Thank you - without your observation all Z2W owners would be missing 12.5% of their RAM for no reason. |
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems where the DMA controller can reach all of RAM. This is a huge amount of RAM to waste on a device with only 512MB to start with, such as the Zero 2 W. See: #5975 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Describe the bug
After doing an rpi-update on my raspberry pi zero 2W, the available ram reduced from ~484MB to 400MB. I do understand that the memory split will take an amount of ram (check logs section). I do not understand the reason of the change, but having less resources available in such a constrained board is not beneficial.
To reproduce
Executing the command sudo rpi-update.
Expected behaviour
Available ram for the system to be at around ~484MB.
Actual behaviour
Available ram for the system is found to be at around ~400MB.
System
Logs
Reduced to only provide relevant information.
Additional context
I do not know if they are relevant, but I have attached the boot configurations just in case I have enabled a device that also is reserving ram at boot.
Thank you.
The text was updated successfully, but these errors were encountered: