1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-05 09:14:03 +00:00

Introduce machine-dependent macro pgtok() to convert page count to number

of kilobytes. Its definition for each architecture could be optimized to
avoid potential numerical overflows.
This commit is contained in:
Luoqi Chen 1999-02-19 19:34:49 +00:00
parent fe2144fd5a
commit 1c6d46f93c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=44157
12 changed files with 52 additions and 49 deletions

View File

@ -1,4 +1,4 @@
/* $Id: param.h,v 1.6 1998/07/30 08:12:14 dfr Exp $ */
/* $Id: param.h,v 1.7 1998/09/09 01:21:25 jdp Exp $ */
/* From: NetBSD: param.h,v 1.20 1997/09/19 13:52:53 leo Exp */
/*
@ -167,6 +167,8 @@
#define alpha_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)
#define alpha_ptob(x) ((unsigned long)(x) << PAGE_SHIFT)
#define pgtok(x) ((x) * (PAGE_SIZE / 1024))
#ifdef _KERNEL
#ifndef _LOCORE

View File

@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: mp_machdep.c,v 1.89 1999/01/28 01:59:50 dillon Exp $
* $Id: mp_machdep.c,v 1.90 1999/02/19 14:25:32 luoqi Exp $
*/
#include "opt_smp.h"
@ -2387,10 +2387,10 @@ forwarded_statclock(int id, int pscnt, int *astmap)
if ((pstats = p->p_stats) != NULL &&
(ru = &pstats->p_ru) != NULL &&
(vm = p->p_vmspace) != NULL) {
ru->ru_ixrss += vm->vm_tsize * PAGE_SIZE / 1024;
ru->ru_idrss += vm->vm_dsize * PAGE_SIZE / 1024;
ru->ru_isrss += vm->vm_ssize * PAGE_SIZE / 1024;
rss = vmspace_resident_count(vm) * PAGE_SIZE / 1024;
ru->ru_ixrss += pgtok(vm->vm_tsize);
ru->ru_idrss += pgtok(vm->vm_dsize);
ru->ru_isrss += pgtok(vm->vm_ssize);
rss = pgtok(vmspace_resident_count(vm));
if (ru->ru_maxrss < rss)
ru->ru_maxrss = rss;
}

View File

@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: mp_machdep.c,v 1.89 1999/01/28 01:59:50 dillon Exp $
* $Id: mp_machdep.c,v 1.90 1999/02/19 14:25:32 luoqi Exp $
*/
#include "opt_smp.h"
@ -2387,10 +2387,10 @@ forwarded_statclock(int id, int pscnt, int *astmap)
if ((pstats = p->p_stats) != NULL &&
(ru = &pstats->p_ru) != NULL &&
(vm = p->p_vmspace) != NULL) {
ru->ru_ixrss += vm->vm_tsize * PAGE_SIZE / 1024;
ru->ru_idrss += vm->vm_dsize * PAGE_SIZE / 1024;
ru->ru_isrss += vm->vm_ssize * PAGE_SIZE / 1024;
rss = vmspace_resident_count(vm) * PAGE_SIZE / 1024;
ru->ru_ixrss += pgtok(vm->vm_tsize);
ru->ru_idrss += pgtok(vm->vm_dsize);
ru->ru_isrss += pgtok(vm->vm_ssize);
rss = pgtok(vmspace_resident_count(vm));
if (ru->ru_maxrss < rss)
ru->ru_maxrss = rss;
}

View File

@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: mp_machdep.c,v 1.89 1999/01/28 01:59:50 dillon Exp $
* $Id: mp_machdep.c,v 1.90 1999/02/19 14:25:32 luoqi Exp $
*/
#include "opt_smp.h"
@ -2387,10 +2387,10 @@ forwarded_statclock(int id, int pscnt, int *astmap)
if ((pstats = p->p_stats) != NULL &&
(ru = &pstats->p_ru) != NULL &&
(vm = p->p_vmspace) != NULL) {
ru->ru_ixrss += vm->vm_tsize * PAGE_SIZE / 1024;
ru->ru_idrss += vm->vm_dsize * PAGE_SIZE / 1024;
ru->ru_isrss += vm->vm_ssize * PAGE_SIZE / 1024;
rss = vmspace_resident_count(vm) * PAGE_SIZE / 1024;
ru->ru_ixrss += pgtok(vm->vm_tsize);
ru->ru_idrss += pgtok(vm->vm_dsize);
ru->ru_isrss += pgtok(vm->vm_ssize);
rss = pgtok(vmspace_resident_count(vm));
if (ru->ru_maxrss < rss)
ru->ru_maxrss = rss;
}

