Re: Proposed new sysctl MIB nodes

Jason R Thorpe <thorpej-DZEk9q7Sfju/3pe1ocb+swC/[email protected]> Wed, 26 Feb 2003 17:37:41 -0800
Newsgroups gmane.os.bsd.api.general
Organization Wasabi Systems, Inc.
Message-ID <[email protected]>
--7JfCtLOvnd9MIVvH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Mon, Feb 24, 2003 at 07:21:44PM -0500, Perry E. Metzger wrote:

 > > I'd like to propose new HW_PHYSPAGES and HW_USERPAGES MIB nodes that
 > > return the same information, but in a 32-bit page count, instead.  The
 > > implementation is left as an exercise to the reader.  I just want to get
 > > consensus on the names, so that I can tell the GCC people about it, and
 > > have it work on all the BSD platforms (as their current sysctl code does).
 > 
 > How about simply having a total memory count in quads instead? That
 > way we won't run out when we pass 2^48 or 49th bytes in 10 or 15
 > years.

OK, since there hasn't been any further discussion about this, I'll take
this to mean that we're all in agreement.  Here is the patch I'm checking
into NetBSD.  I will check a patch into GCC to use it in a few days.

-- 
        -- Jason R. Thorpe <thorpej-DZEk9q7Sfju/3pe1ocb+swC/[email protected]>

--7JfCtLOvnd9MIVvH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=hw-physpages-patch

Index: kern/kern_sysctl.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.126
diff -c -r1.126 kern_sysctl.c
*** kern/kern_sysctl.c	2003/02/15 18:47:41	1.126
--- kern/kern_sysctl.c	2003/02/27 01:33:48
***************
*** 693,701 ****
--- 693,706 ----
  		return (sysctl_rdint(oldp, oldlenp, newp, BYTE_ORDER));
  	case HW_PHYSMEM:
  		return (sysctl_rdint(oldp, oldlenp, newp, ctob(physmem)));
+ 	case HW_PHYSPAGES:
+ 		return (sysctl_rdquad(oldp, oldlenp, newp, physmem));
  	case HW_USERMEM:
  		return (sysctl_rdint(oldp, oldlenp, newp,
  		    ctob(physmem - uvmexp.wired)));
+ 	case HW_USERPAGES:
+ 		return (sysctl_rdquad(oldp, oldlenp, newp,
+ 		    physmem - uvmexp.wired));
  	case HW_PAGESIZE:
  		return (sysctl_rdint(oldp, oldlenp, newp, PAGE_SIZE));
  	case HW_ALIGNBYTES:
Index: sys/sysctl.h
===================================================================
RCS file: /cvsroot/src/sys/sys/sysctl.h,v
retrieving revision 1.90
diff -c -r1.90 sysctl.h
*** sys/sysctl.h	2003/02/10 00:35:15	1.90
--- sys/sysctl.h	2003/02/27 01:33:50
***************
*** 522,536 ****
  #define	HW_MODEL	 2		/* string: specific machine model */
  #define	HW_NCPU		 3		/* int: number of cpus */
  #define	HW_BYTEORDER	 4		/* int: machine byte order */
! #define	HW_PHYSMEM	 5		/* int: total memory */
! #define	HW_USERMEM	 6		/* int: non-kernel memory */
  #define	HW_PAGESIZE	 7		/* int: software page size */
  #define	HW_DISKNAMES	 8		/* string: disk drive names */
  #define	HW_DISKSTATS	 9		/* struct: diskstats[] */
  #define	HW_MACHINE_ARCH	10		/* string: machine architecture */
  #define	HW_ALIGNBYTES	11		/* int: ALIGNBYTES for the kernel */
  #define	HW_CNMAGIC	12		/* string: console magic sequence(s) */
! #define	HW_MAXID	13		/* number of valid hw ids */
  
  #define	CTL_HW_NAMES { \
  	{ 0, 0 }, \
--- 522,538 ----
  #define	HW_MODEL	 2		/* string: specific machine model */
  #define	HW_NCPU		 3		/* int: number of cpus */
  #define	HW_BYTEORDER	 4		/* int: machine byte order */
! #define	HW_PHYSMEM	 5		/* int: total memory (bytes) */
! #define	HW_USERMEM	 6		/* int: non-kernel memory (bytes) */
  #define	HW_PAGESIZE	 7		/* int: software page size */
  #define	HW_DISKNAMES	 8		/* string: disk drive names */
  #define	HW_DISKSTATS	 9		/* struct: diskstats[] */
  #define	HW_MACHINE_ARCH	10		/* string: machine architecture */
  #define	HW_ALIGNBYTES	11		/* int: ALIGNBYTES for the kernel */
  #define	HW_CNMAGIC	12		/* string: console magic sequence(s) */
! #define	HW_PHYSPAGES	13		/* quad: total memory (pages) */
! #define	HW_USERPAGES	14		/* quad: non-kernel memory (pages) */
! #define	HW_MAXID	15		/* number of valid hw ids */
  
  #define	CTL_HW_NAMES { \
  	{ 0, 0 }, \
***************
*** 546,551 ****
--- 548,555 ----
  	{ "machine_arch", CTLTYPE_STRING }, \
  	{ "alignbytes", CTLTYPE_INT }, \
  	{ "cnmagic", CTLTYPE_STRING }, \
+ 	{ "physpages", CTLTYPE_QUAD }, \
+ 	{ "userpages", CTLTYPE_QUAD }, \
  }
  
  /*

--7JfCtLOvnd9MIVvH--

---------------------------------------------------------------------
The BSD APIs Discussion Mailing List
To unsubscribe:
send "unsubscribe bsd-api-discuss" to majordomo-DZEk9q7Sfju/3pe1ocb+swC/[email protected]