Subject: Re: mips kernel profiling?
To: Ethan Solomita <ethan@geocast.com>
From: Simon Burge <simonb@NetBSD.ORG>
List: port-mips
Date: 04/02/2000 01:47:29
Ethan Solomita wrote:
> Simon Burge wrote:
> >
> > What was your fix - to subtract another 16 frop sp on entry to _mcount
> > and add 24 instead of 8 on exit?
> >
> I've now verified that this change does allow me to boot. I haven't
> gotten profiling working yet, but this may be more related to our mips
> port than profiling.
>
> > > I did something much simpler -- no new code, just changed MCOUNT_ENTER
> > > to s = _splset(0); and MCOUNT_EXIT to _splset(s); This seems to work
> > > with my platform -- is it a problem for pmax or others?
> >
> > _splset is a LEAF function, so it calls MCOUNT. From what I understand,
> > we shouldn't profile the profiling support :)
> >
> Then that won't work. 8-)
With playing around with sp on entry and exit of _mcount and using
_splraise_noprof() and _splset_noprof(), I seem to have working
profiling now. Is there any objections to the non-profiled spl
names or should I commit it as is?
I've included the complete patch below for reference. Thanks
for you help Ethan!
Simon.
--
Index: mips/include/profile.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/include/profile.h,v
retrieving revision 1.13
diff -p -u -r1.13 profile.h
--- profile.h 2000/03/28 02:58:46 1.13
+++ profile.h 2000/04/01 15:45:18
@@ -46,9 +46,9 @@
* Declare non-profiled _splhigh() /_splx() entrypoints for _mcount.
* see MCOUNT_ENTER and MCOUNT_EXIT.
*/
-#define _KERNEL_MCOUNT_DECL \
- int _splhigh __P((void)); \
- int _splx __P((int));
+#define _KERNEL_MCOUNT_DECL \
+ int _splraise_noprof __P((int)); \
+ int _splset_noprof __P((int));
#else /* !_KERNEL */
/* Make __mcount static. */
#define _KERNEL_MCOUNT_DECL static
@@ -72,6 +72,7 @@
".set noreorder;" \
".set noat;" \
_PROF_CPLOAD \
+ "subu $29,$29,16;" \
"sw $4,8($29);" \
"sw $5,12($29);" \
"sw $6,16($29);" \
@@ -87,7 +88,7 @@
"lw $7,20($29);" \
"lw $31,4($29);" \
"lw $1,0($29);" \
- "addu $29,$29,8;" \
+ "addu $29,$29,24;" \
"j $31;" \
"move $31,$1;" \
".set reorder;" \
@@ -96,13 +97,13 @@
#ifdef _KERNEL
/*
* The following two macros do splhigh and splx respectively.
- * They have to be defined this way because these are real
- * functions on the MIPS, and we do not want to invoke mcount
- * recursively.
+ * We use versions of _splraise() and _splset that don't
+ * including profiling support.
*/
-#define MCOUNT_ENTER s = _splhigh()
-#define MCOUNT_EXIT _splx(s)
+#define MCOUNT_ENTER s = _splraise_noprof(MIPS_INT_MASK)
+
+#define MCOUNT_EXIT (void)_splset_noprof(s)
#endif /* _KERNEL */
#endif /* _MIPS_PROFILE_H_ */
Index: mips/mips/locore.S
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/mips/locore.S,v
retrieving revision 1.92
diff -p -u -r1.92 locore.S
--- locore.S 2000/03/28 02:58:48 1.92
+++ locore.S 2000/04/01 15:45:18
@@ -493,6 +493,18 @@ LEAF(_splraise)
and v0, v0, (MIPS_INT_MASK | MIPS_SR_INT_IE)
END(_splraise)
+/* as above, with no profiling support */
+LEAF_NOPROFILE(_splraise_noprof)
+ mfc0 v0, MIPS_COP_0_STATUS # fetch status register
+ and a0, a0, MIPS_INT_MASK # extract INT bits
+ nor a0, zero, a0 # bitwise inverse of A0
+ and a0, a0, v0 # disable retaining other bits
+ mtc0 a0, MIPS_COP_0_STATUS # store back
+ nop
+ j ra
+ and v0, v0, (MIPS_INT_MASK | MIPS_SR_INT_IE)
+END(_splraise_noprof)
+
LEAF(_spllower)
mfc0 v0, MIPS_COP_0_STATUS # fetch status register
li v1, ~MIPS_INT_MASK
@@ -529,6 +541,19 @@ LEAF(_splset)
j ra
and v0, v0, (MIPS_INT_MASK | MIPS_SR_INT_IE)
END(_splset)
+
+/* as above, with no profiling support */
+LEAF_NOPROFILE(_splset_noprof)
+ mfc0 v0, MIPS_COP_0_STATUS # fetch status register
+ and a0, a0, (MIPS_INT_MASK | MIPS_SR_INT_IE)
+ li v1, ~(MIPS_INT_MASK | MIPS_SR_INT_IE)
+ and v1, v1, v0 # turn off every INT bit
+ or v1, v1, a0 # set old INT bits
+ mtc0 v1, MIPS_COP_0_STATUS # store back
+ nop
+ j ra
+ and v0, v0, (MIPS_INT_MASK | MIPS_SR_INT_IE)
+END(_splset_noprof)
LEAF(_splget)
mfc0 v0, MIPS_COP_0_STATUS # fetch status register