Based on the feedback on wasabisystems.com!bsd-api-discuss (sure wish

people would read that list in a more timely fashion!), change the new
64-bit memory reporting sysctl nodes to report bytes.  This should not
be a problem, since it's only a week old, and no applications use the
new nodes yet.
This commit is contained in:
thorpej 2003-03-06 20:32:59 +00:00
parent feeb962699
commit 9e7bb2595e
2 changed files with 31 additions and 15 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_sysctl.c,v 1.130 2003/03/05 11:46:49 dsl Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.131 2003/03/06 20:33:00 thorpej Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.130 2003/03/05 11:46:49 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.131 2003/03/06 20:33:00 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_insecure.h"
@ -692,15 +692,31 @@ hw_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
case HW_BYTEORDER:
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:
{
u_int rval;
if ((u_int)physmem > (UINT_MAX / PAGE_SIZE))
rval = UINT_MAX;
else
rval = physmem * PAGE_SIZE;
return (sysctl_rdint(oldp, oldlenp, newp, rval));
}
case HW_PHYSMEM64:
return (sysctl_rdquad(oldp, oldlenp, newp,
physmem - uvmexp.wired));
(u_quad_t)physmem * PAGE_SIZE));
case HW_USERMEM:
{
u_int rval;
if ((u_int)(physmem - uvmexp.wired) > (UINT_MAX / PAGE_SIZE))
rval = UINT_MAX;
else
rval = (physmem - uvmexp.wired) * PAGE_SIZE;
return (sysctl_rdint(oldp, oldlenp, newp, rval));
}
case HW_USERMEM64:
return (sysctl_rdquad(oldp, oldlenp, newp,
(u_quad_t)(physmem - uvmexp.wired) * PAGE_SIZE));
case HW_PAGESIZE:
return (sysctl_rdint(oldp, oldlenp, newp, PAGE_SIZE));
case HW_ALIGNBYTES:

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysctl.h,v 1.92 2003/03/01 05:41:55 atatat Exp $ */
/* $NetBSD: sysctl.h,v 1.93 2003/03/06 20:32:59 thorpej Exp $ */
/*
* Copyright (c) 1989, 1993
@ -532,8 +532,8 @@ struct kinfo_lwp {
#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_PHYSMEM64 13 /* quad: total memory (bytes) */
#define HW_USERMEM64 14 /* quad: non-kernel memory (bytes) */
#define HW_MAXID 15 /* number of valid hw ids */
#define CTL_HW_NAMES { \
@ -550,8 +550,8 @@ struct kinfo_lwp {
{ "machine_arch", CTLTYPE_STRING }, \
{ "alignbytes", CTLTYPE_INT }, \
{ "cnmagic", CTLTYPE_STRING }, \
{ "physpages", CTLTYPE_QUAD }, \
{ "userpages", CTLTYPE_QUAD }, \
{ "physmem64", CTLTYPE_QUAD }, \
{ "usermem64", CTLTYPE_QUAD }, \
}
/*