Added pagein' and pageout'.

1998-08-01  Martin Baulig  <martin@home-of-linux.org>

	* include/glibtop/swap.h (glibtop_swap): Added `pagein' and `pageout'.

	* kernel/table20/table.h: Removed.
	* kernel/table21/table.h: Removed.
	* kernel/table.h: Added. Things are now binary compatible between
	both kernel versions.
This commit is contained in:
Martin Baulig
1998-08-01 22:03:11 +00:00
committed by Martin Baulig
parent fc506344ea
commit 2e454140f1
11 changed files with 59 additions and 181 deletions

View File

@@ -1,3 +1,12 @@
1998-08-01 Martin Baulig <martin@home-of-linux.org>
* include/glibtop/swap.h (glibtop_swap): Added `pagein' and `pageout'.
* kernel/table20/table.h: Removed.
* kernel/table21/table.h: Removed.
* kernel/table.h: Added. Things are now binary compatible between
both kernel versions.
1998-07-30 Martin Baulig <martin@home-of-linux.org> 1998-07-30 Martin Baulig <martin@home-of-linux.org>
* acconfig.h (u_int64_t, int64_t): Added. * acconfig.h (u_int64_t, int64_t): Added.

View File

@@ -86,8 +86,9 @@ main (int argc, char *argv [])
for (c = 0; c < PROFILE_COUNT; c++) for (c = 0; c < PROFILE_COUNT; c++)
glibtop_get_swap (&data.swap); glibtop_get_swap (&data.swap);
printf ("Swap (0x%08Lx): %Lu, %Lu, %Lu\n", data.swap.flags, printf ("Swap (0x%08Lx): %Lu, %Lu, %Lu, %Lu, %Lu\n",
data.swap.total, data.swap.used, data.swap.free); data.swap.flags, data.swap.total, data.swap.used,
data.swap.free, data.swap.pagein, data.swap.pageout);
for (c = 0; c < PROFILE_COUNT; c++) for (c = 0; c < PROFILE_COUNT; c++)
glibtop_get_uptime (&data.uptime); glibtop_get_uptime (&data.uptime);

View File

@@ -1,6 +1,6 @@
void|cpu|ulong(total,user,nice,sys,idle,frequency) void|cpu|ulong(total,user,nice,sys,idle,frequency)
void|mem|ulong(total,used,free,shared,buffer,cached,user,locked) void|mem|ulong(total,used,free,shared,buffer,cached,user,locked)
void|swap|ulong(total,used,free) void|swap|ulong(total,used,free,pagein,pageout)
void|uptime|double(uptime,idletime) void|uptime|double(uptime,idletime)
void|loadavg|double(loadavg[0],loadavg[1],loadavg[2]) void|loadavg|double(loadavg[0],loadavg[1],loadavg[2])
void|shm_limits|ulong(shmmax,shmmin,shmmni,shmseg,shmall) void|shm_limits|ulong(shmmax,shmmin,shmmni,shmseg,shmall)

View File

@@ -30,8 +30,10 @@ __BEGIN_DECLS
#define GLIBTOP_SWAP_TOTAL 0 #define GLIBTOP_SWAP_TOTAL 0
#define GLIBTOP_SWAP_USED 1 #define GLIBTOP_SWAP_USED 1
#define GLIBTOP_SWAP_FREE 2 #define GLIBTOP_SWAP_FREE 2
#define GLIBTOP_SWAP_PAGEIN 3
#define GLIBTOP_SWAP_PAGEOUT 4
#define GLIBTOP_MAX_SWAP 3 #define GLIBTOP_MAX_SWAP 5
typedef struct _glibtop_swap glibtop_swap; typedef struct _glibtop_swap glibtop_swap;
@@ -40,7 +42,9 @@ struct _glibtop_swap
u_int64_t flags, u_int64_t flags,
total, /* GLIBTOP_SWAP_TOTAL */ total, /* GLIBTOP_SWAP_TOTAL */
used, /* GLIBTOP_SWAP_USED */ used, /* GLIBTOP_SWAP_USED */
free; /* GLIBTOP_SWAP_FREE */ free, /* GLIBTOP_SWAP_FREE */
pagein, /* GLIBTOP_SWAP_PAGEIN */
pageout; /* GLIBTOP_SWAP_PAGEOUT */
}; };
#define glibtop_get_swap(swap) glibtop_get_swap_l(glibtop_global_server, swap) #define glibtop_get_swap(swap) glibtop_get_swap_l(glibtop_global_server, swap)

