From owner-freebsd-arch Sat Jan 19 9:31:10 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 0185E37B41D for ; Sat, 19 Jan 2002 09:30:58 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id EAA22551; Sun, 20 Jan 2002 04:30:51 +1100 Date: Sun, 20 Jan 2002 04:32:16 +1100 (EST) From: Bruce Evans X-X-Sender: To: Julian Elischer Cc: Subject: Re: doreti() and userret() In-Reply-To: <3C493A80.F77A2283@elischer.org> Message-ID: <20020120034844.A5320-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sat, 19 Jan 2002, Julian Elischer wrote: > Userret() is supposed to be called the last thing before the > processor is returned to userland.. At least on i386's, this is only true for the pessimized returns from syscall() and trap(). Returns from interrupt handlers normally just return. They sometimes (rarely) go through ast() to handle cases where userret() would do something. In my version of FreeBSD, userret() is almost a no-op and almost all the things that were in userret() are in ast(). > As such it is called from syscall() and from fork_return(). > However AFTER they call it doreti() is called, which in turn > calls ast which sometimes calls userret() again..... > I can't help but feel that there could be some retionalisation there.. There may be any number of calls to userret() for a single return to userland, to handle events that arrive while previous calls are being processed. Unnecessary calls are just pessimizations. In -current there is one call in syscall(), etc. and a loop in ast() that may make any number of calls. The loop must check for new events atomically with exiting. The complications for this are best handled in ast(). > Also, either userret() is the last thing to be called or > ast() is, or maybe doreti is, but > certainly they can't ALL be the last thing called before the kernel returns > to user mode. The logical order is (doreti, ast, userret, iret). > Is it possible that we could take the userret() out of > syscall() and fork_return() > and just make sure that it is always called from doreti()? I haven't completely taken it out. I do the pri_level setting inline and call userret() only to handle the PS_PROFIL case. I think -current only needs it for precisely these things too. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message