From ec9c09f65287ff4fcd3d3ca010f6cdd36dd3727d Mon Sep 17 00:00:00 2001 From: chs Date: Mon, 21 Feb 2005 01:17:29 +0000 Subject: [PATCH] allow profiling of MP kernels, add a spinlock around the body of mcount(). --- sys/arch/i386/include/profile.h | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/sys/arch/i386/include/profile.h b/sys/arch/i386/include/profile.h index a66a067f0467..ddafe15ea832 100644 --- a/sys/arch/i386/include/profile.h +++ b/sys/arch/i386/include/profile.h @@ -1,4 +1,4 @@ -/* $NetBSD: profile.h,v 1.19 2004/05/24 14:01:10 yamt Exp $ */ +/* $NetBSD: profile.h,v 1.20 2005/02/21 01:17:29 chs Exp $ */ /* * Copyright (c) 1992, 1993 @@ -31,6 +31,10 @@ * @(#)profile.h 8.1 (Berkeley) 6/11/93 */ +#ifdef _KERNEL_OPT +#include "opt_multiprocessor.h" +#endif + #include #define _MCOUNT_DECL static __inline void _mcount @@ -66,6 +70,26 @@ mcount() \ } #ifdef _KERNEL -#define MCOUNT_ENTER do { s = (int)read_psl(); disable_intr(); } while (0) -#define MCOUNT_EXIT do { write_psl(s); } while (0) +#ifdef MULTIPROCESSOR +__cpu_simple_lock_t __mcount_lock; + +#define MCOUNT_ENTER_MP \ + __cpu_simple_lock(&__mcount_lock); +#define MCOUNT_EXIT_MP \ + __cpu_simple_unlock(&__mcount_lock); + +#else +#define MCOUNT_ENTER_MP +#define MCOUNT_EXIT_MP +#endif + +#define MCOUNT_ENTER \ + s = (int)read_psl(); \ + disable_intr(); \ + MCOUNT_ENTR_MP + +#define MCOUNT_EXIT \ + MCOUNT_EXIT_MP \ + write_psl(s); + #endif /* _KERNEL */