From patchwork Wed Oct 29 13:43:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 3460 Received: (qmail 18004 invoked by alias); 29 Oct 2014 13:44:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 17990 invoked by uid 89); 29 Oct 2014 13:44:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com From: "Wilco Dijkstra" To: Subject: [RFC PATCH]: Align large allocations to cacheline Date: Wed, 29 Oct 2014 13:43:54 -0000 Message-ID: <002301cff37e$61c12330$25436990$@com> MIME-Version: 1.0 X-MC-Unique: 114102913435600201 This patch aligns allocations of large blocks to a cacheline on ARM and AArch64. The main goal is to reduce performance variations due to random alignment choices, however it improves performance on several benchmarks as well. SPECFP2000 improves by ~1.5%. Any comments? ChangeLog: 2014-10-29 Wilco Dijkstra * malloc/malloc.c (__libc_malloc): Add support for aligning large blocks. * sysdeps/unix/sysv/linux/aarch64/malloc-sysdep.h: New file. New defines (MALLOC_LARGE_BLOCK_ALIGN), (MALLOC_LARGE_BLOCK_SIZE). * sysdeps/unix/sysv/linux/arm/malloc-sysdep.h: Likewise. --- malloc/malloc.c | 8 ++++++++ sysdeps/unix/sysv/linux/aarch64/malloc-sysdep.h | 23 +++++++++++++++++++++++ sysdeps/unix/sysv/linux/arm/malloc-sysdep.h | 23 +++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/aarch64/malloc-sysdep.h create mode 100644 sysdeps/unix/sysv/linux/arm/malloc-sysdep.h diff --git a/malloc/malloc.c b/malloc/malloc.c index 6cbe9f3..0b0466e 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -2878,6 +2878,14 @@ __libc_malloc (size_t bytes) mstate ar_ptr; void *victim; +#ifdef MALLOC_LARGE_BLOCK_ALIGN + if (bytes > MALLOC_LARGE_BLOCK_SIZE) + { + void *address = RETURN_ADDRESS (0); + return _mid_memalign (MALLOC_LARGE_BLOCK_ALIGN, bytes, address); + } +#endif + void *(*hook) (size_t, const void *) = atomic_forced_read (__malloc_hook); if (__builtin_expect (hook != NULL, 0)) diff --git a/sysdeps/unix/sysv/linux/aarch64/malloc-sysdep.h b/sysdeps/unix/sysv/linux/aarch64/malloc-sysdep.h new file mode 100644 index 0000000..3fe9f72 --- /dev/null +++ b/sysdeps/unix/sysv/linux/aarch64/malloc-sysdep.h @@ -0,0 +1,23 @@ +/* System-specific malloc support functions. AArch64 version. + Copyright (C) 2012-2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define MALLOC_LARGE_BLOCK_ALIGN (64) +#define MALLOC_LARGE_BLOCK_SIZE (16384) + +#include_next + diff --git a/sysdeps/unix/sysv/linux/arm/malloc-sysdep.h b/sysdeps/unix/sysv/linux/arm/malloc-sysdep.h new file mode 100644 index 0000000..3fe9f72 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/malloc-sysdep.h @@ -0,0 +1,23 @@ +/* System-specific malloc support functions. AArch64 version. + Copyright (C) 2012-2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define MALLOC_LARGE_BLOCK_ALIGN (64) +#define MALLOC_LARGE_BLOCK_SIZE (16384) + +#include_next +