From owner-svn-src-all@FreeBSD.ORG Tue Nov 4 10:31:43 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 299DDED; Tue, 4 Nov 2014 10:31:43 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 89D4A906; Tue, 4 Nov 2014 10:31:42 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id sA4AVaCp081045 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 4 Nov 2014 12:31:36 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua sA4AVaCp081045 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id sA4AVaMd081044; Tue, 4 Nov 2014 12:31:36 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 4 Nov 2014 12:31:36 +0200 From: Konstantin Belousov To: Bruce Evans Subject: Re: svn commit: r274017 - head/sys/kern Message-ID: <20141104103136.GS53947@kib.kiev.ua> References: <201411030746.sA37kpPu037113@svn.freebsd.org> <54573AEE.9010602@freebsd.org> <54573B87.7000801@freebsd.org> <54573CD2.1000702@selasky.org> <20141103092132.GH29497@dft-labs.eu> <20141103100847.GK53947@kib.kiev.ua> <20141104045159.E1605@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141104045159.E1605@besplex.bde.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: Hans Petter Selasky , Mateusz Guzik , Mateusz Guzik , jmallett@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-head@freebsd.org, Julian Elischer X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Nov 2014 10:31:43 -0000 On Tue, Nov 04, 2014 at 06:03:29AM +1100, Bruce Evans wrote: > Why not just use a C99 VLA? It doesn't require any compiler magic except > being a C99 compiler (I haven't seen any of those yet, but some approximate > C99 for VLAs). I use this in delayed signal delivery code in libthr. > > You (kib) didn't like using alloca() when I tried to talk you into using > it to get aligned structs for SSE long ago. __builtin_alloca() has more > chance of forcing the alignment than VLA,s but this is fragile. FreeBSD > still uses -mpreferred-stack-boundary on i386 with gcc. This option is > broken (unsupported) with clang, but is less needed since clang does > alignment better. You did convinced me to use alloca for transient copy of extended FPU state in signal code. > How do the __builtin_alloca()'s in your FP code (recently synced to i386 > where alignment is more difficult by jhb) work? I think they give > 16-byte alignment in all cases, but some cases seem to need 64-byte > alignment and do this by hand. Old code seems to be little changed, > so I think it still does 16-byte alignment by hand. It does not require any alignment. All FPU accesses (storing and loading the state) happen to the properly aligned save area below the pcb for userspace state. Apart from handling alignment, it is also required (or hard to make any other way) to make XSAVEOPT optimization working. The allocated buffer is used only to put together the scattered pieces before copyout or after copyin.