Module Name:    src
Committed By:   ryo
Date:           Sun Jan 10 09:04:32 UTC 2016

Modified Files:
        src/common/lib/libc/gmon: mcount.c
        src/sys/arch/amd64/include: profile.h
        src/sys/arch/i386/include: profile.h

Log Message:
__mcount_lock is moved to MI from MD.
because it is needed for all MULTIPROCESSOR arch, but it is exists only in i386 
and amd64.

ok christos@, on tech-kern@


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/common/lib/libc/gmon/mcount.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/amd64/include/profile.h
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/i386/include/profile.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/gmon/mcount.c
diff -u src/common/lib/libc/gmon/mcount.c:1.10 src/common/lib/libc/gmon/mcount.c:1.11
--- src/common/lib/libc/gmon/mcount.c:1.10	Tue Mar 20 16:21:41 2012
+++ src/common/lib/libc/gmon/mcount.c	Sun Jan 10 09:04:32 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcount.c,v 1.10 2012/03/20 16:21:41 matt Exp $	*/
+/*	$NetBSD: mcount.c,v 1.11 2016/01/10 09:04:32 ryo Exp $	*/
 
 /*
  * Copyright (c) 2003, 2004 Wasabi Systems, Inc.
@@ -76,12 +76,13 @@
 #if 0
 static char sccsid[] = "@(#)mcount.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: mcount.c,v 1.10 2012/03/20 16:21:41 matt Exp $");
+__RCSID("$NetBSD: mcount.c,v 1.11 2016/01/10 09:04:32 ryo Exp $");
 #endif
 #endif
 
 #include <sys/param.h>
 #include <sys/gmon.h>
+#include <sys/lock.h>
 
 #ifndef _KERNEL
 #include "reentrant.h"
@@ -93,6 +94,10 @@ extern struct gmonparam _gmondummy;
 struct gmonparam *_m_gmon_alloc(void);
 #endif
 
+#if defined(_KERNEL) && !defined(_RUMPKERNEL) && defined(MULTIPROCESSOR)
+__cpu_simple_lock_t __mcount_lock;
+#endif
+
 #ifndef __LINT__
 _MCOUNT_DECL(u_long, u_long)
 #ifdef _KERNEL
@@ -101,16 +106,6 @@ _MCOUNT_DECL(u_long, u_long)
     __used;
 #endif
 
-/* XXX: make these interfaces */
-#ifdef _RUMPKERNEL
-#undef MCOUNT_ENTER
-#define MCOUNT_ENTER
-#undef MCOUNT_EXIT
-#define MCOUNT_EXIT
-#undef MCOUNT
-#define MCOUNT
-#endif
-
 /*
  * mcount is called on entry to each function compiled with the profiling
  * switch set.  _mcount(), which is declared in a machine-dependent way
@@ -155,8 +150,12 @@ _MCOUNT_DECL(u_long frompc, u_long selfp
 	 */
 	if (p->state != GMON_PROF_ON)
 		return;
-#ifdef _KERNEL
+#if defined(_KERNEL) && !defined(_RUMPKERNEL)
 	MCOUNT_ENTER;
