diff options
author | attilio <attilio@FreeBSD.org> | 2008-05-15 20:10:06 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2008-05-15 20:10:06 +0000 |
commit | f7f31164f19cdffc5fc75cde6ac6d025b796f980 (patch) | |
tree | 4a7012a0d4693359153827067b7671780eaffb71 /sys/sys | |
parent | 65c049483295f418e34fa09dc07b3656d53df907 (diff) | |
download | FreeBSD-src-f7f31164f19cdffc5fc75cde6ac6d025b796f980.zip FreeBSD-src-f7f31164f19cdffc5fc75cde6ac6d025b796f980.tar.gz |
- Embed the recursion counter for any locking primitive directly in the
lock_object, using an unified field called lo_data.
- Replace lo_type usage with the w_name usage and at init time pass the
lock "type" directly to witness_init() from the parent lock init
function. Handle delayed initialization before than
witness_initialize() is called through the witness_pendhelp structure.
- Axe out LO_ENROLLPEND as it is not really needed. The case where the
mutex init delayed wants to be destroyed can't happen because
witness_destroy() checks for witness_cold and panic in case.
- In enroll(), if we cannot allocate a new object from the freelist,
notify that to userspace through a printf().
- Modify the depart function in order to return nothing as in the current
CVS version it always returns true and adjust callers accordingly.
- Fix the witness_addgraph() argument name prototype.
- Remove unuseful code from itismychild().
This commit leads to a shrinked struct lock_object and so smaller locks,
in particular on amd64 where 2 uintptr_t (16 bytes per-primitive) are
gained.
Reviewed by: jhb
Diffstat (limited to 'sys/sys')
-rw-r--r-- | sys/sys/_lock.h | 7 | ||||
-rw-r--r-- | sys/sys/_lockmgr.h | 1 | ||||
-rw-r--r-- | sys/sys/_mutex.h | 1 | ||||
-rw-r--r-- | sys/sys/_rwlock.h | 1 | ||||
-rw-r--r-- | sys/sys/_sx.h | 1 | ||||
-rw-r--r-- | sys/sys/lock.h | 9 | ||||
-rw-r--r-- | sys/sys/lockmgr.h | 1 | ||||
-rw-r--r-- | sys/sys/mutex.h | 2 | ||||
-rw-r--r-- | sys/sys/rwlock.h | 2 |
9 files changed, 11 insertions, 14 deletions
diff --git a/sys/sys/_lock.h b/sys/sys/_lock.h index dd0b071..ff5828c 100644 --- a/sys/sys/_lock.h +++ b/sys/sys/_lock.h @@ -33,12 +33,9 @@ struct lock_object { const char *lo_name; /* Individual lock name. */ - const char *lo_type; /* General lock type. */ u_int lo_flags; - union { /* Data for witness. */ - STAILQ_ENTRY(lock_object) lod_list; - struct witness *lod_witness; - } lo_witness_data; + u_int lo_data; /* General class specific data. */ + struct witness *lo_witness; /* Data for witness. */ }; #endif /* !_SYS__LOCK_H_ */ diff --git a/sys/sys/_lockmgr.h b/sys/sys/_lockmgr.h index 11ddac6..0b99e1a 100644 --- a/sys/sys/_lockmgr.h +++ b/sys/sys/_lockmgr.h @@ -38,7 +38,6 @@ struct lock { struct lock_object lock_object; volatile uintptr_t lk_lock; - volatile unsigned lk_recurse; int lk_timo; int lk_pri; #ifdef DEBUG_LOCKS diff --git a/sys/sys/_mutex.h b/sys/sys/_mutex.h index 7aa8f4e..e61954e 100644 --- a/sys/sys/_mutex.h +++ b/sys/sys/_mutex.h @@ -37,7 +37,6 @@ struct mtx { struct lock_object lock_object; /* Common lock properties. */ volatile uintptr_t mtx_lock; /* Owner and flags. */ - volatile u_int mtx_recurse; /* Number of recursive holds. */ }; #endif /* !_SYS__MUTEX_H_ */ diff --git a/sys/sys/_rwlock.h b/sys/sys/_rwlock.h index f65d3fa..c5adac0 100644 --- a/sys/sys/_rwlock.h +++ b/sys/sys/_rwlock.h @@ -38,7 +38,6 @@ struct rwlock { struct lock_object lock_object; volatile uintptr_t rw_lock; - volatile unsigned rw_recurse; }; #endif /* !_SYS__RWLOCK_H_ */ diff --git a/sys/sys/_sx.h b/sys/sys/_sx.h index 0d0351c..789720b 100644 --- a/sys/sys/_sx.h +++ b/sys/sys/_sx.h @@ -37,7 +37,6 @@ struct sx { struct lock_object lock_object; volatile uintptr_t sx_lock; - volatile unsigned sx_recurse; }; #endif /* !_SYS__SX_H_ */ diff --git a/sys/sys/lock.h b/sys/sys/lock.h index 2e94120..2bde087 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -78,7 +78,6 @@ struct lock_class { #define LO_SLEEPABLE 0x00100000 /* Lock may be held while sleeping. */ #define LO_UPGRADABLE 0x00200000 /* Lock may be upgraded/downgraded. */ #define LO_DUPOK 0x00400000 /* Don't check for duplicate acquires */ -#define LO_ENROLLPEND 0x00800000 /* On the pending enroll list. */ #define LO_CLASSMASK 0x0f000000 /* Class index bitmask. */ #define LO_NOPROFILE 0x10000000 /* Don't profile this lock */ @@ -201,7 +200,7 @@ void lock_init(struct lock_object *, struct lock_class *, void lock_destroy(struct lock_object *); void spinlock_enter(void); void spinlock_exit(void); -void witness_init(struct lock_object *); +void witness_init(struct lock_object *, const char *); void witness_destroy(struct lock_object *); int witness_defineorder(struct lock_object *, struct lock_object *); void witness_checkorder(struct lock_object *, int, const char *, int); @@ -225,8 +224,8 @@ const char *witness_file(struct lock_object *); #define WARN_PANIC 0x02 /* Panic if check fails. */ #define WARN_SLEEPOK 0x04 /* Sleepable locks are exempt from check. */ -#define WITNESS_INIT(lock) \ - witness_init((lock)) +#define WITNESS_INIT(lock, type) \ + witness_init((lock), (type)) #define WITNESS_DESTROY(lock) \ witness_destroy(lock) @@ -273,7 +272,7 @@ const char *witness_file(struct lock_object *); witness_line(lock) #else /* WITNESS */ -#define WITNESS_INIT(lock) +#define WITNESS_INIT(lock, type) #define WITNESS_DESTROY(lock) #define WITNESS_DEFINEORDER(lock1, lock2) 0 #define WITNESS_CHECKORDER(lock, flags, file, line) diff --git a/sys/sys/lockmgr.h b/sys/sys/lockmgr.h index e586838..2183144 100644 --- a/sys/sys/lockmgr.h +++ b/sys/sys/lockmgr.h @@ -59,6 +59,7 @@ #endif struct thread; +#define lk_recurse lock_object.lo_data /* * Function prototipes. Routines that start with an underscore are not part diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index 85efb83..b069120 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -134,6 +134,8 @@ void _thread_lock_flags(struct thread *, int, const char *, int); #define thread_unlock(tdp) \ mtx_unlock_spin((tdp)->td_lock) +#define mtx_recurse lock_object.lo_data + /* * We define our machine-independent (unoptimized) mutex micro-operations * here, if they are not already defined in the machine-dependent mutex.h diff --git a/sys/sys/rwlock.h b/sys/sys/rwlock.h index 2b4d82f..2b45667 100644 --- a/sys/sys/rwlock.h +++ b/sys/sys/rwlock.h @@ -83,6 +83,8 @@ #ifdef _KERNEL +#define rw_recurse lock_object.lo_data + /* Very simple operations on rw_lock. */ /* Try to obtain a write lock once. */ |