Browse Source

Plan 9 from Bell Labs 2004-01-23

David du Colombier 17 years ago
parent
commit
ec16657c3a

+ 12 - 12
dist/replica/plan9.db

@@ -143,7 +143,7 @@
 386/bin/aux/searchfs - 775 sys sys 1064598087 90729
 386/bin/aux/sprog - 775 sys sys 1064598088 77816
 386/bin/aux/ssh_genkey - 775 sys sys 1045537957 194629
-386/bin/aux/sshserve - 775 sys sys 1069592362 251177
+386/bin/aux/sshserve - 775 sys sys 1074752196 251439
 386/bin/aux/stub - 775 sys sys 1064598090 136225
 386/bin/aux/tcpostio - 775 sys sys 1071245296 199664
 386/bin/aux/text2post - 775 sys sys 1064598091 77005
@@ -3053,7 +3053,6 @@ rc/bin/service.auth/authsrv.il566 - 775 sys sys 1016832549 34
 rc/bin/service.auth/authsrv.tcp567 - 775 sys sys 1016832561 34
 rc/bin/service.auth/tcp110 - 775 sys sys 1016832647 85
 rc/bin/service.auth/tcp22 - 775 sys sys 1016832620 87
-rc/bin/service.auth/tcp993 - 775 sys sys 1018720071 151
 rc/bin/service.auth/tcp995 - 775 sys sys 1030586935 128
 rc/bin/service/_il17007 - 775 sys sys 1016832393 82
 rc/bin/service/_il17008 - 775 sys sys 945617221 32
@@ -3078,6 +3077,7 @@ rc/bin/service/tcp53 - 775 sys sys 945617223 29
 rc/bin/service/tcp565 - 775 sys sys 945617223 212
 rc/bin/service/tcp7 - 775 sys sys 945617224 19
 rc/bin/service/tcp9 - 775 sys sys 945617224 26
+rc/bin/service/tcp993 - 775 sys sys 1018720071 151
 rc/bin/service/telcodata - 775 sys sys 945617224 95
 rc/bin/service/telcofax - 775 sys sys 945617224 93
 rc/bin/sig - 775 sys sys 1059490402 491
@@ -3422,7 +3422,7 @@ sys/include/stdio.h - 664 sys sys 1055700381 4199
 sys/include/sunrpc.h - 664 sys sys 1046367129 7219
 sys/include/thread.h - 664 sys sys 1045504289 3562
 sys/include/tos.h - 664 sys sys 1067718947 562
-sys/include/trace.h - 664 sys sys 1068393680 585
+sys/include/trace.h - 664 sys sys 1074827800 647
 sys/include/venti.h - 664 sys sys 1072705708 7049
 sys/lib - 20000000775 sys sys 1018580948 0
 sys/lib/acid - 20000000775 sys sys 1016926088 0
@@ -4904,7 +4904,7 @@ sys/man/3/mnt - 664 sys sys 944959698 1994
 sys/man/3/mouse - 664 sys sys 1020313480 4276
 sys/man/3/pipe - 664 sys sys 1032640674 1145
 sys/man/3/pnp - 664 sys sys 1019864752 4645
-sys/man/3/proc - 664 sys sys 1069706068 11896
+sys/man/3/proc - 664 sys sys 1074785156 12026
 sys/man/3/root - 664 sys sys 1046958450 632
 sys/man/3/rtc - 664 sys sys 954378857 667
 sys/man/3/sd - 664 sys sys 1018386776 4805
@@ -5277,7 +5277,7 @@ sys/src/9/pc/archmp.c - 664 sys sys 1067722683 2323
 sys/src/9/pc/audio.h - 664 sys sys 1015014513 343
 sys/src/9/pc/cga.c - 664 sys sys 1015014513 1843
 sys/src/9/pc/dat.h - 664 sys sys 1071245548 6177
