[oe-commits] Holger Hans Peter Freyther : glibc_2.9.bb: Apply recent commits to memusage .c as patches

git version control git at git.openembedded.org
Wed Jan 6 18:12:54 UTC 2010


Module: openembedded.git
Branch: martin_jansa/srcpv
Commit: 8212c8228f6e04817e087a151c5659c7876dec2a
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=8212c8228f6e04817e087a151c5659c7876dec2a

Author: Holger Hans Peter Freyther <zecke at selfish.org>
Date:   Wed Jan  6 15:27:05 2010 +0800

glibc_2.9.bb: Apply recent commits to memusage.c as patches

memusage.c will end up as libmemusage.so and the version in glibc 2.9
has the problem to deal badly with wrap arounds. Apply some upstream
fixes to make the situation a bit better.

---

 ...sage.c-update_data-Fix-handling-of-wrappi.patch |   46 ++++++++++++++++++++
 ...sage.c-DEFAULT_BUFFER_SIZE-Change-to-3276.patch |   26 +++++++++++
 .../0003-Fix-wrap-around-in-memusage.patch         |   37 ++++++++++++++++
 recipes/glibc/glibc_2.9.bb                         |    8 +++-
 4 files changed, 116 insertions(+), 1 deletions(-)

diff --git a/recipes/glibc/glibc-2.9/0001-malloc-memusage.c-update_data-Fix-handling-of-wrappi.patch b/recipes/glibc/glibc-2.9/0001-malloc-memusage.c-update_data-Fix-handling-of-wrappi.patch
new file mode 100644
index 0000000..9a43212
--- /dev/null
+++ b/recipes/glibc/glibc-2.9/0001-malloc-memusage.c-update_data-Fix-handling-of-wrappi.patch
@@ -0,0 +1,46 @@
+From c3ab42a82de7506c17749e78a171ce07ced95dd5 Mon Sep 17 00:00:00 2001
+From: Ulrich Drepper <drepper at redhat.com>
+Date: Fri, 6 Feb 2009 18:24:23 +0000
+Subject: [PATCH 1/3] * malloc/memusage.c (update_data): Fix handling of wrapping back
+
+	to the beginning of the buffer.
+---
+ malloc/memusage.c |    8 +++++---
+ 1 files changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/malloc/memusage.c b/malloc/memusage.c
+index d11e9e6..6c67a8c 100644
+--- a/malloc/memusage.c
++++ b/malloc/memusage.c
+@@ -1,5 +1,5 @@
+ /* Profile heap and stack memory usage of running program.
+-   Copyright (C) 1998-2002, 2004, 2005, 2006 Free Software Foundation, Inc.
++   Copyright (C) 1998-2002, 2004-2006, 2009 Free Software Foundation, Inc.
+    This file is part of the GNU C Library.
+    Contributed by Ulrich Drepper <drepper at cygnus.com>, 1998.
+ 
+@@ -18,6 +18,7 @@
+    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+    02111-1307 USA.  */
+ 
++#include <assert.h>
+ #include <atomic.h>
+ #include <dlfcn.h>
+ #include <errno.h>
+@@ -168,10 +169,11 @@ update_data (struct header *result, size_t len, size_t old_len)
+ 	     this fails because of another thread increasing the
+ 	     counter it does not matter since that thread will take
+ 	     care of the correction.  */
+-	  unsigned int reset = idx - 2 * buffer_size;
+-	  catomic_compare_and_exchange_val_acq (&buffer_size, reset, idx);
++	  uatomic32_t reset = idx % (2 * buffer_size);
++	  catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx);
+ 	  idx = reset;
+ 	}
++      assert (idx < 2 * DEFAULT_BUFFER_SIZE);
+ 
+       buffer[idx].heap = current_heap;
+       buffer[idx].stack = current_stack;
+-- 
+1.6.3.3
+
diff --git a/recipes/glibc/glibc-2.9/0002-malloc-memusage.c-DEFAULT_BUFFER_SIZE-Change-to-3276.patch b/recipes/glibc/glibc-2.9/0002-malloc-memusage.c-DEFAULT_BUFFER_SIZE-Change-to-3276.patch
new file mode 100644
index 0000000..770de9e
--- /dev/null
+++ b/recipes/glibc/glibc-2.9/0002-malloc-memusage.c-DEFAULT_BUFFER_SIZE-Change-to-3276.patch
@@ -0,0 +1,26 @@
+From e2e390fad8271da33a51075cc2bf27c9fe78861b Mon Sep 17 00:00:00 2001
+From: Ulrich Drepper <drepper at redhat.com>
+Date: Fri, 6 Feb 2009 18:27:08 +0000
+Subject: [PATCH 2/3] * malloc/memusage.c (DEFAULT_BUFFER_SIZE): Change to 32768.
+
+	(update_data): Fix handling of wrapping back
+---
+ malloc/memusage.c |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/malloc/memusage.c b/malloc/memusage.c
+index 6c67a8c..fcd58dc 100644
+--- a/malloc/memusage.c
++++ b/malloc/memusage.c
+@@ -93,7 +93,7 @@ static __thread uintptr_t start_sp;
+ #define peak_stack	peak_use[1]
+ #define peak_total	peak_use[2]
+ 
+-#define DEFAULT_BUFFER_SIZE	1024
++#define DEFAULT_BUFFER_SIZE	32768
+ static size_t buffer_size;
+ 
+ static int fd = -1;
+-- 
+1.6.3.3
+
diff --git a/recipes/glibc/glibc-2.9/0003-Fix-wrap-around-in-memusage.patch b/recipes/glibc/glibc-2.9/0003-Fix-wrap-around-in-memusage.patch
new file mode 100644
index 0000000..e07c9d9
--- /dev/null
+++ b/recipes/glibc/glibc-2.9/0003-Fix-wrap-around-in-memusage.patch
@@ -0,0 +1,37 @@
+From 22bc5239e1c7d97b0642af6c135af994586f8e82 Mon Sep 17 00:00:00 2001
+From: Andreas Schwab <schwab at redhat.com>
+Date: Thu, 29 Oct 2009 11:25:20 -0700
+Subject: [PATCH 3/3] Fix wrap-around in memusage.
+
+---
+ malloc/memusage.c |    9 +++++----
+ 1 files changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/malloc/memusage.c b/malloc/memusage.c
+index fcd58dc..382261c 100644
+--- a/malloc/memusage.c
++++ b/malloc/memusage.c
+@@ -163,15 +163,16 @@ update_data (struct header *result, size_t len, size_t old_len)
+   if (fd != -1)
+     {
+       uatomic32_t idx = catomic_exchange_and_add (&buffer_cnt, 1);
+-      if (idx >= 2 * buffer_size)
++      if (idx + 1 >= 2 * buffer_size)
+ 	{
+ 	  /* We try to reset the counter to the correct range.  If
+ 	     this fails because of another thread increasing the
+ 	     counter it does not matter since that thread will take
+ 	     care of the correction.  */
+-	  uatomic32_t reset = idx % (2 * buffer_size);
+-	  catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx);
+-	  idx = reset;
++	  uatomic32_t reset = (idx + 1) % (2 * buffer_size);
++	  catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx + 1);
++	  if (idx >= 2 * buffer_size)
++	    idx = reset - 1;
+ 	}
+       assert (idx < 2 * DEFAULT_BUFFER_SIZE);
+ 
+-- 
+1.6.3.3
+
diff --git a/recipes/glibc/glibc_2.9.bb b/recipes/glibc/glibc_2.9.bb
index 5751a71..b27e0a0 100644
--- a/recipes/glibc/glibc_2.9.bb
+++ b/recipes/glibc/glibc_2.9.bb
@@ -5,7 +5,7 @@ ARM_INSTRUCTION_SET = "arm"
 PACKAGES_DYNAMIC = "libc6*"
 RPROVIDES_${PN}-dev = "libc6-dev virtual-libc-dev"
 
-PR = "${INC_PR}.2"
+PR = "${INC_PR}.3"
 
 # the -isystem in bitbake.conf screws up glibc do_stage
 BUILD_CPPFLAGS = "-I${STAGING_INCDIR_NATIVE}"
@@ -68,6 +68,12 @@ SRC_URI = "ftp://ftp.gnu.org/pub/gnu/glibc/glibc-${PV}.tar.bz2 \
            file://glibc-2.9-enable-binutils-2.2.patch;patch=1 \
            "
 
+# patches to fix libmemusage.so
+SRC_URI_append = " file://0001-malloc-memusage.c-update_data-Fix-handling-of-wrappi.patch;patch=1 \
+                   file://0002-malloc-memusage.c-DEFAULT_BUFFER_SIZE-Change-to-3276.patch;patch=1 \
+                   file://0003-Fix-wrap-around-in-memusage.patch;patch=1 "
+
+
 # Build fails on sh3 and sh4 without additional patches
 SRC_URI_append_sh3 = " file://no-z-defs.patch;patch=1 \
 		file://glibc-2.9-sh-fix.patch;patch=1"





More information about the Openembedded-commits mailing list