remove mconf cruft
This commit is contained in:
parent
fcf30f314b
commit
7cd1b102ee
16 changed files with 78 additions and 271 deletions
|
@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 };
|
||||||
|
|
||||||
|
|
||||||
#include "portdat.h"
|
#include "portdat.h"
|
||||||
|
|
||||||
enum { MAXBANK = 2 };
|
|
||||||
|
|
||||||
typedef struct Mbank {
|
|
||||||
ulong base;
|
|
||||||
ulong limit;
|
|
||||||
} Mbank;
|
|
||||||
|
|
||||||
typedef struct Mconf {
|
|
||||||
Lock;
|
|
||||||
Mbank bank[MAXBANK];
|
|
||||||
int nbank;
|
|
||||||
ulong memsize;
|
|
||||||
} Mconf;
|
|
||||||
extern Mconf mconf;
|
|
||||||
|
|
|
@ -17,20 +17,4 @@
|
||||||
*/
|
*/
|
||||||
enum { FIXEDSIZE = 1 };
|
enum { FIXEDSIZE = 1 };
|
||||||
|
|
||||||
|
|
||||||
#include "portdat.h"
|
#include "portdat.h"
|
||||||
|
|
||||||
enum { MAXBANK = 2 };
|
|
||||||
|
|
||||||
typedef struct Mbank {
|
|
||||||
ulong base;
|
|
||||||
ulong limit;
|
|
||||||
} Mbank;
|
|
||||||
|
|
||||||
typedef struct Mconf {
|
|
||||||
Lock;
|
|
||||||
Mbank bank[MAXBANK];
|
|
||||||
int nbank;
|
|
||||||
ulong memsize;
|
|
||||||
} Mconf;
|
|
||||||
extern Mconf mconf;
|
|
||||||
|
|
|
@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 };
|
||||||
|
|
||||||
|
|
||||||
#include "portdat.h"
|
#include "portdat.h"
|
||||||
|
|
||||||
enum { MAXBANK = 2 };
|
|
||||||
|
|
||||||
typedef struct Mbank {
|
|
||||||
ulong base;
|
|
||||||
ulong limit;
|
|
||||||
} Mbank;
|
|
||||||
|
|
||||||
typedef struct Mconf {
|
|
||||||
Lock;
|
|
||||||
Mbank bank[MAXBANK];
|
|
||||||
int nbank;
|
|
||||||
ulong memsize;
|
|
||||||
} Mconf;
|
|
||||||
extern Mconf mconf;
|
|
||||||
|
|
|
@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 };
|
||||||
|
|
||||||
|
|
||||||
#include "portdat.h"
|
#include "portdat.h"
|
||||||
|
|
||||||
enum { MAXBANK = 2 };
|
|
||||||
|
|
||||||
typedef struct Mbank {
|
|
||||||
ulong base;
|
|
||||||
ulong limit;
|
|
||||||
} Mbank;
|
|
||||||
|
|
||||||
typedef struct Mconf {
|
|
||||||
Lock;
|
|
||||||
Mbank bank[MAXBANK];
|
|
||||||
int nbank;
|
|
||||||
ulong memsize;
|
|
||||||
} Mconf;
|
|
||||||
extern Mconf mconf;
|
|
||||||
|
|
|
@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 };
|
||||||
|
|
||||||
|
|
||||||
#include "portdat.h"
|
#include "portdat.h"
|
||||||
|
|
||||||
enum { MAXBANK = 2 };
|
|
||||||
|
|
||||||
typedef struct Mbank {
|
|
||||||
ulong base;
|
|
||||||
ulong limit;
|
|
||||||
} Mbank;
|
|
||||||
|
|
||||||
typedef struct Mconf {
|
|
||||||
Lock;
|
|
||||||
Mbank bank[MAXBANK];
|
|
||||||
int nbank;
|
|
||||||
ulong memsize;
|
|
||||||
} Mconf;
|
|
||||||
extern Mconf mconf;
|
|
||||||
|
|
|
@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 };
|
||||||
|
|
||||||
|
|
||||||
#include "portdat.h"
|
#include "portdat.h"
|
||||||
|
|
||||||
enum { MAXBANK = 2 };
|
|
||||||
|
|
||||||
typedef struct Mbank {
|
|
||||||
ulong base;
|
|
||||||
ulong limit;
|
|
||||||
} Mbank;
|
|
||||||
|
|
||||||
typedef struct Mconf {
|
|
||||||
Lock;
|
|
||||||
Mbank bank[MAXBANK];
|
|
||||||
int nbank;
|
|
||||||
ulong memsize;
|
|
||||||
} Mconf;
|
|
||||||
extern Mconf mconf;
|
|
||||||
|
|
|
@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 };
|
||||||
|
|
||||||
|
|
||||||
#include "portdat.h"
|
#include "portdat.h"
|
||||||
|
|
||||||
enum { MAXBANK = 2 };
|
|
||||||
|
|
||||||
typedef struct Mbank {
|
|
||||||
ulong base;
|
|
||||||
ulong limit;
|
|
||||||
} Mbank;
|
|
||||||
|
|
||||||
typedef struct Mconf {
|
|
||||||
Lock;
|
|
||||||
Mbank bank[MAXBANK];
|
|
||||||
int nbank;
|
|
||||||
ulong memsize;
|
|
||||||
} Mconf;
|
|
||||||
extern Mconf mconf;
|
|
||||||
|
|
|
@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 };
|
||||||
|
|
||||||
|
|
||||||
#include "portdat.h"
|
#include "portdat.h"
|
||||||
|
|
||||||
enum { MAXBANK = 2 };
|
|
||||||
|
|
||||||
typedef struct Mbank {
|
|
||||||
ulong base;
|
|
||||||
ulong limit;
|
|
||||||
} Mbank;
|
|
||||||
|
|
||||||
typedef struct Mconf {
|
|
||||||
Lock;
|
|
||||||
Mbank bank[MAXBANK];
|
|
||||||
int nbank;
|
|
||||||
ulong memsize;
|
|
||||||
} Mconf;
|
|
||||||
extern Mconf mconf;
|
|
||||||
|
|
|
@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 };
|
||||||
|
|
||||||
|
|
||||||
#include "portdat.h"
|
#include "portdat.h"
|
||||||
|
|
||||||
enum { MAXBANK = 2 };
|
|
||||||
|
|
||||||
typedef struct Mbank {
|
|
||||||
ulong base;
|
|
||||||
ulong limit;
|
|
||||||
} Mbank;
|
|
||||||
|
|
||||||
typedef struct Mconf {
|
|
||||||
Lock;
|
|
||||||
Mbank bank[MAXBANK];
|
|
||||||
int nbank;
|
|
||||||
ulong memsize;
|
|
||||||
} Mconf;
|
|
||||||
extern Mconf mconf;
|
|
||||||
|
|
|
@ -128,8 +128,6 @@ confinit(void)
|
||||||
{
|
{
|
||||||
conf.nmach = 1;
|
conf.nmach = 1;
|
||||||
|
|
||||||
conf.mem = meminit();
|
|
||||||
|
|
||||||
conf.nuid = 1000;
|
conf.nuid = 1000;
|
||||||
conf.nserve = 15; /* tunable */
|
conf.nserve = 15; /* tunable */
|
||||||
conf.nfile = 30000;
|
conf.nfile = 30000;
|
||||||
|
|
|
@ -1,6 +1,40 @@
|
||||||
#include "all.h"
|
#include "all.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
|
||||||
|
static ulong
|
||||||
|
memsize(void)
|
||||||
|
{
|
||||||
|
int nf, pgsize = 0;
|
||||||
|
ulong userpgs = 0, userused = 0;
|
||||||
|
char *ln, *sl;
|
||||||
|
char *fields[2];
|
||||||
|
Biobuf *bp;
|
||||||
|
|
||||||
|
bp = Bopen("#c/swap", OREAD);
|
||||||
|
if (bp != nil) {
|
||||||
|
while ((ln = Brdline(bp, '\n')) != nil) {
|
||||||
|
ln[Blinelen(bp)-1] = '\0';
|
||||||
|
nf = tokenize(ln, fields, nelem(fields));
|
||||||
|
if (nf != 2)
|
||||||
|
continue;
|
||||||
|
if (strcmp(fields[1], "pagesize") == 0)
|
||||||
|
pgsize = atoi(fields[0]);
|
||||||
|
else if (strcmp(fields[1], "user") == 0) {
|
||||||
|
sl = strchr(fields[0], '/');
|
||||||
|
if (sl == nil)
|
||||||
|
continue;
|
||||||
|
userpgs = atol(sl+1);
|
||||||
|
userused = atol(fields[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bterm(bp);
|
||||||
|
if (pgsize > 0 && userused > userpgs)
|
||||||
|
return (userpgs - userused)*pgsize;
|
||||||
|
}
|
||||||
|
return 64*MB;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
long niob;
|
long niob;
|
||||||
long nhiob;
|
long nhiob;
|
||||||
Hiob *hiob;
|
Hiob *hiob;
|
||||||
|
@ -17,27 +51,11 @@ ialloc(ulong n, int align)
|
||||||
|
|
||||||
if (p == nil)
|
if (p == nil)
|
||||||
panic("ialloc: out of memory");
|
panic("ialloc: out of memory");
|
||||||
|
setmalloctag(p, getcallerpc(&n));
|
||||||
memset(p, 0, n);
|
memset(p, 0, n);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
prbanks(void)
|
|
||||||
{
|
|
||||||
Mbank *mbp;
|
|
||||||
|
|
||||||
for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++)
|
|
||||||
print("bank[%ld]: base 0x%8.8lux, limit 0x%8.8lux (%.0fMB)\n",
|
|
||||||
mbp - mconf.bank, mbp->base, mbp->limit,
|
|
||||||
(mbp->limit - mbp->base)/(double)MB);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cmd_memory(int, char *[])
|
|
||||||
{
|
|
||||||
prbanks();
|
|
||||||
}
|
|
||||||
|
|
||||||
enum { HWIDTH = 8 }; /* buffers per hash */
|
enum { HWIDTH = 8 }; /* buffers per hash */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -52,18 +70,11 @@ iobufinit(void)
|
||||||
char *xiop;
|
char *xiop;
|
||||||
Iobuf *p, *q;
|
Iobuf *p, *q;
|
||||||
Hiob *hp;
|
Hiob *hp;
|
||||||
Mbank *mbp;
|
|
||||||
|
|
||||||
wlock(&mainlock); /* init */
|
wlock(&mainlock); /* init */
|
||||||
wunlock(&mainlock);
|
wunlock(&mainlock);
|
||||||
|
|
||||||
if(chatty)
|
m = memsize() / 4;
|
||||||
prbanks();
|
|
||||||
|
|
||||||
m = 0;
|
|
||||||
for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++)
|
|
||||||
m += mbp->limit - mbp->base;
|
|
||||||
|
|
||||||
niob = m / (sizeof(Iobuf) + RBUFSIZE + sizeof(Hiob)/HWIDTH);
|
niob = m / (sizeof(Iobuf) + RBUFSIZE + sizeof(Hiob)/HWIDTH);
|
||||||
nhiob = niob / HWIDTH;
|
nhiob = niob / HWIDTH;
|
||||||
while(!prime(nhiob))
|
while(!prime(nhiob))
|
||||||
|
@ -104,19 +115,6 @@ iobufinit(void)
|
||||||
p++;
|
p++;
|
||||||
xiop += RBUFSIZE;
|
xiop += RBUFSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure that no more of bank[0] can be used.
|
|
||||||
*/
|
|
||||||
mconf.bank[0].base = mconf.bank[0].limit;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++)
|
|
||||||
i += mbp->limit - mbp->base;
|
|
||||||
if(chatty)
|
|
||||||
print("\tmem left = %,d, out of %,ld\n", i, conf.mem);
|
|
||||||
/* paranoia: add this command as late as is easy */
|
|
||||||
cmd_install("memory", "-- print ranges of memory banks", cmd_memory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void*
|
void*
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
#include "all.h"
|
|
||||||
#include "io.h"
|
|
||||||
|
|
||||||
Mconf mconf;
|
|
||||||
|
|
||||||
static void
|
|
||||||
mconfinit(void)
|
|
||||||
{
|
|
||||||
int nf, pgsize = 0;
|
|
||||||
ulong size, userpgs = 0, userused = 0;
|
|
||||||
char *ln, *sl;
|
|
||||||
char *fields[2];
|
|
||||||
Biobuf *bp;
|
|
||||||
Mbank *mbp;
|
|
||||||
|
|
||||||
size = 64*MB;
|
|
||||||
bp = Bopen("#c/swap", OREAD);
|
|
||||||
if (bp != nil) {
|
|
||||||
while ((ln = Brdline(bp, '\n')) != nil) {
|
|
||||||
ln[Blinelen(bp)-1] = '\0';
|
|
||||||
nf = tokenize(ln, fields, nelem(fields));
|
|
||||||
if (nf != 2)
|
|
||||||
continue;
|
|
||||||
if (strcmp(fields[1], "pagesize") == 0)
|
|
||||||
pgsize = atoi(fields[0]);
|
|
||||||
else if (strcmp(fields[1], "user") == 0) {
|
|
||||||
sl = strchr(fields[0], '/');
|
|
||||||
if (sl == nil)
|
|
||||||
continue;
|
|
||||||
userpgs = atol(sl+1);
|
|
||||||
userused = atol(fields[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Bterm(bp);
|
|
||||||
if (pgsize > 0 && userpgs > 0)
|
|
||||||
size = (((userpgs - userused)*1LL)/4)*pgsize;
|
|
||||||
}
|
|
||||||
mconf.memsize = size;
|
|
||||||
mbp = mconf.bank;
|
|
||||||
mbp->base = 0x10000000; /* fake addresses */
|
|
||||||
mbp->limit = mbp->base + size;
|
|
||||||
mbp++;
|
|
||||||
|
|
||||||
mconf.nbank = mbp - mconf.bank;
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong
|
|
||||||
meminit(void)
|
|
||||||
{
|
|
||||||
conf.nmach = 1;
|
|
||||||
mconfinit();
|
|
||||||
return mconf.memsize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* based on libthread's threadsetname, but drags in less library code.
|
|
||||||
* actually just sets the arguments displayed.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
procsetname(char *fmt, ...)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
char *cmdname;
|
|
||||||
char buf[128];
|
|
||||||
va_list arg;
|
|
||||||
|
|
||||||
va_start(arg, fmt);
|
|
||||||
cmdname = vsmprint(fmt, arg);
|
|
||||||
va_end(arg);
|
|
||||||
if (cmdname == nil)
|
|
||||||
return;
|
|
||||||
snprint(buf, sizeof buf, "#p/%d/args", getpid());
|
|
||||||
if((fd = open(buf, OWRITE)) >= 0){
|
|
||||||
write(fd, cmdname, strlen(cmdname)+1);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
free(cmdname);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
newproc(void (*f)(void *), void *arg, char *text)
|
|
||||||
{
|
|
||||||
int kid = rfork(RFPROC|RFMEM|RFNOWAIT);
|
|
||||||
|
|
||||||
if (kid < 0)
|
|
||||||
sysfatal("can't fork: %r");
|
|
||||||
if (kid == 0) {
|
|
||||||
procsetname("%s", text);
|
|
||||||
(*f)(arg);
|
|
||||||
exits("child returned");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -415,7 +415,6 @@ struct Superb
|
||||||
struct Conf
|
struct Conf
|
||||||
{
|
{
|
||||||
ulong nmach; /* processors */
|
ulong nmach; /* processors */
|
||||||
ulong mem; /* total physical bytes of memory */
|
|
||||||
ulong nuid; /* distinct uids */
|
ulong nuid; /* distinct uids */
|
||||||
ulong nserve; /* server processes */
|
ulong nserve; /* server processes */
|
||||||
ulong nfile; /* number of fid -- system wide */
|
ulong nfile; /* number of fid -- system wide */
|
||||||
|
|
|
@ -131,7 +131,6 @@ void machinit(void);
|
||||||
Msgbuf* mballoc(int, Chan*, int);
|
Msgbuf* mballoc(int, Chan*, int);
|
||||||
void mbinit(void);
|
void mbinit(void);
|
||||||
void mbfree(Msgbuf*);
|
void mbfree(Msgbuf*);
|
||||||
ulong meminit(void);
|
|
||||||
Iobuf* movebuf(Iobuf*);
|
Iobuf* movebuf(Iobuf*);
|
||||||
void mcatinit(Device*);
|
void mcatinit(Device*);
|
||||||
int mcatread(Device*, Off, void*);
|
int mcatread(Device*, Off, void*);
|
||||||
|
|
|
@ -21,7 +21,7 @@ OFILES=\
|
||||||
malloc.$O\
|
malloc.$O\
|
||||||
mworm.$O\
|
mworm.$O\
|
||||||
net.$O\
|
net.$O\
|
||||||
pc.$O\
|
proc.$O\
|
||||||
scsi.$O\
|
scsi.$O\
|
||||||
sub.$O\
|
sub.$O\
|
||||||
time.$O\
|
time.$O\
|
||||||
|
|
41
sys/src/cmd/cwfs/proc.c
Normal file
41
sys/src/cmd/cwfs/proc.c
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#include "all.h"
|
||||||
|
#include "io.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* based on libthread's threadsetname, but drags in less library code.
|
||||||
|
* actually just sets the arguments displayed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
procsetname(char *fmt, ...)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
char *cmdname;
|
||||||
|
char buf[128];
|
||||||
|
va_list arg;
|
||||||
|
|
||||||
|
va_start(arg, fmt);
|
||||||
|
cmdname = vsmprint(fmt, arg);
|
||||||
|
va_end(arg);
|
||||||
|
if (cmdname == nil)
|
||||||
|
return;
|
||||||
|
snprint(buf, sizeof buf, "#p/%d/args", getpid());
|
||||||
|
if((fd = open(buf, OWRITE)) >= 0){
|
||||||
|
write(fd, cmdname, strlen(cmdname)+1);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
free(cmdname);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
newproc(void (*f)(void *), void *arg, char *text)
|
||||||
|
{
|
||||||
|
int kid = rfork(RFPROC|RFMEM|RFNOWAIT);
|
||||||
|
|
||||||
|
if (kid < 0)
|
||||||
|
sysfatal("can't fork: %r");
|
||||||
|
if (kid == 0) {
|
||||||
|
procsetname("%s", text);
|
||||||
|
(*f)(arg);
|
||||||
|
exits("child returned");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue