Page MenuHomeFreeBSD

Add support for hw.physmem tunable for ARM/ARM64/RISC-V platforms
ClosedPublic

Authored by gonzo on Nov 9 2020, 7:02 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 3, 10:18 AM
Unknown Object (File)
Oct 3 2024, 10:18 AM
Unknown Object (File)
Oct 1 2024, 3:55 PM
Unknown Object (File)
Sep 25 2024, 11:33 AM
Unknown Object (File)
Sep 18 2024, 9:33 AM
Unknown Object (File)
Sep 9 2024, 3:37 PM
Unknown Object (File)
Sep 1 2024, 12:19 PM
Unknown Object (File)
Aug 25 2024, 10:53 AM
Subscribers

Details

Summary

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.

Test Plan

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

gonzo requested review of this revision.Nov 9 2020, 7:02 PM

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.

Address commends from mhorne@

gonzo added inline comments.
sys/kern/subr_physmem.c
247 ↗(On Diff #79354)

Correct. Fixed in the new revision

Looks good to me overall.

.. 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.

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.

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.

This revision is now accepted and ready to land.Dec 2 2020, 2:54 PM
This revision was automatically updated to reflect the committed changes.
gonzo marked an inline comment as done.
sys/kern/subr_physmem.c
147 ↗(On Diff #80048)

Added and committed, thanks