__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@
This commit is contained in:
ryo 2016-01-10 09:04:32 +00:00
parent b120305be0
commit c2acaf5fa5
3 changed files with 31 additions and 85 deletions

View File

@ -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 selfpc)
*/
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 selfpc)
*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;

View File

@ -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 */

View File

@ -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)
{
@ -126,12 +100,7 @@ mcount_write_psl(u_long 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);
do { s = (int)mcount_read_psl(); mcount_disable_intr(); } while (0)
#define MCOUNT_EXIT do { mcount_write_psl(s); } while (0)
#endif /* _KERNEL */