From owner-freebsd-arch Fri Mar 29 13:30:59 2002 Delivered-To: freebsd-arch@freebsd.org Received: from beastie.mckusick.com (beastie.mckusick.com [209.31.233.184]) by hub.freebsd.org (Postfix) with ESMTP id AAAFF37B400; Fri, 29 Mar 2002 13:30:53 -0800 (PST) Received: from beastie.mckusick.com (localhost [127.0.0.1]) by beastie.mckusick.com (8.11.6/8.11.6) with ESMTP id g2TLUrD01863; Fri, 29 Mar 2002 13:30:53 -0800 (PST) (envelope-from mckusick@beastie.mckusick.com) Message-Id: <200203292130.g2TLUrD01863@beastie.mckusick.com> To: John Baldwin Subject: Re: curthread vs. passing thread pointers around Cc: arch@FreeBSD.ORG In-Reply-To: Your message of "Fri, 29 Mar 2002 14:32:22 EST." Date: Fri, 29 Mar 2002 13:30:52 -0800 From: Kirk McKusick 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 Date: Fri, 29 Mar 2002 14:32:22 -0500 (EST) From: John Baldwin To: arch@FreeBSD.ORG Subject: curthread vs. passing thread pointers around Sender: owner-freebsd-arch@FreeBSD.ORG List-ID: List-Archive: (Web Archive) During a discussion on the smp@ list about changes to the suser() API to make use of td_ucred, it was brought up that the new suser() would be assuming that the passed in thread pointer was curthread so why not just use curthread in suser() and not pass in a pointer at all. There are several places in the kernel where the same assumption is made. Thus, my question is: which general approach should we follow, and should we perhaps switch to using explicit curthread's everywhere and stop passing thread pointers around on the stack? -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ The whole business of passing proc pointers got started in the late 1980's when we went on a big kernel cleanup campaign to get rid of all references to u.u_variable. Most of that efforts worked out well. For example, having most kernel functions return an error rather than stuffing it in u.u_error. That also explains the numerous /* XXX */ comments scattered through the kernel whenever curproc (or now curthread) gets used; the idea was that the proc (or thread) pointer should have been a parameter. A few years ago I set out to try to clean up all those global references, and found that I had to add a proc pointer parameter to nearly every function in the top half of the kernel. I concluded that the extra overhead was simply not worth it, and that we should just continue using the global pointer as we do now. There are still instances where credentials should be passed as parameters since it is not the case that using the current threads credential is the right thing to do. For example, the NFS server wants to use the credential of the incoming request, not its own in deciding filesystem access. I can also believe that suser() might have places where it would want to use a different credential than that of the current thread. So, while removing proc/thread parameters from existing functions is reasonable, we should consider whether they should be replaced with pointers to credentials. Kirk McKusick To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message