View File

@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: mp_machdep.c,v 1.89 1999/01/28 01:59:50 dillon Exp $
* $Id: mp_machdep.c,v 1.90 1999/02/19 14:25:32 luoqi Exp $
*/
#include "opt_smp.h"
@ -2387,10 +2387,10 @@ forwarded_statclock(int id, int pscnt, int *astmap)
if ((pstats = p->p_stats) != NULL &&
(ru = &pstats->p_ru) != NULL &&
(vm = p->p_vmspace) != NULL) {
ru->ru_ixrss += vm->vm_tsize * PAGE_SIZE / 1024;
ru->ru_idrss += vm->vm_dsize * PAGE_SIZE / 1024;
ru->ru_isrss += vm->vm_ssize * PAGE_SIZE / 1024;
rss = vmspace_resident_count(vm) * PAGE_SIZE / 1024;
ru->ru_ixrss += pgtok(vm->vm_tsize);
ru->ru_idrss += pgtok(vm->vm_dsize);
ru->ru_isrss += pgtok(vm->vm_ssize);
rss = pgtok(vmspace_resident_count(vm));
if (ru->ru_maxrss < rss)
ru->ru_maxrss = rss;
}

View File

@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: mp_machdep.c,v 1.89 1999/01/28 01:59:50 dillon Exp $
* $Id: mp_machdep.c,v 1.90 1999/02/19 14:25:32 luoqi Exp $
*/
#include "opt_smp.h"
@ -2387,10 +2387,10 @@ forwarded_statclock(int id, int pscnt, int *astmap)
if ((pstats = p->p_stats) != NULL &&
(ru = &pstats->p_ru) != NULL &&
(vm = p->p_vmspace) != NULL) {
ru->ru_ixrss += vm->vm_tsize * PAGE_SIZE / 1024;
ru->ru_idrss += vm->vm_dsize * PAGE_SIZE / 1024;
ru->ru_isrss += vm->vm_ssize * PAGE_SIZE / 1024;
rss = vmspace_resident_count(vm) * PAGE_SIZE / 1024;
ru->ru_ixrss += pgtok(vm->vm_tsize);
ru->ru_idrss += pgtok(vm->vm_dsize);
ru->ru_isrss += pgtok(vm->vm_ssize);
rss = pgtok(vmspace_resident_count(vm));
if (ru->ru_maxrss < rss)
ru->ru_maxrss = rss;
}

View File

@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: mp_machdep.c,v 1.89 1999/01/28 01:59:50 dillon Exp $
* $Id: mp_machdep.c,v 1.90 1999/02/19 14:25:32 luoqi Exp $
*/
#include "opt_smp.h"
@ -2387,10 +2387,10 @@ forwarded_statclock(int id, int pscnt, int *astmap)
if ((pstats = p->p_stats) != NULL &&
(ru = &pstats->p_ru) != NULL &&
(vm = p->p_vmspace) != NULL) {
ru->ru_ixrss += vm->vm_tsize * PAGE_SIZE / 1024;
ru->ru_idrss += vm->vm_dsize * PAGE_SIZE / 1024;
ru->ru_isrss += vm->vm_ssize * PAGE_SIZE / 1024;
rss = vmspace_resident_count(vm) * PAGE_SIZE / 1024;
ru->ru_ixrss += pgtok(vm->vm_tsize);
ru->ru_idrss += pgtok(vm->vm_dsize);
ru->ru_isrss += pgtok(vm->vm_ssize);
rss = pgtok(vmspace_resident_count(vm));
if (ru->ru_maxrss < rss)
ru->ru_maxrss = rss;
}

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)param.h 5.8 (Berkeley) 6/28/91
* $Id: param.h,v 1.47 1998/10/13 08:24:37 dg Exp $
* $Id: param.h,v 1.48 1999/01/07 06:35:18 peter Exp $
*/
#ifndef _MACHINE_PARAM_H_
@ -147,4 +147,6 @@
#define i386_btop(x) ((unsigned)(x) >> PAGE_SHIFT)
#define i386_ptob(x) ((unsigned)(x) << PAGE_SHIFT)
#define pgtok(x) ((x) * (PAGE_SIZE / 1024))
#endif /* !_MACHINE_PARAM_H_ */

