Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src __mcount_lock is moved to MI from MD.
details: https://anonhg.NetBSD.org/src/rev/cd482873f367
branches: trunk
changeset: 812967:cd482873f367
user: ryo <ryo%NetBSD.org@localhost>
date: Sun Jan 10 09:04:32 2016 +0000
description:
__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@
diffstat:
common/lib/libc/gmon/mcount.c | 39 +++++++++++++++++++++++----------------
sys/arch/amd64/include/profile.h | 38 ++++----------------------------------
sys/arch/i386/include/profile.h | 39 ++++-----------------------------------
3 files changed, 31 insertions(+), 85 deletions(-)
diffs (233 lines):
diff -r 3dfb755b545a -r cd482873f367 common/lib/libc/gmon/mcount.c
--- a/common/lib/libc/gmon/mcount.c Sun Jan 10 08:11:06 2016 +0000
+++ b/common/lib/libc/gmon/mcount.c Sun Jan 10 09:04:32 2016 +0000
@@ -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 @@
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 @@
__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 @@
*/
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 @@
*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;
diff -r 3dfb755b545a -r cd482873f367 sys/arch/amd64/include/profile.h
--- a/sys/arch/amd64/include/profile.h Sun Jan 10 08:11:06 2016 +0000
+++ b/sys/arch/amd64/include/profile.h Sun Jan 10 09:04:32 2016 +0000
@@ -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 @@
#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 @@
}
#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 */
diff -r 3dfb755b545a -r cd482873f367 sys/arch/i386/include/profile.h
--- a/sys/arch/i386/include/profile.h Sun Jan 10 08:11:06 2016 +0000
+++ b/sys/arch/i386/include/profile.h Sun Jan 10 09:04:32 2016 +0000
@@ -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 @@
}
#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 @@
__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 */
Home |
Main Index |
Thread Index |
Old Index