First 2 posts from the Raspberry Pi 4 on sale now from $35 blog post
Rob Stoddard says: 24th Jun 2019 at 7:18 am
Link: https://www.raspberrypi.org/blog/raspbe ... nt-1509934Is that software 64 bit? All that you wrote about the software I honestly don’t care about, all I want to know is, is that software 64 bit?
David Ferguson says: 24th Jun 2019 at 7:28 am
Kexec_file_load(2), or kexec_load(2) and reboot(2)No for mainly the same reason as before: the OS standard Raspbian image needs to be backwards compatible with the older Pi versions, and therefore isn’t 64 bit.
So no 64-bit kernel, because of backwards compability with older Pi models, but ...
... there are the kexec_load and reboot system calls.
reboot(2) does what your think it does, but you probably don't know what the kexec_file_load(2), and the kexec_load(2) system calls does:
Here is their man page
kexec_load, kexec_file_load - load a new kernel for later execution
kexec_file_load, and kexec_load are potential security risks, so I would propose to use an initial 32-bit kernel, which is stripped down to have only what it needs to have - meaning that it don't support network, and the only supported filesystems could be initramfs, and FAT32 for the boot partition.
Boot process with the kexec_file_load, and reboot syscalls
- The Pi boots like it usually do, but the kernel is an initial 32-bit kernel
- The root filesystem for the initial kernel is a initramfs filesystem image that are loaded from a file on the boot (FAT32) partition
- The initial kernel starts the init (PID 1) process from the initramfs filesystem.
- A program (process) needs to detect whether or not the microprocessor is a 64-bit CPU.
- Another tool figures out which kernel images are available on the boot partition. It can also read configuration files too, fx one which file name (not its content) means that the initial 32-bit kernel will always boot into a 32-bit kernel, Fx the name could be BOOT-32-BIT_KERNEL - you probably has a better name. The content of such a file could be the kernel image one would like to use.
- A process calls kexec(8), which is a CLI tool that can directly boot into a new kernel
- If kexec successfully booted into the loaded kernel : That 32-bit or 64-bit kernel will then start as if was started like the way it is done today.
Introduction to virtual memory
Programs run in virtual memory - not directly on physical memory.
Virtual memory is made up of
- Physical RAM
- Named swap (mmap'ed files), which has a higher priority than anonymous swap.
The Python interpreter mmap's *.py source code files
- zram - compressed swap in physical RAM
Don't use zram if you use zswap
- zswap, which is like zram, but backed by a swap partition
If you use, let us say 1 GB of physical RAM for (z)swap, you will get approx about 2,2 times more swap, i.e., ~2,2 GB super fast swap instead of just 1 GB of swap.
Extra bonus: If your Pi don't use the amount of physical RAM reserved for zswap , then the physical RAM is used for something else, fx a disk buffer.
Don't use zswap if you use zram
- Anonymouns swap, which is:
- swap files, and ...
- swap partittions
Example of using a lot of virtual memory
The Chrome browser is know for notoriously using a lot of virtual memory.
If we let a Raspberry Pi 4B make use of a 64-bit kernel, that kernel can have, let's say 4 GB physical memory, and a 12 GB swap partition on a SSD disk.
The amount of available useful virtual memory is then 16 GB!
The Chrome browser can then use 8 GB of virtual memory. Most of it is paged out to zram, zswap, swap file(s), or swap partition(s).
If you want to watch a tab that has been completely paged out (isn't in physucal RAM). Let's say that tab (webpage) uses 25 GB of virtual memeory, then teh folllowing will happen:
25 MB pages are maybe, hint vm.swappiness, paged out, then the 25 MB of pages are swapped in into physical memory.
With a SSD reading at 500 MB/s - and connected to a Raspberry Pi via USB 3.0 - the 25 MB paged out, followed by a 25 MB paged in - it takes 0.1 second, which is acceptable.
If userland programs are both in 32-bit and 64-bit the downloaded image would be about twice the zsize of the current one, so a capability to run 32-bit software would be a good idea.