View File

@@ -53,6 +53,8 @@ struct table_swap
unsigned long total; /* Total swap space */ unsigned long total; /* Total swap space */
unsigned long used; /* Used swap space */ unsigned long used; /* Used swap space */
unsigned long free; /* Free swap space */ unsigned long free; /* Free swap space */
unsigned long pagein; /* Total # of pages swapped in */
unsigned long pageout; /* Total # of pages swapped out */
}; };
/* Load average */ /* Load average */

View File

@@ -28,14 +28,16 @@ diff -ur linux-2.0.32/Makefile linux-hacked/Makefile
diff -ur linux-2.0.32/arch/i386/kernel/entry.S linux-hacked/arch/i386/kernel/entry.S diff -ur linux-2.0.32/arch/i386/kernel/entry.S linux-hacked/arch/i386/kernel/entry.S
--- linux-2.0.32/arch/i386/kernel/entry.S Tue Sep 16 23:42:45 1997 --- linux-2.0.32/arch/i386/kernel/entry.S Tue Sep 16 23:42:45 1997
+++ linux-hacked/arch/i386/kernel/entry.S Thu Jun 11 21:37:20 1998 +++ linux-hacked/arch/i386/kernel/entry.S Thu Jun 11 21:37:20 1998
@@ -699,4 +699,6 @@ @@ -699,4 +699,8 @@
.long SYMBOL_NAME(sys_mremap) .long SYMBOL_NAME(sys_mremap)
.long 0,0 .long 0,0
.long SYMBOL_NAME(sys_vm86) .long SYMBOL_NAME(sys_vm86)
- .space (NR_syscalls-166)*4 - .space (NR_syscalls-166)*4
+ .long 0 + .long 0,0,0,0 /* 170 */
+ .long 0,0,0,0,0,0,0,0,0,0 /* 180 */
+ .long 0,0,0,0,0,0,0
+ .long SYMBOL_NAME(sys_table) + .long SYMBOL_NAME(sys_table)
+ .space (NR_syscalls-168)*4 + .space (NR_syscalls-188)*4
diff -ur linux-2.0.32/include/asm-i386/unistd.h linux-hacked/include/asm-i386/unistd.h diff -ur linux-2.0.32/include/asm-i386/unistd.h linux-hacked/include/asm-i386/unistd.h
--- linux-2.0.32/include/asm-i386/unistd.h Fri Mar 22 07:34:02 1996 --- linux-2.0.32/include/asm-i386/unistd.h Fri Mar 22 07:34:02 1996
+++ linux-hacked/include/asm-i386/unistd.h Thu Jun 11 21:37:03 1998 +++ linux-hacked/include/asm-i386/unistd.h Thu Jun 11 21:37:03 1998
@@ -43,7 +45,7 @@ diff -ur linux-2.0.32/include/asm-i386/unistd.h linux-hacked/include/asm-i386/un
#define __NR_sched_rr_get_interval 161 #define __NR_sched_rr_get_interval 161
#define __NR_nanosleep 162 #define __NR_nanosleep 162
#define __NR_mremap 163 #define __NR_mremap 163
+#define __NR_table 168 +#define __NR_table 188
/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */ /* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
#define _syscall0(type,name) \ #define _syscall0(type,name) \

View File

@@ -257,6 +257,8 @@ sys_table (int type, union table *buf, const void *param)
tbl.swap.total = i.totalswap; tbl.swap.total = i.totalswap;
tbl.swap.used = i.totalswap - i.freeswap; tbl.swap.used = i.totalswap - i.freeswap;
tbl.swap.free = i.freeswap; tbl.swap.free = i.freeswap;
tbl.swap.pagein = kstat.pswpin;
tbl.swap.pageout = kstat.pswpout;
break; break;
case TABLE_LOADAVG: case TABLE_LOADAVG:
tbl.loadavg.loadavg [0] = (double) avenrun [0] / (1 << FSHIFT); tbl.loadavg.loadavg [0] = (double) avenrun [0] / (1 << FSHIFT);

View File

@@ -1,166 +0,0 @@
#ifndef _LINUX_TABLE_H
#define _LINUX_TABLE_H
#ifdef _KERNEL
#include <linux/types.h>
#else
#define NR_TASKS 512
#endif
#define TABLE_VERSION 0
#define TABLE_CPU 1
#define TABLE_MEM 2
#define TABLE_SWAP 3
#define TABLE_LOADAVG 4
#define TABLE_UPTIME 5
#define TABLE_PROCLIST 6
#define TABLE_PROC_UID 7
#define TABLE_PROC_MEM 8
#define TABLE_PROC_SEGMENT 9
#define TABLE_PROC_TIME 10
#define TABLE_PROC_STATE 11
#define TABLE_PROC_SIGNAL 12
#define TABLE_PROC_KERNEL 13
/* CPU Usage (in jiffies = 1/100th seconds) */
struct table_cpu
{
unsigned long total; /* Total CPU Time */
unsigned long user; /* CPU Time in User Mode */
unsigned long nice; /* CPU Time in User Mode (nice) */
unsigned long sys; /* CPU Time in System Mode */
unsigned long idle; /* CPU Time in the Idle Task */
unsigned long frequency; /* Tick frequency */
};
/* Memory Usage (in bytes) */
struct table_mem
{
unsigned long total; /* Total physical memory */
unsigned long used; /* Used memory size */
unsigned long free; /* Free memory size */
unsigned long shared; /* Shared memory size */
unsigned long buffer; /* Size of buffers */
unsigned long cached; /* Size of cached memory */
};
/* Swap Space (in bytes) */
struct table_swap
{
unsigned long total; /* Total swap space */
unsigned long used; /* Used swap space */
unsigned long free; /* Free swap space */
};
/* Load average */
struct table_loadavg
{
double loadavg [3];
unsigned nr_running;
unsigned nr_tasks;
unsigned last_pid;
};
/* Uptime */
struct table_uptime
{
unsigned long uptime;
unsigned long idle;
};
/* Process list. */
struct table_proclist
{
int nr_running, nr_tasks, last_pid;
unsigned pids [NR_TASKS];
};
/* Information about processes. */
struct table_proc_state
{
long state;
unsigned long flags;
char comm[16];
};
struct table_proc_uid
{
int uid, euid, suid, fsuid;
int gid, egid, sgid, fsgid;
int pid, pgrp, ppid;
int session;
unsigned int tty;
int tpgid;
long priority;
long counter;
long def_priority;
};
struct table_proc_mem
{
unsigned long context;
unsigned long start_code, end_code, start_data, end_data;
unsigned long start_brk, brk, start_stack, start_mmap;
unsigned long arg_start, arg_end, env_start, env_end;
unsigned long rss, rlim, total_vm, locked_vm;
};
struct table_proc_segment
{
unsigned long vsize;
int size, resident, shared;
int trs, lrs, drs, dt;
};
struct table_proc_time
{
long utime, stime, cutime, cstime, start_time;
unsigned long timeout, policy, rt_priority;
unsigned long it_real_value, it_prof_value, it_virt_value;
unsigned long it_real_incr, it_prof_incr, it_virt_incr;
};
struct table_proc_signal
{
sigset_t signal;
sigset_t blocked; /* bitmap of masked signals */
sigset_t ignored; /* mask of ignored signals */
sigset_t caught; /* mask of caught signals */
};
struct table_proc_kernel
{
unsigned long keip, kesp, wchan;
unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
unsigned long nswap, cnswap;
};
/* Union */
union table
{
struct table_cpu cpu;
struct table_mem mem;
struct table_swap swap;
struct table_loadavg loadavg;
struct table_uptime uptime;
struct table_proclist proclist;
struct table_proc_uid proc_uid;
struct table_proc_mem proc_mem;
struct table_proc_segment proc_segment;
struct table_proc_time proc_time;
struct table_proc_state proc_state;
struct table_proc_signal proc_signal;
struct table_proc_kernel proc_kernel;
};
#endif /* _LINUX_IPC_H */

