From owner-freebsd-smp Thu Nov 16 14:43: 7 2000 Delivered-To: freebsd-smp@freebsd.org Received: from io.yi.org (h24-69-199-88.gv.shawcable.net [24.69.199.88]) by hub.freebsd.org (Postfix) with ESMTP id 9F70937B479; Thu, 16 Nov 2000 14:43:04 -0800 (PST) Received: from io.yi.org (localhost.gvcl1.bc.wave.home.com [127.0.0.1]) by io.yi.org (Postfix) with ESMTP id DC1E6BA7A; Thu, 16 Nov 2000 14:42:59 -0800 (PST) X-Mailer: exmh version 2.1.1 10/15/1999 To: John Baldwin Cc: smp@FreeBSD.ORG, cp@bsdi.com, jake@io.yi.org Subject: Re: cvs commit: src/sys/kern kern_timeout.c In-Reply-To: Message from John Baldwin of "Thu, 16 Nov 2000 13:26:57 PST." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 16 Nov 2000 14:42:59 -0800 From: Jake Burkholder Message-Id: <20001116224259.DC1E6BA7A@io.yi.org> Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > > On 16-Nov-00 John Baldwin wrote: > > jhb 2000/11/16 13:20:53 PST > > > > Modified files: > > sys/kern kern_timeout.c > > Log: > > The recent changes to msleep() and mawait() resulted in timeout() and > > untimeout() not being called with Giant in those functions. For now, > > use the sched_lock to protect the callout wheel in softclock() and in > > the various timeout and callout functions. > > > > Noticed by: tegge > > Big Kudos to Tor for finding this! Using the sched_lock here is more or less a > bandaid for now. A possible long-term solution might be to use a dedicated > sleep lock to protect the callout wheel. However, if you do this, then you > can't be holding a spinlock when you call into timeout and friends. If we add > in a lock to protect teh sleep queues, then we might be able to push sched_lock > further down into msleep() and mawait(), so that we don't need sched_lock until > after we call timeout and before we call untimeout, but I'm still thinking > about this. Does anyone else have any ideas? One thing I am worried about is > whether the overhead of the extra locks involved (sleepqueue locks, probably > process locks (but we will need those anyway), and a callout wheel lock) will > end up negating the performance gain from not having sched_lock protect so many > different things. I think we need a separate spin lock for the callout wheel, ala BSD/OS's callout_mtx. Hardclock looks at the callout wheel and is now a fast interrupt, so it can't acquire a sleep mutex. Its a little paranoid because hardclock doesn't actually traverse any lists, it just checks if the current callout bucket is empty, and potentially schedules softclock, but you could miss a very short timeout on an smp system. ticks could also get incremented in the middle of softclock's test for if the callout's time has come. I have patches that do this and make softclock INTR_MPSAFE, I just need to test them. There's actually another major problem with this. The run queue and sleep queue use the same list linkage in struct proc, so its not safe to release sched_lock while you're on the sleep queue. If the process blocks on giant in CURSIG, the sleep queue will get corrupted. We really need to split the run queue/sleep queue linkage. Jake > > -- > > John Baldwin -- http://www.FreeBSD.org/~jhb/ > PGP Key: http://www.baldwin.cx/~john/pgpkey.asc > "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-smp" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message