-sys/src/9/pc/devarch.c - 664 sys sys 1074350950 18361
+sys/src/9/pc/devarch.c - 664 sys sys 1074785125 18549
 sys/src/9/pc/devether.c - 664 sys sys 1048644042 10178
 sys/src/9/pc/devfloppy.c - 664 sys sys 1055689885 20024
 sys/src/9/pc/devi82365.c - 664 sys sys 1020284820 19987
@@ -5304,7 +5304,7 @@ sys/src/9/pc/ether8390.c - 664 sys sys 1071245462 17557
 sys/src/9/pc/ether8390.h - 664 sys sys 1015014517 1511
 sys/src/9/pc/etherec2t.c - 664 sys sys 1020284820 4038
 sys/src/9/pc/etherelnk3.c - 664 sys sys 1071515332 48521
-sys/src/9/pc/etherga620.c - 664 sys sys 1067723192 28788
+sys/src/9/pc/etherga620.c - 664 sys sys 1074785126 28754
 sys/src/9/pc/etherga620fw.h - 644 sys sys 1026847642 222295
 sys/src/9/pc/etherif.h - 664 sys sys 1045063564 961
 sys/src/9/pc/etherigbe.c - 664 sys sys 1071245461 42444
@@ -5315,16 +5315,16 @@ sys/src/9/pc/ethersink.c - 664 sys sys 1048644103 1076
 sys/src/9/pc/ethersmc.c - 664 sys sys 1071245461 15103
 sys/src/9/pc/etherwavelan.c - 664 sys sys 1026847642 3722
 sys/src/9/pc/floppy.h - 664 sys sys 1055700609 3835
-sys/src/9/pc/fns.h - 664 sys sys 1071514801 4296
+sys/src/9/pc/fns.h - 664 sys sys 1074785127 4299
 sys/src/9/pc/hcwAMC.h - 664 sys sys 1026860163 166004
-sys/src/9/pc/i8253.c - 664 sys sys 1071245560 6251
+sys/src/9/pc/i8253.c - 664 sys sys 1074785126 6179
 sys/src/9/pc/i8259.c - 664 sys sys 1015014519 4423
 sys/src/9/pc/init9.c - 664 sys sys 1040002518 94
 sys/src/9/pc/initcode.s - 664 sys sys 1015014519 282
 sys/src/9/pc/io.h - 664 sys sys 1072972600 8023
 sys/src/9/pc/kbd.c - 664 sys sys 1071726245 9135
-sys/src/9/pc/l.s - 664 sys sys 1072704796 22700
-sys/src/9/pc/main.c - 664 sys sys 1072704797 14685
+sys/src/9/pc/l.s - 664 sys sys 1074785126 22699
+sys/src/9/pc/main.c - 664 sys sys 1074785126 14644
 sys/src/9/pc/mem.h - 664 sys sys 1018553448 4573
 sys/src/9/pc/memory.c - 664 sys sys 1071245460 13028
 sys/src/9/pc/mkfile - 664 sys sys 1067810339 3219
@@ -5359,7 +5359,7 @@ sys/src/9/pc/sd53c8xx.n - 664 sys sys 1032059019 12455
 sys/src/9/pc/sdata.c - 664 sys sys 1071615236 50538
 sys/src/9/pc/sdmylex.c - 664 sys sys 1071245460 27812
 sys/src/9/pc/sdscsi.c - 664 sys sys 1055689892 7406
-sys/src/9/pc/trap.c - 664 sys sys 1072704797 20506
+sys/src/9/pc/trap.c - 664 sys sys 1074785126 20668
 sys/src/9/pc/uarti8250.c - 664 sys sys 1067722686 13859
 sys/src/9/pc/uartpci.c - 664 sys sys 1015014524 2709
 sys/src/9/pc/usb.h - 664 sys sys 1063857246 3566
@@ -5416,7 +5416,7 @@ sys/src/9/port/devmouse.c - 664 sys sys 1067722758 12203
 sys/src/9/port/devnmouse.c - 664 sys sys 1036812999 3738
 sys/src/9/port/devpipe.c - 664 sys sys 1032640439 5825
 sys/src/9/port/devpnp.c - 664 sys sys 1055688361 13021
