Page MenuHomeFreeBSD

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

Authored by markj on Aug 30 2020, 5:44 PM.
Tags
None
Referenced Files
F142011987: D26239.id76556.diff
Wed, Jan 14, 9:57 PM
Unknown Object (File)
Sat, Dec 20, 6:02 PM
Unknown Object (File)
Nov 27 2025, 7:26 PM
Unknown Object (File)
Nov 22 2025, 5:48 PM
Unknown Object (File)
Nov 17 2025, 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
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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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 ↗(On Diff #76374)

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 ↗(On Diff #76374)

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

sys/kern/kern_mib.c
246 ↗(On Diff #76374)

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 ↗(On Diff #76374)

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 ↗(On Diff #76374)

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.