cvs commit: src/sys/conf options src/sys/kern kern_mutex.c kern_rwlock.c kern_sx.c kern_thread.c sched_4bsd.c sched_ule.c subr_lock.c src/sys/sys _lock.h lock_profile.h proc.h sx.h

Attilio Rao attilio at freebsd.org
Mon Dec 17 05:29:46 PST 2007


2007/12/16, Jeff Roberson <jroberson at chesapeake.net>:
> On Sat, 15 Dec 2007, Jeff Roberson wrote:
>
> > jeff        2007-12-15 23:13:32 UTC
> >
> >  FreeBSD src repository
> >
> >  Modified files:
> >    sys/conf             options
> >    sys/kern             kern_mutex.c kern_rwlock.c kern_sx.c
> >                         kern_thread.c sched_4bsd.c sched_ule.c
> >                         subr_lock.c
> >    sys/sys              _lock.h lock_profile.h proc.h sx.h
>
> Some of you may complain about the inclusion of lock_profile.h in
> sys/proc.h.  I hope you will forgive this since lock profiling now no
> longer disturbs the ABI and will work with binary modules as well.

Hello,

+void
+lock_profile_obtain_lock_success(struct lock_object *lo, int contested,
+    uint64_t waittime, const char *file, int line)
+{
+	static int lock_prof_count;
+	struct lock_profile_object *l;
+	int spin;
+
+	/* don't reset the timer when/if recursing */
+	if (!lock_prof_enable || (lo->lo_flags & LO_NOPROFILE))
+		return;
+	if (lock_prof_skipcount &&
+	    (++lock_prof_count % lock_prof_skipcount) == 0)
+		return;
+	spin = LOCK_CLASS(lo) == &lock_class_mtx_spin;
+	if (spin && lock_prof_skipspin == 1)
+		return;

I would really like to get ride of this kind of checks against
lock_class_* objects.
The correct thing to do here is to check for the LC_SPINLOCK in the
class flags (this is exactly why they have been introduced I think).

I have a question though.
Does this new implementation track adaptive spinning in locks?
I would have expected a different function for something like that as
"lock_profile_obtain_lock_spinning()" or similar in order to track
both spinning and sleeping times about the same locks, but looking at
function prototypes, at consumers and looking at members of struct
lock_prof I don't see any obvious evidence of it.

Thanks for this work, I really like that our ABI is no longer broken :)

Attilio


-- 
Peace can only be achieved by understanding - A. Einstein


More information about the cvs-all mailing list