Date: Tue, 2 Oct 2007 21:53:29 -0700 (PDT) From: Jeff Roberson <jroberson@chesapeake.net> To: Yuri Pankov <yuri.pankov@gmail.com> Cc: current@freebsd.org Subject: Re: ULE/yielding patch for testing. Message-ID: <20071002215228.Q615@10.0.0.1> In-Reply-To: <20071003043724.GA1113@darklight.abyss> References: <20071002165007.D587@10.0.0.1> <20071003005009.GA1103@darklight.abyss> <20071003012155.GA1327@darklight.abyss> <20071002195415.I615@10.0.0.1> <20071003043724.GA1113@darklight.abyss>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] On Wed, 3 Oct 2007, Yuri Pankov wrote: > On Tue, Oct 02, 2007 at 07:55:02PM -0700, Jeff Roberson wrote: >> On Wed, 3 Oct 2007, Yuri Pankov wrote: >> >>> On Wed, Oct 03, 2007 at 04:50:09AM +0400, Yuri Pankov wrote: >>>> On Tue, Oct 02, 2007 at 04:53:33PM -0700, Jeff Roberson wrote: >>>>> Enclosed is a patch that does two things: >>>>> >>>>> 1) Reduces UP context switch time by over 10% making it faster than >>>>> 4BSD >>>>> on UP. On SMP it's hard to compare since ULE can do as many as 30x as >>>>> many >>>>> switches per second on my 8way system. >>>>> >>>>> 2) Restores old sched_yield() behavior from 6.x. This was changed in >>>>> -current unintentionally I think. >>>>> >>>>> I'd appreciate any extra testing. The ULE context switch time >>>>> improvements >>>>> required some changes to the frequency that we recalculate priorities. >>>>> I'm >>>>> mostly interested in hearing whether this causes any regression in >>>>> normal >>>>> workloads. >>>>> >>>>> Those of you still using 4BSD can also verify that the yield changes >>>>> don't >>>>> cause any problems there. >>>>> >>>>> Thanks, >>>>> Jeff >>>> >>>> Jeff, >>>> >>>> Patch applied cleanly, though with new kernel I got a panic just after >>>> boot - on xdm startup, I guess (crashdump wasn't saved), a lot of the >>>> same messages >>>> (copied by hand): >>>> >>>> cpuid = 0 >>>> panic: _mtx_lock_sleep: recursed on non-recursive mutex >>>> audit_mtx@/usr/src/sys/security/audit_worker.c:518 >>>> >>>> and after few seconds system just hangs. >>>> >>>> Any hints? >>>> >>>> -- >>>> Yuri Pankov <yuri.pankov@gmail.com> >>> >>> Sorry for being so verbose... >> >> Did you 'make depend' as well? If you patch -R < yield.diff does this >> kernel work? I'm not sure how my changes could cause this type of bug. >> >> Thanks, >> Jeff >> > > I'm rebuilt kernel with and without your patch (with clean /usr/obj/ every time) > using `make kernel KERNCONF=DARKLIGHT` just to be sure. > > Without your patch, system seems to run stable. With it - I get hard hangs upon > just loading X or upon xdm startup or after xdm login, every time the same. No > messages now, just hangs. Nothing suspicious in /var/log/messages, etc. > > Xorg 7.3 with xf86-video-nv, all ports built yesterday (it was fresh install). > > Anything that I should look at? (as it can be just pilot error). The attached diff is only the changes the fix yield() and sched_yield() to pre-CURRENT states. Can you try this on its own and let me know if it works so I can narrow down the part of the patch causing trouble? Thanks, Jeff > > TIA. > >>> >>> It's UP amd64 with SCHED_ULE >>> >>> kernel config: >>> >>> include GENERIC >>> ident DARKLIGHT >>> >>> nooptions SCHED_4BSD >>> options SCHED_ULE >>> >>> -- >>> Yuri Pankov <yuri.pankov@gmail.com> >>> > > -- > Yuri Pankov <yuri.pankov@gmail.com> > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > [-- Attachment #2 --] Index: kern_switch.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_switch.c,v retrieving revision 1.136 diff -p -u -r1.136 kern_switch.c --- kern_switch.c 20 Sep 2007 20:38:43 -0000 1.136 +++ kern_switch.c 2 Oct 2007 21:41:10 -0000 @@ -133,16 +133,6 @@ choosethread(void) { struct thread *td; -#if defined(SMP) && (defined(__i386__) || defined(__amd64__)) - if (smp_active == 0 && PCPU_GET(cpuid) != 0) { - /* Shutting down, run idlethread on AP's */ - td = PCPU_GET(idlethread); - CTR1(KTR_RUNQ, "choosethread: td=%p (idle)", td); - TD_SET_RUNNING(td); - return (td); - } -#endif - retry: td = sched_choose(); @@ -184,7 +174,7 @@ critical_exit(void) td = curthread; KASSERT(td->td_critnest != 0, ("critical_exit: td_critnest == 0")); -#ifdef PREEMPTION + if (td->td_critnest == 1) { td->td_critnest = 0; if (td->td_owepreempt) { @@ -196,7 +186,6 @@ critical_exit(void) thread_unlock(td); } } else -#endif td->td_critnest--; CTR4(KTR_CRITICAL, "critical_exit by thread %p (%ld, %s) to %d", td, Index: kern_synch.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_synch.c,v retrieving revision 1.301 diff -p -u -r1.301 kern_synch.c --- kern_synch.c 17 Sep 2007 05:27:20 -0000 1.301 +++ kern_synch.c 2 Oct 2007 08:18:19 -0000 @@ -553,8 +553,11 @@ synch_setup(dummy) int yield(struct thread *td, struct yield_args *uap) { - mtx_assert(&Giant, MA_NOTOWNED); - (void)uap; - sched_relinquish(td); + + thread_lock(td); + sched_prio(td, PRI_MAX_TIMESHARE); + mi_switch(SW_VOL, NULL); + thread_unlock(td); + td->td_retval[0] = 0; return (0); } Index: p1003_1b.c =================================================================== RCS file: /home/ncvs/src/sys/kern/p1003_1b.c,v retrieving revision 1.35 diff -p -u -r1.35 p1003_1b.c --- p1003_1b.c 5 Mar 2007 13:10:57 -0000 1.35 +++ p1003_1b.c 2 Oct 2007 21:55:48 -0000 @@ -241,7 +241,8 @@ int sched_yield(struct thread *td, struct sched_yield_args *uap) { - return (ksched_yield(ksched)); + sched_relinquish(curthread); + return 0; } int Index: sched_4bsd.c =================================================================== RCS file: /home/ncvs/src/sys/kern/sched_4bsd.c,v retrieving revision 1.105 diff -p -u -r1.105 sched_4bsd.c --- sched_4bsd.c 21 Sep 2007 04:10:23 -0000 1.105 +++ sched_4bsd.c 2 Oct 2007 08:08:36 -0000 @@ -1324,8 +1324,6 @@ void sched_relinquish(struct thread *td) { thread_lock(td); - if (td->td_pri_class == PRI_TIMESHARE) - sched_prio(td, PRI_MAX_TIMESHARE); SCHED_STAT_INC(switch_relinquish); mi_switch(SW_VOL, NULL); thread_unlock(td); Index: sched_ule.c =================================================================== RCS file: /home/ncvs/src/sys/kern/sched_ule.c,v retrieving revision 1.209 diff -p -u -r1.209 sched_ule.c --- sched_ule.c 24 Sep 2007 00:28:54 -0000 1.209 +++ sched_ule.c 2 Oct 2007 22:26:14 -0000 @@ -2502,8 +2515,6 @@ void sched_relinquish(struct thread *td) { thread_lock(td); - if (td->td_pri_class == PRI_TIMESHARE) - sched_prio(td, PRI_MAX_TIMESHARE); SCHED_STAT_INC(switch_relinquish); mi_switch(SW_VOL, NULL); thread_unlock(td);help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071002215228.Q615>