View File

@ -37,7 +37,7 @@
* SUCH DAMAGE.
*
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
* $Id: kern_clock.c,v 1.86 1998/11/29 20:31:02 phk Exp $
* $Id: kern_clock.c,v 1.87 1999/02/19 14:25:34 luoqi Exp $
*/
#include <sys/param.h>
@ -469,10 +469,10 @@ statclock(frame)
if ((pstats = p->p_stats) != NULL &&
(ru = &pstats->p_ru) != NULL &&
(vm = p->p_vmspace) != NULL) {
ru->ru_ixrss += vm->vm_tsize * PAGE_SIZE / 1024;
ru->ru_idrss += vm->vm_dsize * PAGE_SIZE / 1024;
ru->ru_isrss += vm->vm_ssize * PAGE_SIZE / 1024;
rss = vmspace_resident_count(vm) * PAGE_SIZE / 1024;
ru->ru_ixrss += pgtok(vm->vm_tsize);
ru->ru_idrss += pgtok(vm->vm_dsize);
ru->ru_isrss += pgtok(vm->vm_ssize);
rss = pgtok(vmspace_resident_count(vm));
if (ru->ru_maxrss < rss)
ru->ru_maxrss = rss;
}

View File

@ -37,7 +37,7 @@
* SUCH DAMAGE.
*
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
* $Id: kern_clock.c,v 1.86 1998/11/29 20:31:02 phk Exp $
* $Id: kern_clock.c,v 1.87 1999/02/19 14:25:34 luoqi Exp $
*/
#include <sys/param.h>
@ -469,10 +469,10 @@ statclock(frame)
if ((pstats = p->p_stats) != NULL &&
(ru = &pstats->p_ru) != NULL &&
(vm = p->p_vmspace) != NULL) {
ru->ru_ixrss += vm->vm_tsize * PAGE_SIZE / 1024;
ru->ru_idrss += vm->vm_dsize * PAGE_SIZE / 1024;
ru->ru_isrss += vm->vm_ssize * PAGE_SIZE / 1024;
rss = vmspace_resident_count(vm) * PAGE_SIZE / 1024;
ru->ru_ixrss += pgtok(vm->vm_tsize);
ru->ru_idrss += pgtok(vm->vm_dsize);
ru->ru_isrss += pgtok(vm->vm_ssize);
rss = pgtok(vmspace_resident_count(vm));
if (ru->ru_maxrss < rss)
ru->ru_maxrss = rss;
}

View File

@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: mp_machdep.c,v 1.89 1999/01/28 01:59:50 dillon Exp $
* $Id: mp_machdep.c,v 1.90 1999/02/19 14:25:32 luoqi Exp $
*/
#include "opt_smp.h"
@ -2387,10 +2387,10 @@ forwarded_statclock(int id, int pscnt, int *astmap)
if ((pstats = p->p_stats) != NULL &&
(ru = &pstats->p_ru) != NULL &&
(vm = p->p_vmspace) != NULL) {
ru->ru_ixrss += vm->vm_tsize * PAGE_SIZE / 1024;
ru->ru_idrss += vm->vm_dsize * PAGE_SIZE / 1024;
ru->ru_isrss += vm->vm_ssize * PAGE_SIZE / 1024;
rss = vmspace_resident_count(vm) * PAGE_SIZE / 1024;
ru->ru_ixrss += pgtok(vm->vm_tsize);
ru->ru_idrss += pgtok(vm->vm_dsize);
ru->ru_isrss += pgtok(vm->vm_ssize);
rss = pgtok(vmspace_resident_count(vm));
if (ru->ru_maxrss < rss)
ru->ru_maxrss = rss;
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.c 8.8 (Berkeley) 1/21/94
* $Id: tty.c,v 1.113 1999/01/30 12:17:36 phk Exp $
* $Id: tty.c,v 1.114 1999/02/19 14:25:34 luoqi Exp $
*/
/*-
@ -2269,7 +2269,6 @@ ttyinfo(tp)
ttyprintf(tp, "%ld.%02lds ",
stime.tv_sec, stime.tv_usec / 10000);
#define pgtok(a) (((a) * PAGE_SIZE) / 1024)
/* Print percentage cpu, resident set size. */
tmp = (pick->p_pctcpu * 10000 + FSCALE / 2) >> FSHIFT;
ttyprintf(tp, "%d%% %ldk\n",