svn commit: r231907 - in stable/9: lib/libc/powerpc64/sys sys/conf sys/powerpc/aim sys/powerpc/include sys/powerpc/ofw sys/powerpc/powerpc

Andreas Tobler andreast at FreeBSD.org
Sun Feb 19 08:58:32 UTC 2012


Author: andreast
Date: Sun Feb 19 08:58:31 2012
New Revision: 231907
URL: http://svn.freebsd.org/changeset/base/231907

Log:
  MFC r230391, r230400, 231019:
  
  This commit adds profiling support for powerpc64. Now we can do application
  profiling and kernel profiling. To enable kernel profiling one has to build
  kgmon(8). I will enable the build once I managed to build and test powerpc
  (32-bit) kernels with profiling support.
  
  - add a powerpc64 PROF_PROLOGUE for _mcount.
  - add macros to avoid adding the PROF_PROLOGUE in certain assembly entries.
  - apply these macros where needed.
  - add size information to the MCOUNT function.

Modified:
  stable/9/lib/libc/powerpc64/sys/cerror.S
  stable/9/sys/conf/ldscript.powerpc64
  stable/9/sys/powerpc/aim/locore64.S
  stable/9/sys/powerpc/aim/swtch64.S
  stable/9/sys/powerpc/aim/trap_subr64.S
  stable/9/sys/powerpc/include/asm.h
  stable/9/sys/powerpc/include/profile.h
  stable/9/sys/powerpc/ofw/ofwcall64.S
  stable/9/sys/powerpc/powerpc/atomic.S
  stable/9/sys/powerpc/powerpc/setjmp.S

Modified: stable/9/lib/libc/powerpc64/sys/cerror.S
==============================================================================
--- stable/9/lib/libc/powerpc64/sys/cerror.S	Sun Feb 19 08:17:14 2012	(r231906)
+++ stable/9/lib/libc/powerpc64/sys/cerror.S	Sun Feb 19 08:58:31 2012	(r231907)
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");
 	 * programs and the initial threaded in threaded programs,
 	 * it returns a pointer to the global errno variable.
 	 */
-ENTRY(HIDENAME(cerror))
+ENTRY_NOPROF(HIDENAME(cerror))
 	mflr	%r0
 	std	%r0,16(%r1)		/* save lr */
 	stdu	%r1,-64(%r1)		/* allocate new stack frame */

Modified: stable/9/sys/conf/ldscript.powerpc64
==============================================================================
--- stable/9/sys/conf/ldscript.powerpc64	Sun Feb 19 08:17:14 2012	(r231906)
+++ stable/9/sys/conf/ldscript.powerpc64	Sun Feb 19 08:58:31 2012	(r231907)
@@ -1,7 +1,7 @@
 /* $FreeBSD$ */
 
 OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc")
-OUTPUT_ARCH(powerpc)
+OUTPUT_ARCH(powerpc:common64)
 ENTRY(__start)
 SEARCH_DIR(/usr/lib);
 PROVIDE (__stack = 0);
@@ -56,15 +56,19 @@ SECTIONS
   .sdata2    : { *(.sdata2)  }
   .sbss2     : { *(.sbss2)   }
   /* Adjust the address for the data segment to the next page up. */
-  . = ((. + 0x1000) & ~(0x1000 - 1));
+  . = ALIGN(4096);
   .data    :
   {
     *(.data)
     *(.gnu.linkonce.d*)
     CONSTRUCTORS
   }
-  .data1   : { *(.data1) }
-  .got1           : { *(.got1) }
+  .data1     : { *(.data1) }
+  .toc1      : ALIGN(8) { *(.toc1) }
+  .opd       : ALIGN(8) { KEEP (*(.opd)) }
+  .branch_lt : ALIGN(8) { *(.branch_lt) }
+  .got       : ALIGN(8) { *(.got .toc) }
+
   .dynamic        : { *(.dynamic) }
   /* Put .ctors and .dtors next to the .got2 section, so that the pointers
      get relocated with -mrelocatable. Also put in the .fixup pointers.
@@ -81,10 +85,6 @@ SECTIONS
   .fixup          : { *(.fixup) }
                 PROVIDE (_FIXUP_END_ = .);
                 PROVIDE (_GOT2_END_ = .);
-                PROVIDE (_GOT_START_ = .);
-  .got            : { *(.got) }
-  .got.plt        : { *(.got.plt) }
-                PROVIDE (_GOT_END_ = .);
   /* We want the small data sections together, so single-instruction offsets
      can access them all, and initialized data all before uninitialized, so
      we can shorten the on-disk segment size.  */

Modified: stable/9/sys/powerpc/aim/locore64.S
==============================================================================
--- stable/9/sys/powerpc/aim/locore64.S	Sun Feb 19 08:17:14 2012	(r231906)
+++ stable/9/sys/powerpc/aim/locore64.S	Sun Feb 19 08:58:31 2012	(r231907)
@@ -115,7 +115,7 @@ kernel_text:
  * segment!
  */
 	.text
-ASENTRY(__start)
+ASENTRY_NOPROF(__start)
 	li	8,0
 	li	9,0x100
 	mtctr	9
