PM: added possibility to copy hole list from alloc.c to outside, for
misc.c to copy it away by getsysinfo IS: prints out hole list + stats such as largest contiguous chunk
This commit is contained in:
parent
f04d46f456
commit
abd0b53e0a
7 changed files with 78 additions and 13 deletions
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include "is.h"
|
#include "is.h"
|
||||||
|
|
||||||
#define NHOOKS 17
|
#define NHOOKS 18
|
||||||
|
|
||||||
struct hook_entry {
|
struct hook_entry {
|
||||||
int key;
|
int key;
|
||||||
|
@ -33,6 +33,7 @@ struct hook_entry {
|
||||||
{ SF4, dtab_dmp, "Device/Driver mapping" },
|
{ SF4, dtab_dmp, "Device/Driver mapping" },
|
||||||
{ SF5, mapping_dmp, "Print key mappings" },
|
{ SF5, mapping_dmp, "Print key mappings" },
|
||||||
{ SF6, rproc_dmp, "Reincarnation server process table" },
|
{ SF6, rproc_dmp, "Reincarnation server process table" },
|
||||||
|
{ SF7, holes_dmp, "Memory free list" },
|
||||||
};
|
};
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
|
@ -53,7 +54,7 @@ PUBLIC int do_fkey_pressed(message *m)
|
||||||
if (OK != (s=sendrec(TTY_PROC_NR, m)))
|
if (OK != (s=sendrec(TTY_PROC_NR, m)))
|
||||||
report("IS", "warning, sendrec to TTY failed", s);
|
report("IS", "warning, sendrec to TTY failed", s);
|
||||||
|
|
||||||
/* Now check which keys were pressed: F1-F12. */
|
/* Now check which keys were pressed: F1-F12, SF1-SF12. */
|
||||||
for(h = 0; h < NHOOKS; h++)
|
for(h = 0; h < NHOOKS; h++)
|
||||||
if(pressed(hooks[h].key))
|
if(pressed(hooks[h].key))
|
||||||
hooks[h].function();
|
hooks[h].function();
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include "is.h"
|
#include "is.h"
|
||||||
#include "../pm/mproc.h"
|
#include "../pm/mproc.h"
|
||||||
#include <timers.h>
|
#include <timers.h>
|
||||||
|
#include <minix/config.h>
|
||||||
|
#include <minix/type.h>
|
||||||
|
|
||||||
PUBLIC struct mproc mproc[NR_PROCS];
|
PUBLIC struct mproc mproc[NR_PROCS];
|
||||||
|
|
||||||
|
@ -97,3 +99,39 @@ PUBLIC void sigaction_dmp()
|
||||||
prev_i = i;
|
prev_i = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*===========================================================================*
|
||||||
|
* holes_dmp *
|
||||||
|
*===========================================================================*/
|
||||||
|
PUBLIC void holes_dmp(void)
|
||||||
|
{
|
||||||
|
static struct hole holes[_NR_HOLES];
|
||||||
|
int h;
|
||||||
|
int largest_bytes = 0, total_bytes = 0;
|
||||||
|
|
||||||
|
if(getsysinfo(PM_PROC_NR, SI_MEM_ALLOC, holes) != OK) {
|
||||||
|
printf("Obtaining memory hole list failed.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("Available memory stats\n");
|
||||||
|
|
||||||
|
for(h = 0; h < _NR_HOLES; h++) {
|
||||||
|
if(holes[h].h_base && holes[h].h_len) {
|
||||||
|
int bytes;
|
||||||
|
bytes = (holes[h].h_len << CLICK_SHIFT);
|
||||||
|
printf("%08lx: %6d kB\n",
|
||||||
|
holes[h].h_base << CLICK_SHIFT, bytes / 1024);
|
||||||
|
if(bytes > largest_bytes) largest_bytes = bytes;
|
||||||
|
total_bytes += bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\nTotal memory free: %d kB\n"
|
||||||
|
"Largest contiguous chunk: %d kB\n"
|
||||||
|
"Uncontiguous rest: %d kB (%d%% of total free)\n",
|
||||||
|
total_bytes/1024,
|
||||||
|
largest_bytes/1024,
|
||||||
|
(total_bytes-largest_bytes)/1024,
|
||||||
|
100*(total_bytes/100-largest_bytes/100)/total_bytes);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ PRIVATE void init_server(int argc, char **argv)
|
||||||
/* Set key mappings. IS takes all of F1-F12 and Shift+F1-F6. */
|
/* Set key mappings. IS takes all of F1-F12 and Shift+F1-F6. */
|
||||||
fkeys = sfkeys = 0;
|
fkeys = sfkeys = 0;
|
||||||
for (i=1; i<=12; i++) bit_set(fkeys, i);
|
for (i=1; i<=12; i++) bit_set(fkeys, i);
|
||||||
for (i=1; i<= 6; i++) bit_set(sfkeys, i);
|
for (i=1; i<= 7; i++) bit_set(sfkeys, i);
|
||||||
if ((s=fkey_map(&fkeys, &sfkeys)) != OK)
|
if ((s=fkey_map(&fkeys, &sfkeys)) != OK)
|
||||||
report("IS", "warning, fkey_map failed:", s);
|
report("IS", "warning, fkey_map failed:", s);
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ PRIVATE void exit_server()
|
||||||
*/
|
*/
|
||||||
fkeys = sfkeys = 0;
|
fkeys = sfkeys = 0;
|
||||||
for (i=1; i<=12; i++) bit_set(fkeys, i);
|
for (i=1; i<=12; i++) bit_set(fkeys, i);
|
||||||
for (i=1; i<= 6; i++) bit_set(sfkeys, i);
|
for (i=1; i<= 7; i++) bit_set(sfkeys, i);
|
||||||
if ((s=fkey_unmap(&fkeys, &sfkeys)) != OK)
|
if ((s=fkey_unmap(&fkeys, &sfkeys)) != OK)
|
||||||
report("IS", "warning, unfkey_map failed:", s);
|
report("IS", "warning, unfkey_map failed:", s);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ _PROTOTYPE( void timing_dmp, (void) );
|
||||||
/* dmp_pm.c */
|
/* dmp_pm.c */
|
||||||
_PROTOTYPE( void mproc_dmp, (void) );
|
_PROTOTYPE( void mproc_dmp, (void) );
|
||||||
_PROTOTYPE( void sigaction_dmp, (void) );
|
_PROTOTYPE( void sigaction_dmp, (void) );
|
||||||
|
_PROTOTYPE( void holes_dmp, (void) );
|
||||||
|
|
||||||
/* dmp_fs.c */
|
/* dmp_fs.c */
|
||||||
_PROTOTYPE( void dtab_dmp, (void) );
|
_PROTOTYPE( void dtab_dmp, (void) );
|
||||||
|
|
|
@ -13,26 +13,25 @@
|
||||||
* free_mem: release a previously allocated chunk of memory
|
* free_mem: release a previously allocated chunk of memory
|
||||||
* mem_init: initialize the tables when PM start up
|
* mem_init: initialize the tables when PM start up
|
||||||
* max_hole: returns the largest hole currently available
|
* max_hole: returns the largest hole currently available
|
||||||
|
* mem_holes_copy: for outsiders who want a copy of the hole-list
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pm.h"
|
#include "pm.h"
|
||||||
#include <minix/com.h>
|
#include <minix/com.h>
|
||||||
#include <minix/callnr.h>
|
#include <minix/callnr.h>
|
||||||
|
#include <minix/type.h>
|
||||||
|
#include <minix/config.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include "mproc.h"
|
#include "mproc.h"
|
||||||
#include "../../kernel/const.h"
|
#include "../../kernel/const.h"
|
||||||
#include "../../kernel/config.h"
|
#include "../../kernel/config.h"
|
||||||
#include "../../kernel/type.h"
|
#include "../../kernel/type.h"
|
||||||
|
|
||||||
#define NR_HOLES (2*NR_PROCS) /* max # entries in hole table */
|
|
||||||
#define NIL_HOLE (struct hole *) 0
|
#define NIL_HOLE (struct hole *) 0
|
||||||
|
|
||||||
PRIVATE struct hole {
|
PRIVATE struct hole hole[_NR_HOLES];
|
||||||
struct hole *h_next; /* pointer to next entry on the list */
|
|
||||||
phys_clicks h_base; /* where does the hole begin? */
|
|
||||||
phys_clicks h_len; /* how big is the hole? */
|
|
||||||
} hole[NR_HOLES];
|
|
||||||
|
|
||||||
PRIVATE struct hole *hole_head; /* pointer to first hole */
|
PRIVATE struct hole *hole_head; /* pointer to first hole */
|
||||||
PRIVATE struct hole *free_slots;/* ptr to list of unused table slots */
|
PRIVATE struct hole *free_slots;/* ptr to list of unused table slots */
|
||||||
|
@ -161,6 +160,7 @@ register struct hole *hp;
|
||||||
prev_ptr->h_next = hp->h_next;
|
prev_ptr->h_next = hp->h_next;
|
||||||
|
|
||||||
hp->h_next = free_slots;
|
hp->h_next = free_slots;
|
||||||
|
hp->h_base = hp->h_len = 0;
|
||||||
free_slots = hp;
|
free_slots = hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,8 +218,11 @@ phys_clicks *free; /* memory size summaries */
|
||||||
register struct hole *hp;
|
register struct hole *hp;
|
||||||
|
|
||||||
/* Put all holes on the free list. */
|
/* Put all holes on the free list. */
|
||||||
for (hp = &hole[0]; hp < &hole[NR_HOLES]; hp++) hp->h_next = hp + 1;
|
for (hp = &hole[0]; hp < &hole[_NR_HOLES]; hp++) {
|
||||||
hole[NR_HOLES-1].h_next = NIL_HOLE;
|
hp->h_next = hp + 1;
|
||||||
|
hp->h_base = hp->h_len = 0;
|
||||||
|
}
|
||||||
|
hole[_NR_HOLES-1].h_next = NIL_HOLE;
|
||||||
hole_head = NIL_HOLE;
|
hole_head = NIL_HOLE;
|
||||||
free_slots = &hole[0];
|
free_slots = &hole[0];
|
||||||
|
|
||||||
|
@ -247,6 +250,17 @@ phys_clicks *free; /* memory size summaries */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*===========================================================================*
|
||||||
|
* mem_holes_copy *
|
||||||
|
*===========================================================================*/
|
||||||
|
PUBLIC int mem_holes_copy(struct hole *holecopies, size_t *bytes)
|
||||||
|
{
|
||||||
|
if(*bytes < sizeof(hole)) return ENOSPC;
|
||||||
|
memcpy(holecopies, hole, sizeof(hole));
|
||||||
|
*bytes = sizeof(hole);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLE_SWAP
|
#if ENABLE_SWAP
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* swap_on *
|
* swap_on *
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include <sys/svrctl.h>
|
#include <sys/svrctl.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <minix/com.h>
|
#include <minix/com.h>
|
||||||
|
#include <minix/config.h>
|
||||||
|
#include <minix/type.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "mproc.h"
|
#include "mproc.h"
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
|
@ -58,7 +60,9 @@ PUBLIC int do_getsysinfo()
|
||||||
vir_bytes src_addr, dst_addr;
|
vir_bytes src_addr, dst_addr;
|
||||||
struct kinfo kinfo;
|
struct kinfo kinfo;
|
||||||
size_t len;
|
size_t len;
|
||||||
int s;
|
static struct hole holes[_NR_HOLES];
|
||||||
|
int s, r;
|
||||||
|
size_t holesize;
|
||||||
|
|
||||||
switch(m_in.info_what) {
|
switch(m_in.info_what) {
|
||||||
case SI_KINFO: /* kernel info is obtained via PM */
|
case SI_KINFO: /* kernel info is obtained via PM */
|
||||||
|
@ -75,6 +79,12 @@ PUBLIC int do_getsysinfo()
|
||||||
src_addr = (vir_bytes) mproc;
|
src_addr = (vir_bytes) mproc;
|
||||||
len = sizeof(struct mproc) * NR_PROCS;
|
len = sizeof(struct mproc) * NR_PROCS;
|
||||||
break;
|
break;
|
||||||
|
case SI_MEM_ALLOC:
|
||||||
|
holesize = sizeof(holes);
|
||||||
|
if((r=mem_holes_copy(holes, &holesize)) != OK) return r;
|
||||||
|
src_addr = (vir_bytes) holes;
|
||||||
|
len = holesize;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return(EINVAL);
|
return(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ _PROTOTYPE( void swap_inqueue, (struct mproc *rmp) );
|
||||||
#define swap_in() ((void)0)
|
#define swap_in() ((void)0)
|
||||||
#define swap_inqueue(rmp) ((void)0)
|
#define swap_inqueue(rmp) ((void)0)
|
||||||
#endif /* !SWAP */
|
#endif /* !SWAP */
|
||||||
|
_PROTOTYPE(int mem_holes_copy, (struct hole *, size_t *) );
|
||||||
|
|
||||||
/* break.c */
|
/* break.c */
|
||||||
_PROTOTYPE( int adjust, (struct mproc *rmp,
|
_PROTOTYPE( int adjust, (struct mproc *rmp,
|
||||||
|
|
Loading…
Reference in a new issue