From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 6 06:50:22 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id F1F5AF6C for ; Wed, 6 Nov 2013 06:50:22 +0000 (UTC) (envelope-from dt71@gmx.com) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8A67525EB for ; Wed, 6 Nov 2013 06:50:22 +0000 (UTC) Received: from [157.181.98.186] ([157.181.98.186]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MTSmp-1VEolt2H0p-00SSLF for ; Wed, 06 Nov 2013 07:50:14 +0100 Message-ID: <5279E686.5090508@gmx.com> Date: Wed, 06 Nov 2013 07:49:42 +0100 From: dt71@gmx.com User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:24.0) Gecko/20100101 Firefox/24.0 SeaMonkey/2.21 MIME-Version: 1.0 To: Konstantin Belousov Subject: Re: alignment of thread-local storage References: <52799E85.4050002@gmx.com> <20131106023335.GZ59496@kib.kiev.ua> In-Reply-To: <20131106023335.GZ59496@kib.kiev.ua> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:rf98ioX5Qw7d2EQT+xX8EiAAPIwWKLMZiayeLYCWX8OADepgNhr nOmmom4KTuh8Hm0AVDL7p+yyqoo/p0K8EZsTqsvY8pn7fTvoxRQ2dO/k8RZ6AEapfCZl+pw jIB3vLh5ykVyUQVwrb9k6Js34j148xFI8ekjTft2hBOdjbdMTwTkWOlU6lw/9BCQM5r1F9q 6IQ2dSfzgWlwulxcTuMwQ== Cc: FreeBSD Hackers , jasone@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Nov 2013 06:50:23 -0000 Konstantin Belousov wrote, On 11/06/2013 03:33: > On Wed, Nov 06, 2013 at 02:42:29AM +0100, dt71@gmx.com wrote: >> Starting with revision 191847 of Clang/LLVM, a bus error tends to happen in realloc() under special circumstances. >> > As I understand, the rev. of clang referenced is higher than what we have > in src/contrib, right ? Correct. >> - The __jemalloc_thread_allocated_tls variable is updated using a processor instruction that requires alignment (paddq), that is, as of Clang/LLVM r191847. The variable is defined as: >> __thread thread_allocated_t __attribute__((tls_model("initial-exec"))) thread_allocated_tls = {0,0}; >> >> - The variable turns out to be insufficiently aligned, having only 4-byte alignment. > > I do not see anything in the jemalloc sources which indicate that > thread_allocated must be 16-bytes aligned. The natural aligment for the > structure is 8 bytes. Which is still strictly more than the actual alignment (8 vs 4). Clang even attempts to use certain vector-instructions or what, so it supposedly increases its alignment-request appropriately.