summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1996-06-25 20:02:16 +0000
committerbde <bde@FreeBSD.org>1996-06-25 20:02:16 +0000
commitb78ec1326fea8cfb976e7abdf10620439850a0a0 (patch)
treec03e6b6eda5a905cdc18da08c49cfe58e6af2c5b /sys
parent3d80cb8e5e226da61878d59c56b97b2aca43c535 (diff)
downloadFreeBSD-src-b78ec1326fea8cfb976e7abdf10620439850a0a0.zip
FreeBSD-src-b78ec1326fea8cfb976e7abdf10620439850a0a0.tar.gz
trap.c:
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
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/cpu_switch.S45
-rw-r--r--sys/amd64/amd64/swtch.s45
-rw-r--r--sys/amd64/amd64/trap.c22
-rw-r--r--sys/amd64/include/cpu.h10
-rw-r--r--sys/i386/i386/swtch.s45
-rw-r--r--sys/i386/i386/trap.c22
-rw-r--r--sys/i386/include/cpu.h10
-rw-r--r--sys/kern/subr_trap.c22
-rw-r--r--sys/sys/resourcevar.h8
9 files changed, 37 insertions, 192 deletions
diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S
index 22faea8..dba635d 100644
--- a/sys/amd64/amd64/cpu_switch.S
+++ b/sys/amd64/amd64/cpu_switch.S
@@ -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
diff --git a/sys/amd64/amd64/swtch.s b/sys/amd64/amd64/swtch.s
index 22faea8..dba635d 100644
--- a/sys/amd64/amd64/swtch.s
+++ b/sys/amd64/amd64/swtch.s
@@ -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
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index 224a6f4..2ee576a 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -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 (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
- }
- }
+ if (p->p_flag & P_PROFIL)
+ addupc_task(p, frame->tf_eip,
+ (u_int)(p->p_sticks - oticks) * psratio);
+
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;
diff --git a/sys/amd64/include/cpu.h b/sys/amd64/include/cpu.h
index edf4342..adba748 100644
--- a/sys/amd64/include/cpu.h
+++ b/sys/amd64/include/cpu.h
@@ -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(); }
diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s
index 22faea8..dba635d 100644
--- a/sys/i386/i386/swtch.s
+++ b/sys/i386/i386/swtch.s
@@ -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
diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c
index 224a6f4..2ee576a 100644
--- a/sys/i386/i386/trap.c
+++ b/sys/i386/i386/trap.c
@@ -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 (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
- }
- }
+ if (p->p_flag & P_PROFIL)
+ addupc_task(p, frame->tf_eip,
+ (u_int)(p->p_sticks - oticks) * psratio);
+
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;
diff --git a/sys/i386/include/cpu.h b/sys/i386/include/cpu.h
index edf4342..adba748 100644
--- a/sys/i386/include/cpu.h
+++ b/sys/i386/include/cpu.h
@@ -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(); }
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index 224a6f4..2ee576a 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -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 (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
- }
- }
+ if (p->p_flag & P_PROFIL)
+ addupc_task(p, frame->tf_eip,
+ (u_int)(p->p_sticks - oticks) * psratio);
+
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;
diff --git a/sys/sys/resourcevar.h b/sys/sys/resourcevar.h
index a34e065..018188f 100644
--- a/sys/sys/resourcevar.h
+++ b/sys/sys/resourcevar.h
@@ -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,
OpenPOWER on IntegriCloud