From owner-freebsd-arch Sun Aug 18 12:33:44 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2475F37B400 for ; Sun, 18 Aug 2002 12:33:41 -0700 (PDT) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9B44843E77 for ; Sun, 18 Aug 2002 12:33:40 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) by apollo.backplane.com (8.12.5/8.12.4) with ESMTP id g7IJXYdc072983; Sun, 18 Aug 2002 12:33:35 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.5/8.12.4/Submit) id g7IJXYC5072982; Sun, 18 Aug 2002 12:33:34 -0700 (PDT) (envelope-from dillon) Date: Sun, 18 Aug 2002 12:33:34 -0700 (PDT) From: Matthew Dillon Message-Id: <200208181933.g7IJXYC5072982@apollo.backplane.com> To: Julian Elischer Cc: Ian Dowse , Bruce Evans , arch@FreeBSD.ORG Subject: Re: Solving the stack gap issue References: 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 Sun, 18 Aug 2002, Ian Dowse wrote: :> :> If there is agreement on the td vs. curthread issue, then that would :> obviously be easy to change. : :A few days ago, Peter gave some comments as to the expense of using :curthread. I must admit this is something where some architectureal :guidance would be a good thing.... maybe something like :"Use a local if you need to access a Per-cpu variable more than twice :in a function", and "passing a thread pointer as an argument (is/is not) :preferable to calling curtread explicitly in the child function". : :Julian I would consider this to be more expensive: proc1() { struct thread *td = curthread; ... proc2(td) } proc2(td) { ... } And this to be less expensive: proc1() { proc2(); } proc2() { struct thread *td = curthread; ... use td several times ... } At least for I386. Ultimately I think this will be generally true on any architecture. If a procedure uses 'curthread' multiple times loading it into a local at the top of the procedure should be a sufficient optimization. Passing td around to dozens or hundreds of procedures just for the sake of avoiding accessing 'curthread' is bad design. -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message