@@ -202,7 +202,7 @@ tocbase:
  * or the (currently used) C code optimized, so it doesn't use any non-volatile
  * registers.
  */
-ASENTRY(setfault)
+ASENTRY_NOPROF(setfault)
 	mflr	0
 	mfcr	12
 	mfsprg	4,0

Modified: stable/9/sys/powerpc/aim/swtch64.S
==============================================================================
--- stable/9/sys/powerpc/aim/swtch64.S	Sun Feb 19 08:17:14 2012	(r231906)
+++ stable/9/sys/powerpc/aim/swtch64.S	Sun Feb 19 08:58:31 2012	(r231907)
@@ -268,7 +268,8 @@ ENTRY(savectx)
  * fork_trampoline()
  * Set up the return from cpu_fork()
  */
-ENTRY(fork_trampoline)
+
+ENTRY_NOPROF(fork_trampoline)
 	ld	%r3,CF_FUNC(%r1)
 	ld	%r4,CF_ARG0(%r1)
 	ld	%r5,CF_ARG1(%r1)

Modified: stable/9/sys/powerpc/aim/trap_subr64.S
==============================================================================
--- stable/9/sys/powerpc/aim/trap_subr64.S	Sun Feb 19 08:17:14 2012	(r231906)
+++ stable/9/sys/powerpc/aim/trap_subr64.S	Sun Feb 19 08:58:31 2012	(r231907)
@@ -555,7 +555,7 @@ CNAME(asttrapexit):
 /*
  * Deliberate entry to dbtrap
  */
-ASENTRY(breakpoint)
+ASENTRY_NOPROF(breakpoint)
 	mtsprg1	%r1
 	mfmsr	%r3
 	mtsrr1	%r3

Modified: stable/9/sys/powerpc/include/asm.h
==============================================================================
--- stable/9/sys/powerpc/include/asm.h	Sun Feb 19 08:17:14 2012	(r231906)
+++ stable/9/sys/powerpc/include/asm.h	Sun Feb 19 08:58:31 2012	(r231907)
@@ -76,15 +76,35 @@
 #endif
 
 #if defined(PROF) || (defined(_KERNEL) && defined(GPROF))
-# define	_PROF_PROLOGUE	mflr 0; stw 0,4(1); bl _mcount
+# ifdef __powerpc64__
+#   define	_PROF_PROLOGUE	mflr 0;					\
+				std 3,48(1);				\
+				std 4,56(1);				\
+				std 5,64(1);				\
+				std 0,16(1);				\
+				stdu 1,-112(1);				\
+				bl _mcount;				\
+				nop;					\
+				ld 0,112+16(1);				\
+				ld 3,112+48(1);				\
+				ld 4,112+56(1);				\
+				ld 5,112+64(1);				\
+				mtlr 0;					\
+				addi 1,1,112
+# else
+#   define	_PROF_PROLOGUE	mflr 0; stw 0,4(1); bl _mcount
+# endif
 #else
 # define	_PROF_PROLOGUE
 #endif
 
-#define	ENTRY(y)	_ENTRY(CNAME(y)); _PROF_PROLOGUE
 #define	ASENTRY(y)	_ENTRY(ASMNAME(y)); _PROF_PROLOGUE
+#define	ENTRY(y)	_ENTRY(CNAME(y)); _PROF_PROLOGUE
 #define	GLOBAL(y)	_GLOBAL(CNAME(y))
 
+#define	ASENTRY_NOPROF(y)	_ENTRY(ASMNAME(y))
+#define	ENTRY_NOPROF(y)		_ENTRY(CNAME(y))
+
 #define	ASMSTR		.asciz
 
 #define	RCSID(x)	.text; .asciz x

