switch the UVMHIST counters from mutexes to atomic ops
to avoid a bad interaction with DIAGNOSTIC.
This commit is contained in:
parent
3bb7b36948
commit
4c14d1923f
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: uvm_stat.h,v 1.46 2010/02/06 12:10:59 uebayasi Exp $ */
|
||||
/* $NetBSD: uvm_stat.h,v 1.47 2010/07/07 01:08:51 chs Exp $ */
|
||||
|
||||
/*
|
||||
*
|
||||
@ -70,11 +70,9 @@ struct uvm_history {
|
||||
const char *name; /* name of this history */
|
||||
size_t namelen; /* length of name, not including null */
|
||||
LIST_ENTRY(uvm_history) list; /* link on list of all histories */
|
||||
int n; /* number of entries */
|
||||
int f; /* next free one */
|
||||
int unused; /* old location of lock */
|
||||
unsigned int n; /* number of entries */
|
||||
unsigned int f; /* next free one */
|
||||
struct uvm_history_ent *e; /* the malloc'd entries */
|
||||
kmutex_t l; /* lock on this history */
|
||||
};
|
||||
|
||||
LIST_HEAD(uvm_history_head, uvm_history);
|
||||
@ -110,6 +108,7 @@ LIST_HEAD(uvm_history_head, uvm_history);
|
||||
#define uvmhist_dump(NAME)
|
||||
#else
|
||||
#include <sys/kernel.h> /* for "cold" variable */
|
||||
#include <sys/atomic.h>
|
||||
|
||||
extern struct uvm_history_head uvm_histories;
|
||||
|
||||
@ -121,7 +120,6 @@ do { \
|
||||
(NAME).namelen = strlen(__STRING(NAME)); \
|
||||
(NAME).n = (N); \
|
||||
(NAME).f = 0; \
|
||||
mutex_init(&(NAME).l, MUTEX_SPIN, IPL_HIGH); \
|
||||
(NAME).e = (struct uvm_history_ent *) \
|
||||
malloc(sizeof(struct uvm_history_ent) * (N), M_TEMP, \
|
||||
M_WAITOK); \
|
||||
@ -135,7 +133,6 @@ do { \
|
||||
(NAME).namelen = strlen(__STRING(NAME)); \
|
||||
(NAME).n = sizeof(BUF) / sizeof(struct uvm_history_ent); \
|
||||
(NAME).f = 0; \
|
||||
mutex_init(&(NAME).l, MUTEX_SPIN, IPL_HIGH); \
|
||||
(NAME).e = (struct uvm_history_ent *) (BUF); \
|
||||
memset((NAME).e, 0, sizeof(struct uvm_history_ent) * (NAME).n); \
|
||||
LIST_INSERT_HEAD(&uvm_histories, &(NAME), list); \
|
||||
@ -156,11 +153,11 @@ do { \
|
||||
|
||||
#define UVMHIST_LOG(NAME,FMT,A,B,C,D) \
|
||||
do { \
|
||||
int _i_; \
|
||||
mutex_enter(&(NAME).l); \
|
||||
unsigned int _i_, _j_; \
|
||||
do { \
|
||||
_i_ = (NAME).f; \
|
||||
(NAME).f = (_i_ + 1 < (NAME).n) ? _i_ + 1 : 0; \
|
||||
mutex_exit(&(NAME).l); \
|
||||
_j_ = (_i_ + 1 < (NAME).n) ? _i_ + 1 : 0; \
|
||||
} while (atomic_cas_uint(&(NAME).f, _i_, _j_) != _i_); \
|
||||
if (!cold) \
|
||||
microtime(&(NAME).e[_i_].tv); \
|
||||
(NAME).e[_i_].cpunum = cpu_number(); \
|
||||
@ -178,16 +175,12 @@ do { \
|
||||
|
||||
#define UVMHIST_CALLED(NAME) \
|
||||
do { \
|
||||
{ \
|
||||
mutex_enter(&(NAME).l); \
|
||||
_uvmhist_call = _uvmhist_cnt++; \
|
||||
mutex_exit(&(NAME).l); \
|
||||
} \
|
||||
_uvmhist_call = atomic_inc_uint_nv(&_uvmhist_cnt); \
|
||||
UVMHIST_LOG(NAME,"called!", 0, 0, 0, 0); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define UVMHIST_FUNC(FNAME) \
|
||||
static int _uvmhist_cnt = 0; \
|
||||
static unsigned int _uvmhist_cnt = 0; \
|
||||
static const char *const _uvmhist_name = FNAME; \
|
||||
int _uvmhist_call;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user