From owner-freebsd-smp Wed Sep 11 8:38:58 2002 Delivered-To: freebsd-smp@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9798E37B400 for ; Wed, 11 Sep 2002 08:38:55 -0700 (PDT) Received: from iguana.icir.org (iguana.icir.org [192.150.187.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 54CEE43E4A for ; Wed, 11 Sep 2002 08:38:55 -0700 (PDT) (envelope-from rizzo@iguana.icir.org) Received: from iguana.icir.org (localhost [127.0.0.1]) by iguana.icir.org (8.12.3/8.11.3) with ESMTP id g8BFcsIb090604; Wed, 11 Sep 2002 08:38:54 -0700 (PDT) (envelope-from rizzo@iguana.icir.org) Received: (from rizzo@localhost) by iguana.icir.org (8.12.3/8.12.3/Submit) id g8BFcsmL090603; Wed, 11 Sep 2002 08:38:54 -0700 (PDT) (envelope-from rizzo) Date: Wed, 11 Sep 2002 08:38:54 -0700 From: Luigi Rizzo To: smp@freebsd.org Subject: wakeup handling on SMP boxes Message-ID: <20020911083854.A88921@iguana.icir.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Hi, I have a question about the handling of wakeup on SMP machine. (I am looking at RELENG_4, but i believe the same thing happens on CURRENT with threads instead of processes). Imagine the following situation -- all CPUs are running cpu-bound processes (say, all with the same priority), and at some point a wakeup() is invoked which awakes one or more sleeping processes. My understanding of the behaviour is that: + the processor handling the wakeup will suspend the curproc and, eventually, invoke need_resched(); + on this same processor, the priority of the newly awaken process is compared with the one of the suspended process; + if the comparison succeeds, the suspended process is preempted and the new one runs; otherwise, the new process will have a chance at the next voluntary descheduling or roundrobin(); Am I correct ? This seems to suggest that the priority ordering might be violated for as much as kern.quantum, after which the roundrobin() and forward_roundrobin() will do the right thing. The only reason why this more or less works in practice is that the sleeping process likely has raised its priority in the tsleep() call, so it will preempt the process running on the processor handling the wakeup(). On the other hand, there is no guarantee that this process is the one with the lowest priority among those currently running. I guess to fix this one would need to determine if one of the processes needs to be kicked out and replaced with the new one, by invoking an Xcpuast IPI on the specific processor. Any reason why this is not done ? Is the call too expensive so one prefers to tolerate the temporary inconsistency ? cheers luigi To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message