View File

@@ -27,7 +27,8 @@
static unsigned long _glibtop_sysdeps_swap = static unsigned long _glibtop_sysdeps_swap =
(1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) + (1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) +
(1 << GLIBTOP_SWAP_FREE); (1 << GLIBTOP_SWAP_FREE) + (1 << GLIBTOP_SWAP_PAGEIN) +
(1 << GLIBTOP_SWAP_PAGEOUT);
/* Provides information about swap usage. */ /* Provides information about swap usage. */
@@ -48,4 +49,7 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
buf->total = tbl.swap.total; buf->total = tbl.swap.total;
buf->used = tbl.swap.used; buf->used = tbl.swap.used;
buf->free = tbl.swap.free; buf->free = tbl.swap.free;
buf->pagein = tbl.swap.pagein;
buf->pageout = tbl.swap.pageout;
} }

View File

@@ -23,9 +23,12 @@
#include <glibtop/error.h> #include <glibtop/error.h>
#include <glibtop/swap.h> #include <glibtop/swap.h>
#include <fcntl.h>
static unsigned long _glibtop_sysdeps_swap = static unsigned long _glibtop_sysdeps_swap =
(1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) + (1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) +
(1 << GLIBTOP_SWAP_FREE); (1 << GLIBTOP_SWAP_FREE) + (1 << GLIBTOP_SWAP_PAGEIN) +
(1 << GLIBTOP_SWAP_PAGEOUT);
#define FILENAME "/proc/meminfo" #define FILENAME "/proc/meminfo"
@@ -34,6 +37,8 @@ static unsigned long _glibtop_sysdeps_swap =
void void
glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
{ {
char buffer [BUFSIZ+1], *ptr;
int fd, len;
FILE *f; FILE *f;
glibtop_init_s (&server, 0, 0); glibtop_init_s (&server, 0, 0);
@@ -49,4 +54,14 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
&buf->total, &buf->used, &buf->free); &buf->total, &buf->used, &buf->free);
fclose (f); fclose (f);
fd = open ("/proc/stat", O_RDONLY);
len = read (fd, buffer, BUFSIZ);
close (fd);
ptr = strstr (buffer, "\nswap");
if (ptr == NULL) return;
sscanf (ptr, "\nSwap: %Lu %Lu\n",
&buf->pagein, &buf->pageout);
} }

