Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm switch the UVMHIST counters from mutexes to atomic ops
details: https://anonhg.NetBSD.org/src/rev/924f6a360872
branches: trunk
changeset: 756118:924f6a360872
user: chs <chs%NetBSD.org@localhost>
date: Wed Jul 07 01:08:51 2010 +0000
description:
switch the UVMHIST counters from mutexes to atomic ops
to avoid a bad interaction with DIAGNOSTIC.
diffstat:
sys/uvm/uvm_stat.h | 29 +++++++++++------------------
1 files changed, 11 insertions(+), 18 deletions(-)
diffs (83 lines):
diff -r 4d7aa58ded94 -r 924f6a360872 sys/uvm/uvm_stat.h
--- a/sys/uvm/uvm_stat.h Wed Jul 07 00:10:14 2010 +0000
+++ b/sys/uvm/uvm_stat.h Wed Jul 07 01:08:51 2010 +0000
@@ -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 @@
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 @@
#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 @@
(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 @@
(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 @@
#define UVMHIST_LOG(NAME,FMT,A,B,C,D) \
do { \
- int _i_; \
- mutex_enter(&(NAME).l); \
- _i_ = (NAME).f; \
- (NAME).f = (_i_ + 1 < (NAME).n) ? _i_ + 1 : 0; \
- mutex_exit(&(NAME).l); \
+ unsigned int _i_, _j_; \
+ do { \
+ _i_ = (NAME).f; \
+ _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 @@
#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;
Home |
Main Index |
Thread Index |
Old Index