From owner-p4-projects Tue Jun 4 14:20:32 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B847237B406; Tue, 4 Jun 2002 14:20:25 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by hub.freebsd.org (Postfix) with ESMTP id D9E8B37B405; Tue, 4 Jun 2002 14:20:23 -0700 (PDT) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc52.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020604212023.WRRH2751.rwcrmhc52.attbi.com@InterJet.elischer.org>; Tue, 4 Jun 2002 21:20:23 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id OAA49358; Tue, 4 Jun 2002 14:14:41 -0700 (PDT) Date: Tue, 4 Jun 2002 14:14:40 -0700 (PDT) From: Julian Elischer To: John Baldwin Cc: Perforce Change Reviews Subject: Re: PERFORCE change 12362 for review In-Reply-To: <200206041746.g54HkS563688@freefall.freebsd.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 4 Jun 2002, John Baldwin wrote: > http://people.freebsd.org/~peter/p4db/chv.cgi?CH=12362 > > Change 12362 by jhb@jhb_laptop on 2002/06/04 10:45:42 > > - Add a thread_runnable() macro to make some code more readable > and make the KSE diff easier. > - Fix the adaptive mutex spin optimization. We need to stop > spinning not just when mtx_owner(m) changes, but also if the > owner stops running. > > Affected files ... > > ... //depot/projects/smpng/sys/kern/kern_mutex.c#36 edit > > Differences ... > > ==== //depot/projects/smpng/sys/kern/kern_mutex.c#36 (text+ko) ==== > > @@ -70,6 +70,9 @@ > #define mtx_owner(m) (mtx_unowned((m)) ? NULL \ > : (struct thread *)((m)->mtx_lock & MTX_FLAGMASK)) > > +#define thread_runnable(td) \ > + ((td)->td_kse != NULL && (td)->td_kse->ke_oncpu != NOCPU) > + this actually checks for "thread_running" not "thread_runnable". Since you are mentioning KSE diffs, in KSE this test is performed by: if (td->td_state == TDS_RUNNING) and if you want to check for both running and runnable, you need: if ((td->td_state == TDS_RUNNING) || (td->td_state == TDS_RUNQ)) > /* > * Lock classes for sleep and spin mutexes. > */ > @@ -129,7 +132,7 @@ > * If lock holder is actually running, just bump priority. > */ > /* XXXKSE this test is not sufficient */ > - if (td->td_kse && (td->td_kse->ke_oncpu != NOCPU)) { > + if (thread_runnable(td)) { > MPASS(td->td_proc->p_stat == SRUN > || td->td_proc->p_stat == SZOMB > || td->td_proc->p_stat == SSTOP); > @@ -531,10 +534,10 @@ > * CPU, spin instead of blocking. > */ > owner = (struct thread *)(v & MTX_FLAGMASK); > - if (m != &Giant && owner->td_kse != NULL && > - owner->td_kse->ke_oncpu != NOCPU) { > + if (m != &Giant && thread_runnable(owner)) { > mtx_unlock_spin(&sched_lock); > - while (mtx_owner(m) == owner) { > + while (mtx_owner(m) == owner && > + thread_runnable(owner)) { > #ifdef __i386__ > ia32_pause(); > #endif > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message