-sys/src/9/port/devproc.c - 664 sys sys 1068393158 28387
+sys/src/9/port/devproc.c - 664 sys sys 1074785145 28636
 sys/src/9/port/devrealtime.c - 664 sys sys 1055688366 16209
 sys/src/9/port/devroot.c - 664 sys sys 1067722764 4254
 sys/src/9/port/devsd.c - 664 sys sys 1071245428 28564

+ 13 - 0
dist/replica/plan9.log

@@ -13423,3 +13423,16 @@
 1074731557 0 a rc/bin/uptime - 775 sys sys 1074730712 234
 1074731557 1 c sys/src/cmd/ssh/authsrvtis.c - 664 sys sys 1074731315 928
 1074735156 0 a sys/man/1/uptime - 664 sys sys 1074733782 380
+1074753160 0 c 386/bin/aux/sshserve - 775 sys sys 1074752196 251439
+1074785563 0 c sys/man/3/proc - 664 sys sys 1074785156 12026
+1074785563 1 c sys/src/9/pc/devarch.c - 664 sys sys 1074785125 18549
+1074785563 2 c sys/src/9/pc/fns.h - 664 sys sys 1074785127 4299
+1074785563 3 c sys/src/9/pc/i8253.c - 664 sys sys 1074785126 6179
+1074785563 4 c sys/src/9/pc/l.s - 664 sys sys 1074785126 22699
+1074785563 5 c sys/src/9/pc/main.c - 664 sys sys 1074785126 14644
+1074785563 6 c sys/src/9/pc/trap.c - 664 sys sys 1074785126 20668
+1074785563 7 c sys/src/9/pc/etherga620.c - 664 sys sys 1074785126 28754
+1074785563 8 c sys/src/9/port/devproc.c - 664 sys sys 1074785145 28636
+1074801767 0 a rc/bin/service/tcp993 - 775 sys sys 1018720071 151
+1074801767 1 d rc/bin/service.auth/tcp993 - 775 sys sys 1018720071 0
+1074828772 0 c sys/include/trace.h - 664 sys sys 1074827800 647

+ 0 - 0
rc/bin/service.auth/tcp993 → rc/bin/service/tcp993


+ 4 - 2
sys/include/trace.h

