[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patches] Add MEMUSAGE option group



Hello Joseph,

The attached patch adds new option group OPTION_EGLIBC_MEMUSAGE, which controls build and installation of libmemusage library. This library is of no use for certain systems, hence the option.

This patch also introduces anew configuration option (OPTION_EGLIBC_MEMUSAGE_DEFAUL_BUFFER_SIZE) to control how much space will the library allocate if loaded. By default, the library allocates 1.5M buffer and this option allows to reduce that to as little as 48 bytes.

Tested on i686 with no difference in the testresults for both cases
* trunk / trunk + patch + option group enabled and
* trunk / trunk + patch - option group disabled.

OK to check in?

Thanks,

--
Maxim K.
CodeSourcery
2009-08-18  Maxim Kuvyrkov  <maxim@xxxxxxxxxxxxxxxx>

	Add OPTION_EGLIBC_MEMUSAGE option group and
	OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE option.

	* option-groups.def (OPTION_EGLIBC_MEMUSAGE): Define new option group.
	(OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE): Document option.
	* option-groups.defaults (OPTION_EGLIBC_MEMUSAGE): Add.
	* malloc/Makefile (libmemusage): Build if option group is selected.
	(memusage): Update CPPFLAGS.
	* malloc/memusage.c (DEFAULT_BUFFER_SIZE): Allow overriding the default.

Index: option-groups.defaults
===================================================================
--- option-groups.defaults	(revision 8835)
+++ option-groups.defaults	(working copy)
@@ -26,6 +26,7 @@ OPTION_EGLIBC_INET = y
 OPTION_EGLIBC_LIBM = y
 OPTION_EGLIBC_LOCALES = y
 OPTION_EGLIBC_LOCALE_CODE = y
+OPTION_EGLIBC_MEMUSAGE = y
 OPTION_EGLIBC_NIS = y
 OPTION_EGLIBC_NSSWITCH = y
 OPTION_EGLIBC_RCMD = y
Index: malloc/Makefile
===================================================================
--- malloc/Makefile	(revision 8835)
+++ malloc/Makefile	(working copy)
@@ -20,6 +20,8 @@
 #
 #	Makefile for malloc routines
 #
+include ../option-groups.mak
+
 subdir	:= malloc
 
 all:
@@ -43,9 +45,15 @@ install-lib := libmcheck.a
 non-lib.a := libmcheck.a
 
 # Additional library.
+ifeq ($(OPTION_EGLIBC_MEMUSAGE),y)
 extra-libs = libmemusage
 extra-libs-others = $(extra-libs)
 
+ifdef OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
+CPPFLAGS-memusage += -D__OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE=$(OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE)
+endif
+endif
+
 libmemusage-routines = memusage
 libmemusage-inhibit-o = $(filter-out .os,$(object-suffixes))
 
Index: malloc/memusage.c
===================================================================
--- malloc/memusage.c	(revision 8835)
+++ malloc/memusage.c	(working copy)
@@ -93,7 +93,12 @@ static __thread uintptr_t start_sp;
 #define peak_stack	peak_use[1]
 #define peak_total	peak_use[2]
 
-#define DEFAULT_BUFFER_SIZE	32768
+#ifndef __OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
+# define DEFAULT_BUFFER_SIZE	32768
+#else
+# define DEFAULT_BUFFER_SIZE	__OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
+#endif
+
 static size_t buffer_size;
 
 static int fd = -1;
Index: option-groups.def
===================================================================
--- option-groups.def	(revision 8835)
+++ option-groups.def	(working copy)
@@ -465,6 +465,24 @@ config OPTION_EGLIBC_LOCALE_CODE
        group; if you disable OPTION_EGLIBC_LOCALE_CODE, you must also
        disable OPTION_EGLIBC_CATGETS.
 
+config OPTION_EGLIBC_MEMUSAGE
+   bool "Memory profiling library"
+   help
+       This option group includes the 'libmemusage' library,
+       which provides memory profiling functions.
+
+     OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
+
+       Libmemusage library buffers the profiling data in memory
+       before writing it out to disk.  By default, the library
+       allocates 1.5M buffer, which can be substantial for some
+       systems.  OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE option
+       allows to change the default buffer size.  It specifies
+       the number of entries the buffer should have.
+       On most architectures one buffer entry will amounts to 48 bytes,
+       so setting this option to the value of 512 will reduce the size of
+       the memory buffer to 24K.
+
 config OPTION_EGLIBC_NIS
    bool "Support for NIS, NIS+, and the special 'compat' services."
    depends OPTION_EGLIBC_INET