From 4fd995ea5a2f9fada2e298bb1b828e510eb2ad29 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 11 Aug 2019 23:09:23 +0200 Subject: add patch info to malloc_stats --- src/allocators/glibc.py | 4 +-- .../glibc/glibc_2.28_no_passive_falsesharing.patch | 22 --------------- .../glibc_2.28_no_passive_falsesharing_fancy.patch | 25 ---------------- .../glibc/glibc_2.29_no_passive_falsesharing.patch | 30 ++++++++++++++++++++ .../glibc_2.29_no_passive_falsesharing_fancy.patch | 33 ++++++++++++++++++++++ 5 files changed, 65 insertions(+), 49 deletions(-) delete mode 100644 src/allocators/glibc/glibc_2.28_no_passive_falsesharing.patch delete mode 100644 src/allocators/glibc/glibc_2.28_no_passive_falsesharing_fancy.patch create mode 100644 src/allocators/glibc/glibc_2.29_no_passive_falsesharing.patch create mode 100644 src/allocators/glibc/glibc_2.29_no_passive_falsesharing_fancy.patch diff --git a/src/allocators/glibc.py b/src/allocators/glibc.py index 94d3c24..8ccd8a0 100644 --- a/src/allocators/glibc.py +++ b/src/allocators/glibc.py @@ -38,9 +38,9 @@ glibc_notc = Glibc("glibc-noThreadCache", color="xkcd:maroon") glibc_nofs = Glibc("glibc-noFalsesharing", - patches=["{patchdir}/glibc_2.28_no_passive_falsesharing.patch"], + patches=["{patchdir}/glibc_2.29_no_passive_falsesharing.patch"], color="xkcd:pink") glibc_nofs_fancy = Glibc("glibc-noFalsesharingClever", - patches=["{patchdir}/glibc_2.28_no_passive_falsesharing_fancy.patch"], + patches=["{patchdir}/glibc_2.29_no_passive_falsesharing_fancy.patch"], color="xkcd:orange") diff --git a/src/allocators/glibc/glibc_2.28_no_passive_falsesharing.patch b/src/allocators/glibc/glibc_2.28_no_passive_falsesharing.patch deleted file mode 100644 index fcc695c..0000000 --- a/src/allocators/glibc/glibc_2.28_no_passive_falsesharing.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/malloc/malloc.c b/malloc/malloc.c -index 27cf6137c2..3aadaddd1d 100644 ---- a/malloc/malloc.c -+++ b/malloc/malloc.c -@@ -4172,6 +4172,9 @@ _int_free (mstate av, mchunkptr p, int have_lock) - - #if USE_TCACHE - { -+ /* Check if chunk is from our own arena. */ -+ if (av == thread_arena) -+ { - size_t tc_idx = csize2tidx (size); - if (tcache != NULL && tc_idx < mp_.tcache_bins) - { -@@ -4201,6 +4204,7 @@ _int_free (mstate av, mchunkptr p, int have_lock) - return; - } - } -+ } - } - #endif - diff --git a/src/allocators/glibc/glibc_2.28_no_passive_falsesharing_fancy.patch b/src/allocators/glibc/glibc_2.28_no_passive_falsesharing_fancy.patch deleted file mode 100644 index 044909b..0000000 --- a/src/allocators/glibc/glibc_2.28_no_passive_falsesharing_fancy.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff --git a/malloc/malloc.c b/malloc/malloc.c -index 27cf6137c2..fbd311801d 100644 ---- a/malloc/malloc.c -+++ b/malloc/malloc.c -@@ -4172,6 +4172,12 @@ _int_free (mstate av, mchunkptr p, int have_lock) - - #if USE_TCACHE - { -+ /* Check if chunk is from our own arena or false sharing is not possible -+ because the chunk is cache line aligned and it's size is a multiple -+ of a cacheline */ -+ if (av == thread_arena -+ || (((size_t)p & 63) == 0 && ((size + 2*SIZE_SZ) % 64) == 0)) -+ { - size_t tc_idx = csize2tidx (size); - if (tcache != NULL && tc_idx < mp_.tcache_bins) - { -@@ -4201,6 +4207,7 @@ _int_free (mstate av, mchunkptr p, int have_lock) - return; - } - } -+ } - } - #endif - diff --git a/src/allocators/glibc/glibc_2.29_no_passive_falsesharing.patch b/src/allocators/glibc/glibc_2.29_no_passive_falsesharing.patch new file mode 100644 index 0000000..7d0f23f --- /dev/null +++ b/src/allocators/glibc/glibc_2.29_no_passive_falsesharing.patch @@ -0,0 +1,30 @@ +diff --git a/malloc/malloc.c b/malloc/malloc.c +index 0abd653be2..eaefd3bd7c 100644 +--- a/malloc/malloc.c ++++ b/malloc/malloc.c +@@ -4194,6 +4194,9 @@ _int_free (mstate av, mchunkptr p, int have_lock) + + #if USE_TCACHE + { ++ /* Check if chunk is from our own arena. */ ++ if (av == thread_arena) ++ { + size_t tc_idx = csize2tidx (size); + if (tcache != NULL && tc_idx < mp_.tcache_bins) + { +@@ -4223,6 +4226,7 @@ _int_free (mstate av, mchunkptr p, int have_lock) + return; + } + } ++ } + } + #endif + +@@ -4997,6 +5001,7 @@ __malloc_stats (void) + memset (&mi, 0, sizeof (mi)); + __libc_lock_lock (ar_ptr->mutex); + int_mallinfo (ar_ptr, &mi); ++ fprintf (stderr, "false sharing path by muhq\n"); + fprintf (stderr, "Arena %d:\n", i); + fprintf (stderr, "system bytes = %10u\n", (unsigned int) mi.arena); + fprintf (stderr, "in use bytes = %10u\n", (unsigned int) mi.uordblks); diff --git a/src/allocators/glibc/glibc_2.29_no_passive_falsesharing_fancy.patch b/src/allocators/glibc/glibc_2.29_no_passive_falsesharing_fancy.patch new file mode 100644 index 0000000..24fbe7a --- /dev/null +++ b/src/allocators/glibc/glibc_2.29_no_passive_falsesharing_fancy.patch @@ -0,0 +1,33 @@ +diff --git a/malloc/malloc.c b/malloc/malloc.c +index 0abd653be2..71b2d433ba 100644 +--- a/malloc/malloc.c ++++ b/malloc/malloc.c +@@ -4194,6 +4194,12 @@ _int_free (mstate av, mchunkptr p, int have_lock) + + #if USE_TCACHE + { ++ /* Check if chunk is from our own arena or false sharing is not possible ++ because the chunk is cache line aligned and it's size is a multiple ++ of a cacheline */ ++ if (av == thread_arena ++ || (((size_t)p & 63) == 0 && ((size + 2*SIZE_SZ) % 64) == 0)) ++ { + size_t tc_idx = csize2tidx (size); + if (tcache != NULL && tc_idx < mp_.tcache_bins) + { +@@ -4223,6 +4229,7 @@ _int_free (mstate av, mchunkptr p, int have_lock) + return; + } + } ++ } + } + #endif + +@@ -4997,6 +5004,7 @@ __malloc_stats (void) + memset (&mi, 0, sizeof (mi)); + __libc_lock_lock (ar_ptr->mutex); + int_mallinfo (ar_ptr, &mi); ++ fprintf (stderr, "fancy false sharing patch by muhq"); + fprintf (stderr, "Arena %d:\n", i); + fprintf (stderr, "system bytes = %10u\n", (unsigned int) mi.arena); + fprintf (stderr, "in use bytes = %10u\n", (unsigned int) mi.uordblks); -- cgit v1.2.3