@@ -1,5 +1,5 @@
 typedef enum Tevent {
-	SAdmit,		/* Edf admit */
+	SAdmit = 0,	/* Edf admit */
 	SRelease,	/* Edf release, waiting to be scheduled */
 	SEdf,		/* running under EDF */
 	SRun,		/* running best effort */
@@ -10,6 +10,8 @@ typedef enum Tevent {
 	SDeadline,	/* proc's deadline */
 	SExpel,		/* Edf expel */
 	SDead,		/* proc dies */
+	SInts,		/* Interrupt start */
+	SInte,		/* Interrupt end */
 	SUser,		/* user event */
 	Nevent,
 } Tevent;
@@ -17,6 +19,6 @@ typedef enum Tevent {
 typedef struct Traceevent	Traceevent;
 struct Traceevent {
 	ulong	pid;	
-	Tevent	etype;		/* Event type */
+	ulong	etype;		/* Event type */
 	vlong	time;		/* time stamp (ns)  */
 };

+ 3 - 1
sys/man/3/proc

@@ -270,9 +270,11 @@ Wire the process to processor
 .IR n .
 .TP 10n
 .B trace
-Toggle trace event generation for this process into
+Without an argument, toggle trace event generation for this process into
 .B /proc/trace
 (see below).
+With a zero argument, tracing for the proc is turned off, with a non-zero numeric
+argument, it is turned on.
 .TP 10n
 .B "period\ \fInu
 Set the real-time scheduling period of the process to

+ 11 - 0
sys/src/9/pc/devarch.c

@@ -621,6 +621,16 @@ static X86type x86sis[] =
 
 static X86type *cputype;
 
+static void	simplecycles(uvlong*);
+void	(*cycles)(uvlong*) = simplecycles;
+void	_cycles(uvlong*);	/* in l.s */
+
+static void
+simplecycles(uvlong*x)
+{
+	*x = m->ticks;
+}
+
 void
 cpuidprint(void)
 {
@@ -680,6 +690,7 @@ cpuidentify(void)
 	 */
 	if(m->cpuiddx & 0x10){
 		m->havetsc = 1;
+		cycles = _cycles;
 		if(m->cpuiddx & 0x20)
 			wrmsr(0x10, 0);
 	}

+ 2 - 4
sys/src/9/pc/etherga620.c

@@ -627,8 +627,7 @@ ga620interrupt(Ureg*, void* arg)
 
 	if(!(csr32r(ctlr, Mhc) & Is))
 		return;
-	if(m->havetsc)
-		cycles(&tsc0);
+	cycles(&tsc0);
 
 	ctlr->interrupts++;
 	csr32w(ctlr, Hi, 1);
@@ -660,8 +659,7 @@ ga620interrupt(Ureg*, void* arg)
 		work = 0;
 	}
 
-	if(m->havetsc)
-		cycles(&tsc1);
+	cycles(&tsc1);
 	ctlr->ticks += tsc1-tsc0;
 }
 

+ 1 - 1
sys/src/9/pc/fns.h

@@ -13,7 +13,7 @@ void	(*coherence)(void);
 void	cpuid(char*, int*, int*);
 int	cpuidentify(void);
 void	cpuidprint(void);
-void	cycles(uvlong*);
+void	(*cycles)(uvlong*);
 void	delay(int);
 int	dmacount(int);
 int	dmadone(int);

+ 2 - 6
sys/src/9/pc/i8253.c

@@ -140,14 +140,12 @@ guesscpuhz(int aalcycles)
 		 *
 		 */
 		outb(Tmode, Latch0);
-		if(m->havetsc)
-			cycles(&a);
+		cycles(&a);
 		x = inb(T0cntr);
 		x |= inb(T0cntr)<<8;
 		aamloop(loops);
 		outb(Tmode, Latch0);
-		if(m->havetsc)
-			cycles(&b);
+		cycles(&b);
 		y = inb(T0cntr);
 		y |= inb(T0cntr)<<8;
 		x -= y;
@@ -305,8 +303,6 @@ perfticks(void)
 {
 	uvlong x;
 
-	if(!m->havetsc)
-		return m->ticks;
 	cycles(&x);
 	return x;
 }

+ 2 - 2
sys/src/9/pc/l.s

@@ -329,9 +329,9 @@ TEXT putcr4(SB), $0
 	MOVL	AX, CR4
 	RET
 
-TEXT cycles(SB), $0				/* time stamp counter; cycles since power up */
+TEXT _cycles(SB), $0			/* time stamp counter; cycles since power up */
 	RDTSC
-	MOVL	vlong+0(FP), CX			/* &vlong */
+	MOVL	vlong+0(FP), CX		/* &vlong */
 	MOVL	AX, 0(CX)			/* lo */
 	MOVL	DX, 4(CX)			/* hi */
 	RET

+ 3 - 5
sys/src/9/pc/main.c

@@ -559,7 +559,7 @@ procrestore(Proc *p)
 {
 	uvlong t;
 
-	if(p->kp || m->havetsc == 0)
+	if(p->kp)
 		return;
 	cycles(&t);
 	p->pcycles -= t;
@@ -573,10 +573,8 @@ procsave(Proc *p)
 {
 	uvlong t;
 
-	if(m->havetsc){
-		cycles(&t);
-		p->pcycles += t;
-	}
+	cycles(&t);
+	p->pcycles += t;
 	if(p->fpstate == FPactive){
 		if(p->state == Moribund)
 			fpoff();

+ 13 - 8
sys/src/9/pc/trap.c

@@ -7,6 +7,7 @@
 #include	"io.h"
 #include	"ureg.h"
 #include	"../port/error.h"
+#include	<trace.h>
 
 void	noted(Ureg*, ulong);
 
@@ -284,10 +285,8 @@ kexit(Ureg*)
 
 	/* precise time accounting, kernel exit */
 	tos = (Tos*)(USTKTOP-sizeof(Tos));
-	if(m->havetsc){
-		cycles(&t);
-		tos->kcycles += t - up->kentry;
-	}
+	cycles(&t);
+	tos->kcycles += t - up->kentry;
 	tos->pcycles = up->pcycles;
 	tos->pid = up->pid;
 }
@@ -306,18 +305,21 @@ trap(Ureg* ureg)
 	char buf[ERRMAX];
 	Vctl *ctl, *v;
 	Mach *mach;
+	void (*pt)(Proc*, int, vlong);
 
 	m->perf.intrts = perfticks();
 	user = (ureg->cs & 0xFFFF) == UESEL;
 	if(user){
 		up->dbgreg = ureg;
-		if(m->havetsc)
-			cycles(&up->kentry);
+		cycles(&up->kentry);
 	}
 
 	vno = ureg->trap;
 	if(ctl = vctl[vno]){
 		if(ctl->isintr){
+			pt = proctrace;
+			if(up && up->trace && pt)
+				pt(up, (vno << 16) | SInts, 0);
 			m->intr++;
 			if(vno >= VectorPIC && vno != VectorSYSCALL)
 				m->lastintr = ctl->irq;
@@ -334,6 +336,10 @@ trap(Ureg* ureg)
 
 		if(ctl->isintr){
 			intrtime(m, vno);
+			pt = proctrace;
+			if(up && up->trace && pt)
+				pt(up, (vno << 16) | SInte, 0);
+
 			if(up && ctl->irq != IrqTIMER && ctl->irq != IrqCLOCK)
 				preempted();
 		}
@@ -611,8 +617,7 @@ syscall(Ureg* ureg)
 	if((ureg->cs & 0xFFFF) != UESEL)
 		panic("syscall: cs 0x%4.4luX\n", ureg->cs);
 
-	if (m->havetsc)
-		cycles(&up->kentry);
+	cycles(&up->kentry);
 
 	m->syscall++;
 	up->insyscall = 1;

+ 18 - 2
sys/src/9/port/devproc.c

@@ -60,6 +60,7 @@ enum
 	CMsporadic,
 	CMdeadlinenotes,
 	CMadmit,
+	CMextra,
 	CMexpel,
 };
 
@@ -115,13 +116,14 @@ Cmdtab proccmd[] = {
 	CMwired,		"wired",		2,
 	CMfair,			"fair",			1,
 	CMunfair,		"unfair",		1,
-	CMtrace,		"trace",		1,
+	CMtrace,		"trace",		0,
 	CMperiod,		"period",		2,
 	CMdeadline,		"deadline",		2,
 	CMcost,			"cost",			2,
 	CMsporadic,		"sporadic",		1,
 	CMdeadlinenotes,	"deadlinenotes",	1,
 	CMadmit,		"admit",		1,
+	CMextra,		"extra",		1,
 	CMexpel,		"expel",		1,
 };
 
@@ -1388,7 +1390,16 @@ procctlreq(Proc *p, char *va, int n)
 		procwired(p, atoi(cb->f[1]));
 		break;
 	case CMtrace:
-		p->trace ^= 1;
+		switch(cb->nf){
+		case 1:
+			p->trace ^= 1;
+			break;
+		case 2:
+			p->trace = atoi(cb->f[1])?1:0;
+			break;
+		default:
+			error("args");
+		}
 		break;
 	/* real time */
 	case CMperiod:
@@ -1431,6 +1442,11 @@ procctlreq(Proc *p, char *va, int n)
 		if(e = edfadmit(p))
 			error(e);
 		break;
+	case CMextra:
+		if(p->edf == nil)
+			edfinit(p);
+		p->edf->flags |= Extratime;
+		break;
 	case CMexpel:
 		if(p->edf)
 			edfstop(p);