Module Name: src Committed By: chs Date: Wed Jul 7 01:08:51 UTC 2010
Modified Files: src/sys/uvm: uvm_stat.h Log Message: switch the UVMHIST counters from mutexes to atomic ops to avoid a bad interaction with DIAGNOSTIC. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/uvm/uvm_stat.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/uvm/uvm_stat.h diff -u src/sys/uvm/uvm_stat.h:1.46 src/sys/uvm/uvm_stat.h:1.47 --- src/sys/uvm/uvm_stat.h:1.46 Sat Feb 6 12:10:59 2010 +++ src/sys/uvm/uvm_stat.h Wed Jul 7 01:08:51 2010 @@ -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;