PERFORCE change 100121 for review
Kip Macy
kip.macy at gmail.com
Tue Jun 27 16:31:05 UTC 2006
Point me at your tree. I do :-).
-Kip
On 6/27/06, John Baldwin <jhb at freebsd.org> wrote:
> On Tuesday 27 June 2006 03:42, Kip Macy wrote:
> > http://perforce.freebsd.org/chv.cgi?CH=100121
> >
> > Change 100121 by kmacy at kmacy_storage:sun4v_work_sleepq on 2006/06/27
> 07:41:14
> >
> > avoid pointless turnstile contention if mutex owner is running
>
> Yes, I did this already in jhb_lock for both mutexes and rwlocks at BSDCan.
> Kris said my patch panic'd for him at BSDCan but I don't have an SMP machine
> I can test it on now to debug it. :(
>
> >
> > Affected files ...
> >
> > .. //depot/projects/kmacy_sun4v/src/sys/kern/kern_mutex.c#20 edit
> >
> > Differences ...
> >
> > ==== //depot/projects/kmacy_sun4v/src/sys/kern/kern_mutex.c#20 (text+ko)
> ====
> >
> > @@ -176,7 +176,7 @@
> > static int mutex_prof_maxrecords = MPROF_HASH_SIZE;
> > SYSCTL_INT(_debug_mutex_prof, OID_AUTO, maxrecords, CTLFLAG_RD,
> > &mutex_prof_maxrecords, 0, "Maximum number of profiling records");
> > -int mutex_prof_rejected;
> > +int mutex_prof_rejected = 0;
> > SYSCTL_INT(_debug_mutex_prof, OID_AUTO, rejected, CTLFLAG_RD,
> > &mutex_prof_rejected, 0, "Number of rejected profiling records");
> > static int mutex_prof_hashsize = MPROF_HASH_SIZE;
> > @@ -418,6 +418,16 @@
> >
> > while (!_obtain_lock(m, tid)) {
> > lock_profile_obtain_lock_failed(&m->mtx_object, &contested);
> > +#if defined(SMP) && !defined(NO_ADAPTIVE_MUTEXES)
> > + /*
> > + * If the current owner of the lock is executing on another
> > + * CPU, spin instead of blocking.
> > + */
> > + for (owner = mtx_owner(m); owner && TD_IS_RUNNING(owner); owner =
> mtx_owner(m))
> > + cpu_spinwait();
> > + if (mtx_unowned(m))
> > + continue;
> > +#endif /* SMP && !NO_ADAPTIVE_MUTEXES */
> > turnstile_lock(&m->mtx_object);
> > v = m->mtx_lock;
> >
> > @@ -425,7 +435,7 @@
> > * Check if the lock has been released while spinning for
> > * the turnstile chain lock.
> > */
> > - if (v == MTX_UNOWNED) {
> > + if (mtx_unowned(m)) {
> > turnstile_release(&m->mtx_object);
> > cpu_spinwait();
> > continue;
> > @@ -837,6 +847,8 @@
> > mtx_validate(m);
> > #endif
> >
> > +
> > +
> > /* Determine lock class and lock flags. */
> > if (opts & MTX_SPIN)
> > class = &lock_class_mtx_spin;
> >
>
> --
> John Baldwin
>
More information about the p4-projects
mailing list