Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Jun 2006 00:49:47 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 99909 for review
Message-ID:  <200606240049.k5O0nl2H081228@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=99909

Change 99909 by kmacy@kmacy_storage:sun4v_work_sleepq on 2006/06/24 00:49:07

	profile spin locks

Affected files ...

.. //depot/projects/kmacy_sun4v/src/sys/kern/kern_mutex.c#15 edit
.. //depot/projects/kmacy_sun4v/src/sys/sys/lock.h#6 edit
.. //depot/projects/kmacy_sun4v/src/sys/sys/lock_profile.h#3 edit
.. //depot/projects/kmacy_sun4v/src/sys/sys/mutex.h#7 edit

Differences ...

==== //depot/projects/kmacy_sun4v/src/sys/kern/kern_mutex.c#15 (text+ko) ====

@@ -320,6 +320,7 @@
 	LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file,
 	    line);
 	WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line);
+	lock_profile_obtain_lock_success(&m->mtx_object, file, line);
 }
 
 void
@@ -334,6 +335,7 @@
 	LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file,
 	    line);
 	mtx_assert(m, MA_OWNED);
+	lock_profile_release_lock(&m->mtx_object);
 	_rel_spin_lock(m);
 }
 
@@ -356,14 +358,15 @@
 		m->mtx_recurse++;
 		atomic_set_ptr(&m->mtx_lock, MTX_RECURSED);
 		rval = 1;
-	} else
+	} else 
 		rval = _obtain_lock(m, (uintptr_t)curthread);
 
 	LOCK_LOG_TRY("LOCK", &m->mtx_object, opts, rval, file, line);
-	if (rval)
+	if (rval) {
 		WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE | LOP_TRYLOCK,
 		    file, line);
-
+		lock_profile_obtain_lock_success(&m->mtx_object, file, line);
+	}
 	return (rval);
 }
 
@@ -507,7 +510,7 @@
 _mtx_lock_spin(struct mtx *m, uintptr_t tid, int opts, const char *file,
     int line)
 {
-	int i = 0;
+	int contested, i = 0;
 #ifdef SPIN_PROFILING
 	int profiling = 0;
 	volatile struct thread *td = NULL;
@@ -520,9 +523,10 @@
 		CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m);
 
 	while (!_obtain_lock(m, tid)) {
-
+		lock_profile_obtain_lock_failed(&m->mtx_object, &contested);
 		/* Give interrupts a chance while we spin. */
 		spinlock_exit();
+
 #ifdef SPIN_PROFILING
 		td = mtx_owner(m);
 #endif
@@ -788,6 +792,8 @@
 		flags |= LO_DUPOK;
 	if (opts & MTX_PROFILE)
 		flags |= LO_PROFILE;
+	if (opts & MTX_NOPROFILE)
+		flags |= LO_NOPROFILE;
 
 	/* Initialize mutex. */
 	m->mtx_lock = MTX_UNOWNED;

==== //depot/projects/kmacy_sun4v/src/sys/sys/lock.h#6 (text+ko) ====

@@ -70,6 +70,7 @@
 #define	LO_ENROLLPEND	0x00800000	/* On the pending enroll list. */
 #define	LO_CLASSMASK	0x0f000000	/* Class index bitmask. */
 #define	LO_PROFILE	0x10000000	/* Enable per-lock profiling */
+#define	LO_NOPROFILE	0x20000000	/* Disable mutex profiling */
 
 /*
  * Lock classes are statically assigned an index into the global lock_classes

==== //depot/projects/kmacy_sun4v/src/sys/sys/lock_profile.h#3 (text+ko) ====

@@ -80,7 +80,7 @@
 	/* Initialize the mutex profiling locks */
 	for (i = 0; i < MPROF_LOCK_SIZE; i++) {
 		mtx_init(&mprof_locks[i], "mprof lock",
-		    NULL, MTX_SPIN|MTX_QUIET);
+		    NULL, MTX_SPIN|MTX_QUIET|MTX_NOPROFILE);
 	}
 }
 
@@ -117,7 +117,7 @@
 {
 	struct lock_profile_object *l = &lo->lo_profile_obj;
 
-	if (l->lpo_acqtime) {
+	if (l->lpo_acqtime && !(lo->lo_flags & LO_NOPROFILE)) {
 		const char *unknown = "(unknown)";
 		struct mutex_prof *mpp;
 		u_int64_t acqtime, now, waittime;

==== //depot/projects/kmacy_sun4v/src/sys/sys/mutex.h#7 (text+ko) ====

@@ -57,6 +57,7 @@
 #define MTX_RECURSE	0x00000004	/* Option: lock allowed to recurse */
 #define	MTX_NOWITNESS	0x00000008	/* Don't do any witness checking. */
 #define	MTX_PROFILE	0x00000020	/* Enable spinlock profiling for this spin lock */
+#define	MTX_NOPROFILE	0x00000040	/* Disable mutex profiling for this spin lock */
 
 /*
  * Option flags passed to certain lock/unlock routines, through the use



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606240049.k5O0nl2H081228>