From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>,
barebox@lists.infradead.org
Subject: Re: malloc() alignment on 32 bit
Date: Mon, 19 Sep 2022 14:33:59 +0100 [thread overview]
Message-ID: <cacddc32-3b0f-7014-393c-8c93e5971627@pengutronix.de> (raw)
In-Reply-To: <ly7d1z1qvs.fsf@ensc-pc.intern.sigma-chemnitz.de>
On 19.09.22 13:37, Enrico Scholz wrote:
> Hello,
>
> on an iMX6ull I stumpled across
>
> | zstd_decomp_init:536 workspace=8ff1a004+161320
> | ERROR: initcall ubifs_init+0x1/0xc4 failed: Invalid argument
>
> which is caused by
>
> | static int zstd_decomp_init(void)
> | void *wksp = malloc(wksp_size);
> | ...
> | ZSTD_DCtx* ZSTD_initStaticDCtx(void *workspace, size_t workspaceSize)
> | if ((size_t)workspace & 7) return NULL; /* 8-aligned */
>
>
> Trivial fix would be 'memalign(8, wksp_size)', but is it really ok that
> malloc() for 32 bit has only an alignment of 4?
>
> Relevant code seems to be in common/tlsf.c
>
> | enum tlsf_private
> | {
> | #if defined (TLSF_64BIT)
> | /* All allocation sizes and addresses are aligned to 8 bytes. */
> | ALIGN_SIZE_LOG2 = 3,
> | #else
> | /* All allocation sizes and addresses are aligned to 4 bytes. */
> | ALIGN_SIZE_LOG2 = 2,
> | #endif
>
> 'ldrd/strd' require 8 byte alignment which might break with such
> alignment.
I recently learnt too that on 32-bit TLSF only has 4 byte alignment.
I also think that this is too low. 8 byte alignment sounds good IMO.
Cheers,
Ahmad
>
>
> Enrico
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2022-09-19 13:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-19 12:37 Enrico Scholz
2022-09-19 13:33 ` Ahmad Fatoum [this message]
2022-09-19 13:57 ` Sascha Hauer
2022-09-19 14:24 ` Enrico Scholz
2022-09-20 7:36 ` Sascha Hauer
2022-09-28 10:24 ` Enrico Scholz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cacddc32-3b0f-7014-393c-8c93e5971627@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=enrico.scholz@sigma-chemnitz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox