Removed all traces of `p_switchtime'. The relevant timestamp is per-cpu,

not per-process.  Keep it in `switchtime' consistently.

It is now clear that the timestamp is always valid in fork_trampoline()
except when the child is running on a previously idle cpu, which
can only happen if there are multiple cpus, so don't check or set
the timestamp in fork_trampoline except in the (i386) SMP case.
Just remove the alpha code for setting it unconditionally, since
there is no SMP case for alpha and the code had rotted.

Parts reviewed by:	dfr, phk
This commit is contained in:
Bruce Evans 1999-02-28 10:53:29 +00:00
parent 5419aa3ecf
commit e7ba67f274
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=44327
12 changed files with 40 additions and 68 deletions

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)genassym.c 5.11 (Berkeley) 5/10/91
* $Id: genassym.c,v 1.3 1998/07/12 16:08:15 dfr Exp $
* $Id: genassym.c,v 1.4 1998/11/15 18:25:15 dfr Exp $
*/
#include <sys/param.h>
@ -94,7 +94,6 @@ main()
OFF(P_WCHAN, struct proc, p_wchan);
OFF(P_FLAG, struct proc, p_flag);
OFF(P_PID, struct proc, p_pid);
OFF(P_SWITCHTIME, struct proc, p_switchtime);
OFF(P_RUNTIME, struct proc, p_runtime);
OFF(P_MD_FLAGS, struct proc, p_md.md_flags);
OFF(P_MD_PCBPADDR, struct proc, p_md.md_pcbpaddr);

View File

@ -1,4 +1,4 @@
/* $Id: swtch.s,v 1.6 1998/11/15 18:25:15 dfr Exp $ */
/* $Id: swtch.s,v 1.7 1998/12/02 10:24:56 dfr Exp $ */
/* $NetBSD: locore.s,v 1.47 1998/03/22 07:26:32 thorpej Exp $ */
/*
@ -265,11 +265,6 @@ Lcs7:
* pointer to the executing process's proc structure.
*/
LEAF(switch_trampoline, 0)
ldq a0, curproc
ldiq a1, P_SWITCHTIME
addq a0, a1, a0
CALL(microuptime)
mov s0, pv
mov s1, ra
mov s2, a0

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: exception.s,v 1.55 1998/08/10 19:41:07 bde Exp $
* $Id: exception.s,v 1.56 1999/02/25 11:03:08 bde Exp $
*/
#include "npx.h"
@ -312,23 +312,17 @@ IDTVEC(int0x80_syscall)
ENTRY(fork_trampoline)
call _spl0
movl _curproc,%eax
addl $P_SWITCHTIME,%eax
movl _switchtime,%ecx
testl %ecx,%ecx
#ifdef SMP
cmpl $0,_switchtime
jne 1f
/* XXX unreachable except in the SMP case? */
pushl %eax
pushl $_switchtime
call _microuptime
popl %eax
popl %edx
movl _ticks,%eax
movl %eax,_switchticks
jmp 2f
1:
movl %ecx,(%eax)
movl _switchtime+4,%edx
movl %edx,4(%eax)
2:
#endif
/*
* cpu_set_fork_handler intercepts this function call to

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: exception.s,v 1.55 1998/08/10 19:41:07 bde Exp $
* $Id: exception.s,v 1.56 1999/02/25 11:03:08 bde Exp $
*/
#include "npx.h"
@ -312,23 +312,17 @@ IDTVEC(int0x80_syscall)
ENTRY(fork_trampoline)
call _spl0
movl _curproc,%eax
addl $P_SWITCHTIME,%eax
movl _switchtime,%ecx
testl %ecx,%ecx
#ifdef SMP
cmpl $0,_switchtime
jne 1f
/* XXX unreachable except in the SMP case? */
pushl %eax
pushl $_switchtime
call _microuptime
popl %eax
popl %edx
movl _ticks,%eax
movl %eax,_switchticks
jmp 2f
1:
movl %ecx,(%eax)
movl _switchtime+4,%edx
movl %edx,4(%eax)
2:
#endif
/*
* cpu_set_fork_handler intercepts this function call to

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)genassym.c 5.11 (Berkeley) 5/10/91
* $Id: genassym.c,v 1.62 1998/10/08 21:03:41 msmith Exp $
* $Id: genassym.c,v 1.63 1999/02/22 15:13:34 bde Exp $
*/
#include "opt_vm86.h"
@ -92,7 +92,6 @@ main()
printf("#define\tP_WCHAN %#x\n", OS(proc, p_wchan));
printf("#define\tP_FLAG %#x\n", OS(proc, p_flag));
printf("#define\tP_PID %#x\n", OS(proc, p_pid));
printf("#define\tP_SWITCHTIME %#x\n", OS(proc, p_switchtime));
#ifdef SMP
printf("#define\tP_ONCPU %#x\n", OS(proc, p_oncpu));
printf("#define\tP_LASTCPU %#x\n", OS(proc, p_lastcpu));

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: exception.s,v 1.55 1998/08/10 19:41:07 bde Exp $
* $Id: exception.s,v 1.56 1999/02/25 11:03:08 bde Exp $
*/
#include "npx.h"
@ -312,23 +312,17 @@ IDTVEC(int0x80_syscall)
ENTRY(fork_trampoline)
call _spl0
movl _curproc,%eax
addl $P_SWITCHTIME,%eax
movl _switchtime,%ecx
testl %ecx,%ecx
#ifdef SMP
cmpl $0,_switchtime
jne 1f
/* XXX unreachable except in the SMP case? */
pushl %eax
pushl $_switchtime
call _microuptime
popl %eax
popl %edx
movl _ticks,%eax
movl %eax,_switchticks
jmp 2f
1:
movl %ecx,(%eax)
movl _switchtime+4,%edx
movl %edx,4(%eax)
2:
#endif
/*
* cpu_set_fork_handler intercepts this function call to

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)genassym.c 5.11 (Berkeley) 5/10/91
* $Id: genassym.c,v 1.62 1998/10/08 21:03:41 msmith Exp $
* $Id: genassym.c,v 1.63 1999/02/22 15:13:34 bde Exp $
*/
#include "opt_vm86.h"
@ -92,7 +92,6 @@ main()
printf("#define\tP_WCHAN %#x\n", OS(proc, p_wchan));
printf("#define\tP_FLAG %#x\n", OS(proc, p_flag));
printf("#define\tP_PID %#x\n", OS(proc, p_pid));
printf("#define\tP_SWITCHTIME %#x\n", OS(proc, p_switchtime));
#ifdef SMP
printf("#define\tP_ONCPU %#x\n", OS(proc, p_oncpu));
printf("#define\tP_LASTCPU %#x\n", OS(proc, p_lastcpu));

