From 1da0c46175859f8df020a3ca265cd83330a88bcf Mon Sep 17 00:00:00 2001 From: rpokala Date: Wed, 3 Apr 2019 03:30:57 +0000 Subject: [PATCH] MFC r345457: Add descriptions for sysctls in kern_mib.c and sysctl.3 which lack them. r343532 noted the difference between "hw.realmem" and "hw.physmem", which I was previously unaware of. I discovered that neither sysctl had a description visible via `sysctl -d', so I found where they were defined and added suitable descriptions. While in the file, I went ahead and added descriptions for all the others which lacked them. I also updated sysctl.3 accordingly. --- lib/libc/gen/sysctl.3 | 16 ++++++++++++---- sys/kern/kern_mib.c | 12 ++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3 index a5c178064bd..513ab1bfbd5 100644 --- a/lib/libc/gen/sysctl.3 +++ b/lib/libc/gen/sysctl.3 @@ -28,7 +28,7 @@ .\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd October 22, 2017 +.Dd March 22, 2019 .Dt SYSCTL 3 .Os .Sh NAME @@ -284,6 +284,7 @@ privilege may change the value. .It Dv HW_FLOATINGPT Ta integer Ta no .It Dv HW_MACHINE_ARCH Ta string Ta no .It Dv HW_REALMEM Ta integer Ta no +.It Dv HW_AVAILPAGES Ta integer Ta no .El .Bl -tag -width 6n .It Li HW_MACHINE @@ -295,9 +296,10 @@ The number of cpus. .It Li HW_BYTEORDER The byteorder (4321 or 1234). .It Li HW_PHYSMEM -The bytes of physical memory. +Amount of physical memory (in bytes), minus the amount used by the kernel, +pre-loaded modules, and (on x86) the dcons buffer. .It Li HW_USERMEM -The bytes of non-kernel memory. +Amount of memory (in bytes) which is not wired. .It Li HW_PAGESIZE The software page size. .\".It Fa HW_DISKNAMES @@ -307,7 +309,13 @@ Nonzero if the floating point support is in hardware. .It Li HW_MACHINE_ARCH The machine dependent architecture type. .It Li HW_REALMEM -The bytes of real memory. +Amount of memory (in bytes) reported by the firmware. +That value is sometimes not sane; in that case, the kernel reports the max +memory address instead. +.It Li HW_AVAILPAGES +The same value as +.Li HW_PHYSMEM , +measured in pages rather than bytes. .El .Ss CTL_KERN The string and integer information available for the CTL_KERN level diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c index 729b4cad3c4..a6104ebfd64 100644 --- a/sys/kern/kern_mib.c +++ b/sys/kern/kern_mib.c @@ -183,7 +183,8 @@ sysctl_hw_physmem(SYSCTL_HANDLER_ARGS) return (sysctl_handle_long(oidp, &val, 0, req)); } SYSCTL_PROC(_hw, HW_PHYSMEM, physmem, CTLTYPE_ULONG | CTLFLAG_RD, - 0, 0, sysctl_hw_physmem, "LU", ""); + 0, 0, sysctl_hw_physmem, "LU", + "Amount of physical memory (in bytes)"); static int sysctl_hw_realmem(SYSCTL_HANDLER_ARGS) @@ -197,7 +198,8 @@ sysctl_hw_realmem(SYSCTL_HANDLER_ARGS) return (sysctl_handle_long(oidp, &val, 0, req)); } SYSCTL_PROC(_hw, HW_REALMEM, realmem, CTLTYPE_ULONG | CTLFLAG_RD, - 0, 0, sysctl_hw_realmem, "LU", ""); + 0, 0, sysctl_hw_realmem, "LU", + "Amount of memory (in bytes) reported by the firmware"); static int sysctl_hw_usermem(SYSCTL_HANDLER_ARGS) @@ -212,9 +214,11 @@ sysctl_hw_usermem(SYSCTL_HANDLER_ARGS) return (sysctl_handle_long(oidp, &val, 0, req)); } SYSCTL_PROC(_hw, HW_USERMEM, usermem, CTLTYPE_ULONG | CTLFLAG_RD, - 0, 0, sysctl_hw_usermem, "LU", ""); + 0, 0, sysctl_hw_usermem, "LU", + "Amount of memory (in bytes) which is not wired"); -SYSCTL_LONG(_hw, OID_AUTO, availpages, CTLFLAG_RD, &physmem, 0, ""); +SYSCTL_LONG(_hw, OID_AUTO, availpages, CTLFLAG_RD, &physmem, 0, + "Amount of physical memory (in pages)"); u_long pagesizes[MAXPAGESIZES] = { PAGE_SIZE }; -- 2.45.0