Bug 203877 - Increase maximum allowed alignment for memalign()
Summary: Increase maximum allowed alignment for memalign()
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.4.1
Platform: Fedora RPMs Linux
: NOR crash
Target Milestone: blocking3.5.1
Assignee: Nicholas Nethercote
URL:
Keywords:
: 272940 301229 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-08-14 20:24 UTC by Alex Ivershen
Modified: 2012-06-15 22:54 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Ivershen 2009-08-14 20:24:24 UTC
Version:           3.4.1 (using KDE 4.3.0)
Compiler:          gcc 4.1 
OS:                Linux
Installed from:    Fedora RPMs

An application that causes VG_(arena_memalign) crash is allocating memory with posix_memalign() using 8 MB alignment. 8MB alignment is required for DMA access to a disk array, memory chunks have to be page-aligned.

Memcheck prevents the calls to memalign() with values greater than 1Mb. I'd like to ask this check to be changed to 8388608 in m_mallocfree.c. Memory-page alignemnt is a fairly common scenario. 

PS: This is a follow-up to an old bug report https://bugs.kde.org/show_bug.cgi?id=187760
Comment 1 Tom Hughes 2011-08-23 10:17:15 UTC
*** Bug 272940 has been marked as a duplicate of this bug. ***
Comment 2 Tom Hughes 2011-08-23 10:21:34 UTC
I'd like to understand what the reasoning was for limiting the alignment before changing this, but we have had several requests for it now, so it does seem like something we need to give some thought to.

Does anybody know why we have the limit? Presumably it's because of the potential wastefulness because we have to allocate a large block in order to ensure the alignment?

It looks like we return the spare memory to the heap though, and the larger the alignment the larger that spare fragment will be and the more useful it is likely to be for future allocations?
Comment 3 Yann Droneaud 2011-10-14 16:16:50 UTC
I have the same problem regarding a 4MBytes alignment request.
Alignment on 4MBytes a condition to (eventually) benefit from Linux' Transparent Huge Page http://lwn.net/Articles/423584/ .
Even if it's not a concern when running under valgrind, having to build a dedicated test program with alignment disabled, is not 'user-friendly'.

Why not add an option to memcheck to allow user defined max alignment ?
Comment 4 Benjamin Herrenschmidt 2012-06-09 23:46:06 UTC
Same problem here. qemu-system-ppc64 -M pseries requires a 16M aligned allocation for the MMU hash table which fails.

16M can be reasonably common (it's the standard huge page size on ppc64).

What is the reason for having a limit to begin with ?
Comment 5 Philippe Waroquiers 2012-06-15 22:21:56 UTC
Maximum increased to 16 Mb in revision 12642
Note : after discussion, it was deemed better to keep a check on plausible
alignment maximum, rather than authorize full freedom.
Comment 6 Philippe Waroquiers 2012-06-15 22:22:34 UTC
*** Bug 301229 has been marked as a duplicate of this bug. ***
Comment 7 Benjamin Herrenschmidt 2012-06-15 22:54:40 UTC
Thanks !