From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/15030 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Jeffrey Walton Newsgroups: gmane.linux.lib.musl.general Subject: Re: max_align_t mess on i386 Date: Mon, 16 Dec 2019 10:30:30 -0500 Message-ID: References: <20191214151932.GW1666@brightrain.aerifal.cx> <20191215182242.GA1666@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="125446"; mail-complaints-to="usenet@blaine.gmane.org" To: musl@lists.openwall.com Original-X-From: musl-return-15046-gllmg-musl=m.gmane.org@lists.openwall.com Mon Dec 16 16:30:57 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1igsKm-000WQB-O1 for gllmg-musl@m.gmane.org; Mon, 16 Dec 2019 16:30:56 +0100 Original-Received: (qmail 7985 invoked by uid 550); 16 Dec 2019 15:30:53 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 7967 invoked from network); 16 Dec 2019 15:30:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to; bh=VGib52ov2u1Qk0lX6vQCZv/UDhBYn7laVXiUBghHLHQ=; b=rlRbWEfhr88ko3ErwKyGTRMXPE+M3X5QOxU8IUBVFQ3Fdk2lYVhHaN5c8B7VY0aV4v JA6Zx0G1lDUT8gLz3dLHah9vHrNjPfYLvSRLJDMrnf97PX1FOBvVvfNa7WHPjOjauEt4 Nux9pDe//oD2aas4/hgBkijOUqzbYneDtuAKTS6t8G6EY2aWAiFWruOdewM3X1+8Jam/ Sd5y54ouXeBhcOgEqlVOIp9UcFZbNN3FIfutO0nM9wIDHTRQYyIK99e2X123phMV01qZ CZ1mlEEuYcg+EjoXyxFtOBYkQ6H0FV6F6FLiMmujg/sBQzE3ZJ+TPtg3UODvtzmt2yYN NmyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to; bh=VGib52ov2u1Qk0lX6vQCZv/UDhBYn7laVXiUBghHLHQ=; b=eEYZID7gEtMxrAbbLQ6mZ/g007yJ3RHIeFAKm62NLZTrwNmGDatu6SrmykRnvi16Rs lUGw8PMrL1eDCCZdVEzSRHHwpMzaWkUEAJStM1XHbz77P7MaJuQC/rD4lbmqZcqA/ezC RtyrBuzMP50NHPfFwVbb+CteW1alF7kgE4dpXdXVa5y+m8jc6AjRBJ3B1tP0ladZyYI0 sh0LuvWMGH3/fqSDlRG9tQ0xKLXdLQPFZ4s460kv0/ZJ9QflV9LemgaIrVINJ6YY4gOM qMiWuz3zZAtqhnDdAtXN6QuZnBzF+mR2zbX2DJ/d6jl9Hy2RSfymwIOTBBR6Q/dq7+Lj fvMw== X-Gm-Message-State: APjAAAUiz7sIao3hIKpJLzcJk+cwq72tRuU3Ms/AA6d3uKYXZep/COVl IxLJ56DWNedZFoQeWhrAtr/lHS3CwkuZ2in/Mg1YTUZq X-Google-Smtp-Source: APXvYqyCjvbBDUSbdLElKlpSM4N8ifqO3dxFRjmHyBP/REjT3xvnc/Km5XboVtkczEQtqh/h3mq+jdJRK9R8edB4M28= X-Received: by 2002:a5d:9b04:: with SMTP id y4mr11666801ion.212.1576510241037; Mon, 16 Dec 2019 07:30:41 -0800 (PST) In-Reply-To: <20191215182242.GA1666@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:15030 Archived-At: On Sun, Dec 15, 2019 at 1:22 PM Rich Felker wrote: > > On Sun, Dec 15, 2019 at 01:06:29PM -0500, Jeffrey Walton wrote: > > On Sat, Dec 14, 2019 at 10:19 AM Rich Felker wrote: > > > > > > In reserching how much memory could be saved, and how practical it > > > would be, for the new malloc to align only to 8-byte boundaries > > > instead of 16-byte on archs where alignof(max_align_t) is 8 (pretty > > > much all 32-bit archs), I discovered that GCC quietly changed its > > > idead of i386 max_align_t to 16-byte alignment in GCC 7, to better > > > accommodate the new _Float128 access via SSE. Presumably (I haven't > > > checked) the change is reflected with changes in the psABI document to > > > make it "official". > > > > Be careful with policy changes like this. The malloc (3) man page says: > > Generally, you should look to the C11 or POSIX (man 3p) specifications > for the functions rather than the "man 3" ones, but here it's pretty > close to the same, just imprecisely worded: > > > The malloc() and calloc() functions return a pointer to the > > allocated memory that is suitably aligned for any kind of variable. > > > > I expect to be able to use a pointer returned by malloc (and friends) > > in MMX, SSE and AVX functions. > > "Any kind of variable" isn't "any kind of load/store instruction". For > example you most certainly will not get 32- or 64-byte alignment that > you may want for AVX-256 or AVX-512 without memalign. GCC tells us the largest alignment that we can expect: $ gcc -dM -E - A max_align_t > (and corresponding malloc alignment constraint) that heavily aligned > would be awful to use, with memory waste possibly exceeding 1000% and > over 500% likely for real-world data structures. Over-alignment also > weakens hardening properties by making pointers more predictable. It sounds like you are moving the fragmentation problem from the runtime library to the application. (When fragmentation is a problem). Jeff