Modified: stable/9/sys/powerpc/include/profile.h
==============================================================================
--- stable/9/sys/powerpc/include/profile.h	Sun Feb 19 08:17:14 2012	(r231906)
+++ stable/9/sys/powerpc/include/profile.h	Sun Feb 19 08:58:31 2012	(r231907)
@@ -85,6 +85,7 @@ __asm(	"	.text				\n" \
 	"_mcount:				\n" \
 	"	.quad .L._mcount,.TOC. at tocbase,0\n" \
 	"	.previous			\n" \
+	"	.size   main,24			\n" \
 	"	.type	_mcount, at function	\n" \
 	"	.align	4			\n" \
 	".L._mcount:				\n" \

Modified: stable/9/sys/powerpc/ofw/ofwcall64.S
==============================================================================
--- stable/9/sys/powerpc/ofw/ofwcall64.S	Sun Feb 19 08:17:14 2012	(r231906)
+++ stable/9/sys/powerpc/ofw/ofwcall64.S	Sun Feb 19 08:58:31 2012	(r231907)
@@ -56,7 +56,7 @@ GLOBAL(rtas_entry)
  * Open Firmware Real-mode Entry Point. This is a huge pain.
  */
 
-ASENTRY(ofwcall)
+ASENTRY_NOPROF(ofwcall)
 	mflr	%r0
 	std	%r0,16(%r1)
 	stdu	%r1,-208(%r1)
@@ -175,7 +175,7 @@ ASENTRY(ofwcall)
  * C prototype: int rtascall(void *callbuffer, void *rtas_privdat);
  */
 
-ASENTRY(rtascall)
+ASENTRY_NOPROF(rtascall)
 	mflr	%r0
 	std	%r0,16(%r1)
 	stdu	%r1,-208(%r1)

Modified: stable/9/sys/powerpc/powerpc/atomic.S
==============================================================================
--- stable/9/sys/powerpc/powerpc/atomic.S	Sun Feb 19 08:17:14 2012	(r231906)
+++ stable/9/sys/powerpc/powerpc/atomic.S	Sun Feb 19 08:58:31 2012	(r231907)
@@ -30,7 +30,7 @@
 	
 	.text
 	
-ASENTRY(atomic_set_8)
+ASENTRY_NOPROF(atomic_set_8)
 0:	lwarx	0, 0, 3		/* load old value */
 	slwi	4, 4, 24	/* shift the byte so it's in the right place */
 	or	0, 0, 4		/* generate new value */
@@ -40,7 +40,7 @@ ASENTRY(atomic_set_8)
 	sync
 	blr			/* return */
 
-ASENTRY(atomic_clear_8)
+ASENTRY_NOPROF(atomic_clear_8)
 0:	lwarx 	0, 0, 3		/* load old value */
 	slwi	4, 4, 24	/* shift the byte so it's in the right place */
 	andc	0, 0, 4		/* generate new value */
@@ -50,7 +50,7 @@ ASENTRY(atomic_clear_8)
 	sync
 	blr			/* return */
 
-ASENTRY(atomic_add_8)
+ASENTRY_NOPROF(atomic_add_8)
 0:	lwarx	9, 0, 3		/* load old value */
 	srwi	0, 9, 24	/* byte alignment */
 	add	0, 4, 0		/* calculate new value */
@@ -63,7 +63,7 @@ ASENTRY(atomic_add_8)
 	sync
 	blr			/* return */
 
-ASENTRY(atomic_subtract_8)
+ASENTRY_NOPROF(atomic_subtract_8)
 0:	lwarx	9, 0, 3		/* load old value */
 	srwi	0, 9, 24	/* byte alignment */
 	subf	0, 4, 0		/* calculate new value */
@@ -76,7 +76,7 @@ ASENTRY(atomic_subtract_8)
 	sync
 	blr			/* return */
 
-ASENTRY(atomic_set_16)
+ASENTRY_NOPROF(atomic_set_16)
 	li	11, 3		/* mask to test for alignment */
 	andc.	11, 3, 11	/* force address to be word-aligned */
 0:	lwarx	12, 0, 11	/* load old value */
@@ -89,7 +89,7 @@ ASENTRY(atomic_set_16)
 	sync
 	blr			/* return */
 
-ASENTRY(atomic_clear_16)
+ASENTRY_NOPROF(atomic_clear_16)
 	li	11, 3		/* mask to test for alignment */
 	andc.	11, 3, 11	/* force address to be word-aligned */
 0:	lwarx	12, 0, 11	/* load old value */
@@ -102,7 +102,7 @@ ASENTRY(atomic_clear_16)
 	sync
 	blr			/* return */
 
-ASENTRY(atomic_add_16)
+ASENTRY_NOPROF(atomic_add_16)
 	li	11, 3		/* mask to test for alignment */
 	andc.	11, 3, 11	/* force address to be word-aligned */
 0:	lwarx	12, 0, 11	/* load old value */
@@ -119,7 +119,7 @@ ASENTRY(atomic_add_16)
 	sync
 	blr			/* return */
 
-ASENTRY(atomic_subtract_16)
+ASENTRY_NOPROF(atomic_subtract_16)
 	li	11, 3		/* mask to test for alignment */
 	andc.	11, 3, 11	/* force address to be word-aligned */
 0:	lwarx	12, 0, 11	/* load old value */

Modified: stable/9/sys/powerpc/powerpc/setjmp.S
==============================================================================
--- stable/9/sys/powerpc/powerpc/setjmp.S	Sun Feb 19 08:17:14 2012	(r231906)
+++ stable/9/sys/powerpc/powerpc/setjmp.S	Sun Feb 19 08:58:31 2012	(r231907)
@@ -42,7 +42,7 @@
 #define JMP_xer	24*REGWIDTH
 #define JMP_sig	25*REGWIDTH
 
-ASENTRY(setjmp)
+ASENTRY_NOPROF(setjmp)
 	ST_REG 31, JMP_r31(3)
 	/* r1, r2, r14-r30 */
 	ST_REG 1,  JMP_r1 (3)
@@ -79,7 +79,7 @@ ASENTRY(setjmp)
 
 
 .extern sigsetmask
-ASENTRY(longjmp)
+ASENTRY_NOPROF(longjmp)
 	LD_REG 31, JMP_r31(3)
 	/* r1, r2, r14-r30 */
 	LD_REG 1,  JMP_r1 (3)


More information about the svn-src-stable-9 mailing list