hw.physmem tunable allows to limit number of physical memory available
to the system. It's handled in machdep files for x86 and PowerPC. This patch
adds required logic to the consolidated physmem management interface
that is used by ARM, ARM64, and RISC-V.
Details
Tested on ARM64 platforms, both FDT and ACPI
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Looks good to me overall.
I tested a couple sizes on RISC-V and it seems to work fine. With hw.physmem=512M, boot -v gives:
real memory = 2147483648 (2048 MB) Physical memory chunk(s): 0x0000000080a62000 - 0x000000009fb41fff, 521011200 bytes (127200 pages) avail memory = 517816320 (493 MB)
It might be worth adding an explicit message like is done on amd64:
if (atop(physmap[physmap_idx + 1]) != Maxmem && (boothowto & RB_VERBOSE)) printf("Physical memory use set to %ldK\n", Maxmem * 4);
sys/kern/subr_physmem.c | ||
---|---|---|
247 ↗ | (On Diff #79354) | If I'm reading this right, you might simply break at this point. The condition will continue to be true on future iterations of the loop. |
400 ↗ | (On Diff #79354) | This should be a u_long. |
sys/kern/subr_physmem.c | ||
---|---|---|
247 ↗ | (On Diff #79354) | Correct. Fixed in the new revision |
.. skipped ...
It might be worth adding an explicit message like is done on amd64:
if (atop(physmap[physmap_idx + 1]) != Maxmem && (boothowto & RB_VERBOSE)) printf("Physical memory use set to %ldK\n", Maxmem * 4);
This is not easily addressable. When the physmem_init_kernel_globals is called console is not ready yet, so print is not visible to the user. So it needs to be addressed somewhere else.
One minor note, otherwise looks good to me.
Understood. It could be added in initarm() perhaps, but it's not a blocker for this patch.
sys/kern/subr_physmem.c | ||
---|---|---|
147 ↗ | (On Diff #80048) | Please update the comment to explain the purpose of maxphyssz. |
sys/kern/subr_physmem.c | ||
---|---|---|
147 ↗ | (On Diff #80048) | Added and committed, thanks |