Fixed profiling of system times.  It was pre-4.4Lite and didn't support
statclocks.  System times were too small by a factor of 8.

Handle deferred profiling ticks the 4.4Lite way: use addupc_task() instead
of addupc().  Call addupc_task() directly instead of using the ADDUPC()
macro.

Removed vestigial support for PROFTIMER.

switch.s:
Removed addupc().

resourcevar.h:
Removed ADDUPC() and declarations of addupc().

cpu.h:
Updated a comment.  i386's never were tahoe's, and the deferred profiling
tick became (possibly) multiple ticks in 4.4Lite.

Obtained from:	mostly from NetBSD
This commit is contained in:
Bruce Evans 1996-06-25 20:02:16 +00:00
parent 93f4b1bf1b
commit 79df6d8597
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=16725
9 changed files with 34 additions and 189 deletions

View file

@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: swtch.s,v 1.35 1996/05/01 03:46:15 bde Exp $
* $Id: swtch.s,v 1.36 1996/06/25 19:25:25 bde Exp $
*/
#include "apm.h"
@ -519,46 +519,3 @@ ENTRY(savectx)
1:
ret
/*
* addupc(int pc, struct uprof *up, int ticks):
* update profiling information for the user process.
*/
ENTRY(addupc)
pushl %ebp
movl %esp,%ebp
movl 12(%ebp),%edx /* up */
movl 8(%ebp),%eax /* pc */
subl PR_OFF(%edx),%eax /* pc -= up->pr_off */
jb L1 /* if (pc was < off) return */
pushl %edx
mull PR_SCALE(%edx) /* praddr = pc * up->pr_scale */
shrdl $16,%edx,%eax /* praddr >>= 16 */
popl %edx
andl $-2,%eax /* praddr &= ~1 */
cmpl PR_SIZE(%edx),%eax /* if (praddr > up->pr_size) return */
ja L1
/* addl %eax,%eax /* praddr -> word offset */
addl PR_BASE(%edx),%eax /* praddr += up-> pr_base */
movl 16(%ebp),%ecx /* ticks */
movl _curpcb,%edx
movl $proffault,PCB_ONFAULT(%edx)
addl %ecx,(%eax) /* storage location += ticks */
movl $0,PCB_ONFAULT(%edx)
L1:
leave
ret
ALIGN_TEXT
proffault:
/* if we get a fault, then kill profiling all together */
movl $0,PCB_ONFAULT(%edx) /* squish the fault handler */
movl 12(%ebp),%ecx
movl $0,PR_SCALE(%ecx) /* up->pr_scale = 0 */
leave
ret

View file

@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: swtch.s,v 1.35 1996/05/01 03:46:15 bde Exp $
* $Id: swtch.s,v 1.36 1996/06/25 19:25:25 bde Exp $
*/
#include "apm.h"
@ -519,46 +519,3 @@ ENTRY(savectx)
1:
ret
/*
* addupc(int pc, struct uprof *up, int ticks):
* update profiling information for the user process.
*/
ENTRY(addupc)
pushl %ebp
movl %esp,%ebp
movl 12(%ebp),%edx /* up */
movl 8(%ebp),%eax /* pc */
subl PR_OFF(%edx),%eax /* pc -= up->pr_off */
jb L1 /* if (pc was < off) return */
pushl %edx
mull PR_SCALE(%edx) /* praddr = pc * up->pr_scale */
shrdl $16,%edx,%eax /* praddr >>= 16 */
popl %edx
andl $-2,%eax /* praddr &= ~1 */
cmpl PR_SIZE(%edx),%eax /* if (praddr > up->pr_size) return */
ja L1
/* addl %eax,%eax /* praddr -> word offset */
addl PR_BASE(%edx),%eax /* praddr += up-> pr_base */
movl 16(%ebp),%ecx /* ticks */
movl _curpcb,%edx
movl $proffault,PCB_ONFAULT(%edx)
addl %ecx,(%eax) /* storage location += ticks */
movl $0,PCB_ONFAULT(%edx)
L1:
leave
ret
ALIGN_TEXT
proffault:
/* if we get a fault, then kill profiling all together */
movl $0,PCB_ONFAULT(%edx) /* squish the fault handler */
movl 12(%ebp),%ecx
movl $0,PR_SCALE(%ecx) /* up->pr_scale = 0 */
leave
ret

