Page MenuHomeFreeBSD

Add sysctl(8) formatting for hw.pagesizes.
ClosedPublic

Authored by markj on Aug 30 2020, 5:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 27, 7:26 PM
Unknown Object (File)
Sat, Nov 22, 5:48 PM
Unknown Object (File)
Mon, Nov 17, 3:57 PM
Unknown Object (File)
Oct 24 2025, 12:04 AM
Unknown Object (File)
Oct 24 2025, 12:03 AM
Unknown Object (File)
Oct 24 2025, 12:03 AM
Unknown Object (File)
Oct 23 2025, 3:30 PM
Unknown Object (File)
Oct 19 2025, 10:27 AM
Subscribers

Details

Summary


- Change the type of hw.pagesizes to OPAQUE, since it returns an array.
- Modify the handler to only truncate the returned length if the caller
supplied an output buffer. This allows use of the trick of passing a
NULL output buffer to fetch the output size, while preserving
compatibility if MAXPAGESIZES is increased.
- Add a "S,pagesize" formatter to sysctl(8).

Test Plan

Example output:

hw.pagesizes: { 4096, 2097152, 1073741824 }

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 33239
Build 30578: arc lint + arc unit

Event Timeline

markj requested review of this revision.Aug 30 2020, 5:44 PM
markj created this revision.
kib added inline comments.
sys/kern/kern_mib.c
246

I think we should truncate len by removing all indexes for which pagesizes32[i] are zero (not a problem right now).

This revision is now accepted and ready to land.Aug 30 2020, 6:41 PM
sys/kern/kern_mib.c
246

You mean, zero due to integer truncation? Does LA57 permit 512G superpages?

sys/kern/kern_mib.c
246

I mean the comment above, about (uint32_t)pagesizes[i] calculation.

Right now LA57 only defines PG_PS at PD and PDP level still, i.e. no 512G superpages still. But would it allowed (and I do not think it is too far in the future), we get into this situation for i386 on amd64.

markj added inline comments.
sys/kern/kern_mib.c
246

Shouldn't we do that for the native case as well? For instance, with 1G pages some amd64 systems will still have only 4K and 2M in the page sizes array.

sys/kern/kern_mib.c
246

It could be reasonable but not critical. amd64 native binaries should be prepared for 3 page sizes. While i386 expect only two.

This revision was automatically updated to reflect the committed changes.
markj marked an inline comment as done.