View File

@@ -23,24 +23,29 @@
const char *glibtop_names_swap [GLIBTOP_MAX_SWAP] = const char *glibtop_names_swap [GLIBTOP_MAX_SWAP] =
{ {
"total", "used", "free" "total", "used", "free", "pagein", "pageout"
}; };
const unsigned glibtop_types_swap [GLIBTOP_MAX_SWAP] = const unsigned glibtop_types_swap [GLIBTOP_MAX_SWAP] =
{ {
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG
}; };
const char *glibtop_labels_swap [GLIBTOP_MAX_SWAP] = const char *glibtop_labels_swap [GLIBTOP_MAX_SWAP] =
{ {
N_("Total Swap Space"), N_("Total Swap Space"),
N_("Used Swap Space"), N_("Used Swap Space"),
N_("Free Swap Space") N_("Free Swap Space"),
N_("Page In"),
N_("Page Out"),
}; };
const char *glibtop_descriptions_swap [GLIBTOP_MAX_SWAP] = const char *glibtop_descriptions_swap [GLIBTOP_MAX_SWAP] =
{ {
N_("Total Swap Space"), N_("Total Swap Space"),
N_("Used Swap Space"), N_("Used Swap Space"),
N_("Free Swap Space") N_("Free Swap Space"),
N_("Total number of swap pages that have been brought in"),
N_("Total number of swap pages that have been brought out"),
}; };