View file

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
* $Id: trap.c,v 1.77 1996/06/12 05:02:54 gpalmer Exp $
* $Id: trap.c,v 1.78 1996/06/13 07:17:21 asami Exp $
*/
/*
@ -163,19 +163,10 @@ userret(p, frame, oticks)
/*
* Charge system time if profiling.
*/
if (p->p_flag & P_PROFIL) {
u_quad_t ticks = p->p_sticks - oticks;
if (p->p_flag & P_PROFIL)
addupc_task(p, frame->tf_eip,
(u_int)(p->p_sticks - oticks) * psratio);
if (ticks) {
#ifdef PROFTIMER
extern int profscale;
addupc(frame->tf_eip, &p->p_stats->p_prof,
ticks * profscale);
#else
addupc(frame->tf_eip, &p->p_stats->p_prof, ticks);
#endif
}
}
curpriority = p->p_priority;
}
@ -227,8 +218,9 @@ trap(frame)
astoff();
cnt.v_soft++;
if (p->p_flag & P_OWEUPC) {
addupc(frame.tf_eip, &p->p_stats->p_prof, 1);
p->p_flag &= ~P_OWEUPC;
addupc_task(p, p->p_stats->p_prof.pr_addr,
p->p_stats->p_prof.pr_ticks);
}
goto out;

View file

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)cpu.h 5.4 (Berkeley) 5/9/91
* $Id: cpu.h,v 1.23 1996/04/05 03:36:23 ache Exp $
* $Id: cpu.h,v 1.24 1996/04/07 16:44:28 bde Exp $
*/
#ifndef _MACHINE_CPU_H_
@ -83,9 +83,11 @@
#define need_resched() { want_resched = 1; aston(); }
/*
* Give a profiling tick to the current process from the softclock
* interrupt. On tahoe, request an ast to send us through trap(),
* marking the proc as needing a profiling tick.
* Arrange to handle pending profiling ticks before returning to user mode.
*
* XXX this is now poorly named and implemented. It used to handle only a
* single tick and the P_OWEUPC flag served as a counter. Now there is a
* counter in the proc table and flag isn't really necessary.
*/
#define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); }

View file

@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: swtch.s,v 1.35 1996/05/01 03:46:15 bde Exp $
* $Id: swtch.s,v 1.36 1996/06/25 19:25:25 bde Exp $
*/
#include "apm.h"
@ -519,46 +519,3 @@ ENTRY(savectx)
1:
ret
/*
* addupc(int pc, struct uprof *up, int ticks):
* update profiling information for the user process.
*/
ENTRY(addupc)
pushl %ebp
movl %esp,%ebp
movl 12(%ebp),%edx /* up */
movl 8(%ebp),%eax /* pc */
subl PR_OFF(%edx),%eax /* pc -= up->pr_off */
jb L1 /* if (pc was < off) return */
pushl %edx
mull PR_SCALE(%edx) /* praddr = pc * up->pr_scale */
shrdl $16,%edx,%eax /* praddr >>= 16 */
popl %edx
andl $-2,%eax /* praddr &= ~1 */
cmpl PR_SIZE(%edx),%eax /* if (praddr > up->pr_size) return */
ja L1
/* addl %eax,%eax /* praddr -> word offset */
addl PR_BASE(%edx),%eax /* praddr += up-> pr_base */
movl 16(%ebp),%ecx /* ticks */
movl _curpcb,%edx
movl $proffault,PCB_ONFAULT(%edx)
addl %ecx,(%eax) /* storage location += ticks */
movl $0,PCB_ONFAULT(%edx)
L1:
leave
ret
ALIGN_TEXT
proffault:
/* if we get a fault, then kill profiling all together */
movl $0,PCB_ONFAULT(%edx) /* squish the fault handler */
movl 12(%ebp),%ecx
movl $0,PR_SCALE(%ecx) /* up->pr_scale = 0 */
leave
ret

