PERFORCE change 117021 for review

Kip Macy kmacy at FreeBSD.org
Sat Mar 31 20:40:49 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=117021

Change 117021 by kmacy at kmacy_vt-x:opentoe_init on 2007/03/31 20:40:35

	only modify lo_flags when the lock is held
	move LOCK_PROFILING_FAST into initial acquisition so we can skip tracking statistics for 
	an uncontested lock entirely
	MFP4 after:	2 days

Affected files ...

.. //depot/projects/opentoe/sys/kern/subr_lock.c#2 edit
.. //depot/projects/opentoe/sys/sys/lock_profile.h#2 edit

Differences ...

==== //depot/projects/opentoe/sys/kern/subr_lock.c#2 (text+ko) ====

@@ -258,9 +258,11 @@
         if (l->lpo_acqtime == 0) {
 		lo->lo_profile_obj.lpo_contest_holding = 0;
 
-		if (contested)
-			lo->lo_profile_obj.lpo_contest_locking++;		
-	
+		if (contested) {
+			lo->lo_flags |= LO_CONTESTED;
+			lo->lo_profile_obj.lpo_contest_locking++;
+		}
+		
                 l->lpo_filename = file;
                 l->lpo_lineno = line;
                 l->lpo_acqtime = nanoseconds(); 

==== //depot/projects/opentoe/sys/sys/lock_profile.h#2 (text+ko) ====

@@ -122,7 +122,6 @@
 
 	if (lock_prof_enable && *contested == 0) {
 		*waittime = nanoseconds();
-		lo->lo_flags |= LO_CONTESTED;
 		atomic_add_int(&l->lpo_contest_holding, 1);
 		*contested = 1;
 	}
@@ -131,18 +130,19 @@
 static inline void lock_profile_obtain_lock_success(struct lock_object *lo, int contested, uint64_t waittime, const char *file, int line) 
 {
 	if (lock_prof_enable) {
-		_lock_profile_obtain_lock_success(lo, contested, waittime, file, line);
+#ifdef LOCK_PROFILE_FAST
+		if (contested == 0)
+			return;
+#endif		
+			_lock_profile_obtain_lock_success(lo, contested, waittime, file, line);
 	}
 }
 
 static inline void lock_profile_release_lock(struct lock_object *lo)
 {
 	struct lock_profile_object *l = &lo->lo_profile_obj;
-#ifdef LOCK_PROFILING_FAST
-	if((lo->lo_flags & LO_CONTESTED) == 0)
-		return;
-#endif		
-	if (lock_prof_enable || l->lpo_acqtime) {
+
+	if (l->lpo_acqtime) {
 		lo->lo_flags &= ~LO_CONTESTED;
 		_lock_profile_release_lock(lo);
 	}


More information about the p4-projects mailing list