View File

@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* @(#)init_main.c 8.9 (Berkeley) 1/21/94
* $Id: init_main.c,v 1.109 1999/02/19 14:25:34 luoqi Exp $
* $Id: init_main.c,v 1.110 1999/02/25 11:03:08 bde Exp $
*/
#include "opt_devfs.h"
@ -495,7 +495,7 @@ proc0_post(dummy)
*/
microtime(&proc0.p_stats->p_start);
proc0.p_runtime = 0;
microuptime(&proc0.p_switchtime);
microuptime(&switchtime);
switchticks = ticks;
/*

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_resource.c 8.5 (Berkeley) 1/21/94
* $Id: kern_resource.c,v 1.40 1999/01/31 03:15:13 newton Exp $
* $Id: kern_resource.c,v 1.41 1999/02/25 11:03:08 bde Exp $
*/
#include "opt_compat.h"
@ -523,8 +523,8 @@ calcru(p, up, sp, ip)
* quantum, which is much greater than the sampling error.
*/
microuptime(&tv);
totusec += (tv.tv_usec - p->p_switchtime.tv_usec) +
(tv.tv_sec - p->p_switchtime.tv_sec) * (int64_t)1000000;
totusec += (tv.tv_usec - switchtime.tv_usec) +
(tv.tv_sec - switchtime.tv_sec) * (int64_t)1000000;
/*
* Copy the time that was just read to `switchtime' in case

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_synch.c 8.9 (Berkeley) 5/19/95
* $Id: kern_synch.c,v 1.72 1999/01/10 01:58:24 eivind Exp $
* $Id: kern_synch.c,v 1.73 1999/02/22 16:57:47 bde Exp $
*/
#include "opt_ktrace.h"
@ -769,6 +769,7 @@ wakeup_one(ident)
void
mi_switch()
{
struct timeval new_switchtime;
register struct proc *p = curproc; /* XXX */
register struct rlimit *rlim;
int x;
@ -800,9 +801,9 @@ mi_switch()
* Compute the amount of time during which the current
* process was running, and add that to its total so far.
*/
microuptime(&switchtime);
p->p_runtime += (switchtime.tv_usec - p->p_switchtime.tv_usec) +
(switchtime.tv_sec - p->p_switchtime.tv_sec) * (int64_t)1000000;
microuptime(&new_switchtime);
p->p_runtime += (new_switchtime.tv_usec - switchtime.tv_usec) +
(new_switchtime.tv_sec - switchtime.tv_sec) * (int64_t)1000000;
/*
* Check if the process exceeds its cpu resource allocation.
@ -826,11 +827,10 @@ mi_switch()
* Pick a new current process and record its start time.
*/
cnt.v_swtch++;
switchtime = new_switchtime;
cpu_switch(p);
if (switchtime.tv_sec)
p->p_switchtime = switchtime;
else
microuptime(&p->p_switchtime);
if (switchtime.tv_sec == 0)
microuptime(&switchtime);
switchticks = ticks;
splx(x);

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)genassym.c 5.11 (Berkeley) 5/10/91
* $Id: genassym.c,v 1.3 1998/07/12 16:08:15 dfr Exp $
* $Id: genassym.c,v 1.4 1998/11/15 18:25:15 dfr Exp $
*/
#include <sys/param.h>
@ -94,7 +94,6 @@ main()
OFF(P_WCHAN, struct proc, p_wchan);
OFF(P_FLAG, struct proc, p_flag);
OFF(P_PID, struct proc, p_pid);
OFF(P_SWITCHTIME, struct proc, p_switchtime);
OFF(P_RUNTIME, struct proc, p_runtime);
OFF(P_MD_FLAGS, struct proc, p_md.md_flags);
OFF(P_MD_PCBPADDR, struct proc, p_md.md_pcbpaddr);

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)proc.h 8.15 (Berkeley) 5/19/95
* $Id: proc.h,v 1.70 1999/02/22 16:57:48 bde Exp $
* $Id: proc.h,v 1.71 1999/02/25 14:28:46 newton Exp $
*/
#ifndef _SYS_PROC_H_
@ -159,7 +159,6 @@ struct proc {
struct itimerval p_realtimer; /* Alarm timer. */
u_int64_t p_runtime; /* Real time in microsec. */
struct timeval p_switchtime; /* When last scheduled */
u_quad_t p_uticks; /* Statclock hits in user mode. */
u_quad_t p_sticks; /* Statclock hits in system mode. */
u_quad_t p_iticks; /* Statclock hits processing intr. */