From owner-freebsd-hackers Fri Jul 12 16:59:55 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 90BA437B400 for ; Fri, 12 Jul 2002 16:59:51 -0700 (PDT) Received: from canning.wemm.org (canning.wemm.org [192.203.228.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3E81943EB1 for ; Fri, 12 Jul 2002 16:59:51 -0700 (PDT) (envelope-from peter@wemm.org) Received: from fw.wemm.org (canning.wemm.org [192.203.228.65]) by canning.wemm.org (Postfix) with ESMTP id 1A3A22A7F2 for ; Fri, 12 Jul 2002 16:33:31 -0700 (PDT) (envelope-from peter@wemm.org) Received: from overcee.wemm.org (overcee.wemm.org [10.0.0.3]) by fw.wemm.org (Postfix) with ESMTP id ACCB14C241 for ; Fri, 12 Jul 2002 16:33:30 -0700 (PDT) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by overcee.wemm.org (Postfix) with ESMTP id 9259A3811; Fri, 12 Jul 2002 16:33:30 -0700 (PDT) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: Terry Lambert Cc: Yar Tikhiy , hackers@freebsd.org Subject: Re: Large variables on stack In-Reply-To: <3D2F4DE4.932D4995@mindspring.com> Date: Fri, 12 Jul 2002 16:33:30 -0700 From: Peter Wemm Message-Id: <20020712233330.9259A3811@overcee.wemm.org> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Terry Lambert wrote: > Yar Tikhiy wrote: > > As I see, there are many spots in the FreeBSD userland sources where > > multi-kilobyte automatic variables (e.g., string buffers) are used. > > I've been taught that such variables would better be static or > > allocated on heap. > > > > So the following question comes to my mind: To stay portable to a > > reasonable degree, how large on-stack variables can be used? > > Depends on the system and the stack. Typically, if you want your > code to be portable, you will use as little stack as possible: > > -------------- --------------------------------------------------- > Space Stack size > -------------- --------------------------------------------------- > user 8MB (FreeBSD: 64MB) > user thread 8K (or settable by user on pthread_create) > user signals 40K[8K] (or settable via sigaltstack) > kernel 8K (max; usable is closer to 4K) > -------------- --------------------------------------------------- > > Note that this assumes none of the stack is used elsewhere; in the > kernel example, ther is slightly over 3K used, on average, by the > time you get to run. FWIW; This isn't correct for -current anymore. We have about 7.6K of kernel stack now, and a guard page below it to force a double fault in case of an oveflow. The pcb is above the kernel stack now, and the user area is completely seperate. Cheers, -Peter -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message