From owner-freebsd-hackers@freebsd.org Wed Sep 14 11:58:32 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 01C84BDA333 for ; Wed, 14 Sep 2016 11:58:32 +0000 (UTC) (envelope-from joerg@bec.de) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:c:538::196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C3D3615A1 for ; Wed, 14 Sep 2016 11:58:31 +0000 (UTC) (envelope-from joerg@bec.de) Received: from britannica.bec.de (p200300D2ABD048104639C4FFFE599710.dip0.t-ipconnect.de [IPv6:2003:d2:abd0:4810:4639:c4ff:fe59:9710]) (Authenticated sender: joerg@bec.de) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id EED2F1720C2 for ; Wed, 14 Sep 2016 13:58:21 +0200 (CEST) Date: Wed, 14 Sep 2016 13:58:20 +0200 From: Joerg Sonnenberger To: freebsd-hackers@freebsd.org Subject: Re: Is replacing alloca(3) where possible a good thing to do? Message-ID: <20160914115820.GA12534@britannica.bec.de> Mail-Followup-To: freebsd-hackers@freebsd.org References: <3fe9ba0e-0089-a59c-a09e-8c6f8b74b6bc@openmailbox.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.2 (2016-07-01) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Sep 2016 11:58:32 -0000 On Wed, Sep 14, 2016 at 01:46:35PM +0200, Ed Schouten wrote: > So the best solution is to replace any use of alloca() with > malloc()/free(). That said, as you were interested in making such > changes in cddl/*, I guess you'll also have to go through the process > of sending those patches to Illumos. Blindly replacing them makes little sense. alloca provides zero-cost freeing and is also much cheaper than malloc. It should be limited to reasonable sizes though, where reasonable is typically < 1MB per thread. Joerg