+#ifdef MULTIPROCESSOR
+	__cpu_simple_lock(&__mcount_lock);
+	__insn_barrier();
+#endif
 #endif
 	p->state = GMON_PROF_BUSY;
 	/*
@@ -246,17 +245,25 @@ _MCOUNT_DECL(u_long frompc, u_long selfp
 			*frompcindex = (u_short)toindex;
 			goto done;
 		}
-		
 	}
 done:
 	p->state = GMON_PROF_ON;
-#ifdef _KERNEL
+#if defined(_KERNEL) && !defined(_RUMPKERNEL)
+#ifdef MULTIPROCESSOR
+	__insn_barrier();
+	__cpu_simple_unlock(&__mcount_lock);
+#endif
 	MCOUNT_EXIT;
 #endif
 	return;
+
 overflow:
 	p->state = GMON_PROF_ERROR;
-#ifdef _KERNEL
+#if defined(_KERNEL) && !defined(_RUMPKERNEL)
+#ifdef MULTIPROCESSOR
+	__insn_barrier();
+	__cpu_simple_unlock(&__mcount_lock);
+#endif
 	MCOUNT_EXIT;
 #endif
 	return;

Index: src/sys/arch/amd64/include/profile.h
diff -u src/sys/arch/amd64/include/profile.h:1.16 src/sys/arch/amd64/include/profile.h:1.17
--- src/sys/arch/amd64/include/profile.h:1.16	Thu Sep 12 15:36:17 2013
+++ src/sys/arch/amd64/include/profile.h	Sun Jan 10 09:04:32 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: profile.h,v 1.16 2013/09/12 15:36:17 joerg Exp $	*/
+/*	$NetBSD: profile.h,v 1.17 2016/01/10 09:04:32 ryo Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -34,14 +34,9 @@
 #ifdef __x86_64__
 
 #ifdef _KERNEL_OPT
-#include "opt_multiprocessor.h"
 #include "opt_xen.h"
 #endif
 
-#ifdef _KERNEL
-#include <machine/lock.h>
-#endif
-
 #define	_MCOUNT_DECL void _mcount
 
 #define EPROL_EXPORT	__asm(".globl _eprol")
@@ -84,27 +79,6 @@ __asm(" .globl __mcount		\n"			\
 
 
 #ifdef _KERNEL
-#ifdef MULTIPROCESSOR
-__cpu_simple_lock_t __mcount_lock;
-
-static inline void
-MCOUNT_ENTER_MP(void)
-{
-	__cpu_simple_lock(&__mcount_lock);
-	__insn_barrier();
-}
-
-static inline void
-MCOUNT_EXIT_MP(void)
-{
-	__insn_barrier();
-	__mcount_lock = __SIMPLELOCK_UNLOCKED;
-}
-#else
-#define MCOUNT_ENTER_MP()
-#define MCOUNT_EXIT_MP()
-#endif
-
 #ifdef XEN
 static inline void
 mcount_disable_intr(void)
@@ -150,14 +124,10 @@ mcount_write_psl(u_long ef)
 }
 
 #endif /* XEN */
-#define	MCOUNT_ENTER							\
-	s = (int)mcount_read_psl();					\
-	mcount_disable_intr();						\
-	MCOUNT_ENTER_MP();
-
-#define	MCOUNT_EXIT							\
-	MCOUNT_EXIT_MP();						\
-	mcount_write_psl(s);
+
+#define MCOUNT_ENTER	\
+	do { s = (int)mcount_read_psl(); mcount_disable_intr(); } while (0)
+#define MCOUNT_EXIT	do { mcount_write_psl(s); } while (0)
 
 #endif /* _KERNEL */
 

Index: src/sys/arch/i386/include/profile.h
diff -u src/sys/arch/i386/include/profile.h:1.33 src/sys/arch/i386/include/profile.h:1.34
--- src/sys/arch/i386/include/profile.h:1.33	Thu Dec 20 23:46:13 2007
+++ src/sys/arch/i386/include/profile.h	Sun Jan 10 09:04:32 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: profile.h,v 1.33 2007/12/20 23:46:13 ad Exp $	*/
+/*	$NetBSD: profile.h,v 1.34 2016/01/10 09:04:32 ryo Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -31,13 +31,8 @@
  *	@(#)profile.h	8.1 (Berkeley) 6/11/93
  */
 
-#ifdef _KERNEL_OPT
-#include "opt_multiprocessor.h"
-#endif
-
 #ifdef _KERNEL
 #include <machine/cpufunc.h>
-#include <machine/lock.h>
 #endif
 
 #define	_MCOUNT_DECL static __inline void _mcount
@@ -83,27 +78,6 @@ mcount(void)								\
 }
 
 #ifdef _KERNEL
-#ifdef MULTIPROCESSOR
-__cpu_simple_lock_t __mcount_lock;
-
-static inline void
-MCOUNT_ENTER_MP(void)
-{
-	__cpu_simple_lock(&__mcount_lock);
-	__insn_barrier();
-}
-
-static inline void
-MCOUNT_EXIT_MP(void)
-{
-	__insn_barrier();
-	__mcount_lock = __SIMPLELOCK_UNLOCKED;
-}
-#else
-#define MCOUNT_ENTER_MP()
-#define MCOUNT_EXIT_MP()
-#endif
-
 static inline void
 mcount_disable_intr(void)
 {
@@ -125,13 +99,8 @@ mcount_write_psl(u_long ef)
 	__asm volatile("pushl %0; popfl" : : "r" (ef));
 }
 
-#define	MCOUNT_ENTER							\
-	s = (int)mcount_read_psl();					\
-	mcount_disable_intr();						\
-	MCOUNT_ENTER_MP();
-
-#define	MCOUNT_EXIT							\
-	MCOUNT_EXIT_MP();						\
-	mcount_write_psl(s);
+#define MCOUNT_ENTER	\
+	do { s = (int)mcount_read_psl(); mcount_disable_intr(); } while (0)
+#define MCOUNT_EXIT	do { mcount_write_psl(s); } while (0)
 
 #endif /* _KERNEL */

Reply via email to