View file

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
* $Id: trap.c,v 1.77 1996/06/12 05:02:54 gpalmer Exp $
* $Id: trap.c,v 1.78 1996/06/13 07:17:21 asami Exp $
*/
/*
@ -163,19 +163,10 @@ userret(p, frame, oticks)
/*
* Charge system time if profiling.
*/
if (p->p_flag & P_PROFIL) {
u_quad_t ticks = p->p_sticks - oticks;
if (p->p_flag & P_PROFIL)
addupc_task(p, frame->tf_eip,
(u_int)(p->p_sticks - oticks) * psratio);
if (ticks) {
#ifdef PROFTIMER
extern int profscale;
addupc(frame->tf_eip, &p->p_stats->p_prof,
ticks * profscale);
#else
addupc(frame->tf_eip, &p->p_stats->p_prof, ticks);
#endif
}
}
curpriority = p->p_priority;
}
@ -227,8 +218,9 @@ trap(frame)
astoff();
cnt.v_soft++;
if (p->p_flag & P_OWEUPC) {
addupc(frame.tf_eip, &p->p_stats->p_prof, 1);
p->p_flag &= ~P_OWEUPC;
addupc_task(p, p->p_stats->p_prof.pr_addr,
p->p_stats->p_prof.pr_ticks);
}
goto out;

View file

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)cpu.h 5.4 (Berkeley) 5/9/91
* $Id: cpu.h,v 1.23 1996/04/05 03:36:23 ache Exp $
* $Id: cpu.h,v 1.24 1996/04/07 16:44:28 bde Exp $
*/
#ifndef _MACHINE_CPU_H_
@ -83,9 +83,11 @@
#define need_resched() { want_resched = 1; aston(); }
/*
* Give a profiling tick to the current process from the softclock
* interrupt. On tahoe, request an ast to send us through trap(),
* marking the proc as needing a profiling tick.
* Arrange to handle pending profiling ticks before returning to user mode.
*
* XXX this is now poorly named and implemented. It used to handle only a
* single tick and the P_OWEUPC flag served as a counter. Now there is a
* counter in the proc table and flag isn't really necessary.
*/
#define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); }

View file

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
* $Id: trap.c,v 1.77 1996/06/12 05:02:54 gpalmer Exp $
* $Id: trap.c,v 1.78 1996/06/13 07:17:21 asami Exp $
*/
/*
@ -163,19 +163,10 @@ userret(p, frame, oticks)
/*
* Charge system time if profiling.
*/
if (p->p_flag & P_PROFIL) {
u_quad_t ticks = p->p_sticks - oticks;
if (p->p_flag & P_PROFIL)
addupc_task(p, frame->tf_eip,
(u_int)(p->p_sticks - oticks) * psratio);
if (ticks) {
#ifdef PROFTIMER
extern int profscale;
addupc(frame->tf_eip, &p->p_stats->p_prof,
ticks * profscale);
#else
addupc(frame->tf_eip, &p->p_stats->p_prof, ticks);
#endif
}
}
curpriority = p->p_priority;
}
@ -227,8 +218,9 @@ trap(frame)
astoff();
cnt.v_soft++;
if (p->p_flag & P_OWEUPC) {
addupc(frame.tf_eip, &p->p_stats->p_prof, 1);
p->p_flag &= ~P_OWEUPC;
addupc_task(p, p->p_stats->p_prof.pr_addr,
p->p_stats->p_prof.pr_ticks);
}
goto out;

View file

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)resourcevar.h 8.4 (Berkeley) 1/9/95
* $Id: resourcevar.h,v 1.7 1996/02/25 07:23:03 hsu Exp $
* $Id: resourcevar.h,v 1.7 1996/03/11 02:20:13 hsu Exp $
*/
#ifndef _SYS_RESOURCEVAR_H_
@ -77,13 +77,7 @@ struct plimit {
int p_refcnt; /* number of references */
};
/* add user profiling from AST */
#define ADDUPROF(p) \
addupc_task(p, \
(p)->p_stats->p_prof.pr_addr, (p)->p_stats->p_prof.pr_ticks)
#ifdef KERNEL
int addupc __P((int pc, struct uprof *up, int ticks));
void addupc_intr __P((struct proc *p, u_long pc, u_int ticks));
void addupc_task __P((struct proc *p, u_long pc, u_int ticks));
void calcru __P((struct proc *p, struct timeval *up, struct timeval *sp,