Module: sip-router
Branch: master
Commit: ed6f5bcaf616d2da8f8cfce4428b4eab41696717
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ed6f5bc…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Dec 20 09:40:46 2010 +0100
core: execute core events when pkg usage changes
- track used and real_used metrics for q/f_malloc when MALLOC_STATS is
defined
---
mem/f_malloc.c | 25 +++++++++++++++++++++++++
mem/q_malloc.c | 19 +++++++++++++++++++
2 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/mem/f_malloc.c b/mem/f_malloc.c
index 6fa88c3..17927f6 100644
--- a/mem/f_malloc.c
+++ b/mem/f_malloc.c
@@ -55,6 +55,9 @@
#include "memdbg.h"
#include "../bit_scan.h"
#include "../cfg/cfg.h" /* memlog */
+#ifdef MALLOC_STATS
+#include "../evnets.h"
+#endif
/*useful macros*/
@@ -240,6 +243,9 @@ void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,
FRAG_CLEAR_USED(n); /* never used */
#if defined(DBG_F_MALLOC) || defined(MALLOC_STATS)
qm->real_used+=FRAG_OVERHEAD;
+#ifdef MALLOC_STATS
+ sr_event_exec(SREV_PKG_SET_REAL_USED, (void*)qm->real_used);
+#endif
#endif
#ifdef DBG_F_MALLOC
/* frag created by malloc, mark it*/
@@ -406,6 +412,10 @@ found:
qm->used+=frag->size;
if (qm->max_real_used<qm->real_used)
qm->max_real_used=qm->real_used;
+#ifdef MALLOC_STATS
+ sr_event_exec(SREV_PKG_SET_USED, (void*)qm->used);
+ sr_event_exec(SREV_PKG_SET_REAL_USED, (void*)qm->real_used);
+#endif
#endif
FRAG_MARK_USED(frag); /* mark it as used */
return (char*)frag+sizeof(struct fm_frag);
@@ -444,6 +454,10 @@ void fm_free(struct fm_block* qm, void* p)
#if defined(DBG_F_MALLOC) || defined(MALLOC_STATS)
qm->used-=size;
qm->real_used-=size;
+#ifdef MALLOC_STATS
+ sr_event_exec(SREV_PKG_SET_USED, (void*)qm->used);
+ sr_event_exec(SREV_PKG_SET_REAL_USED, (void*)qm->real_used);
+#endif
#endif
#ifdef DBG_F_MALLOC
f->file=file;
@@ -513,6 +527,10 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned long size)
free frag, so here we only need orig_size-f->size for real used */
qm->real_used-=(orig_size-f->size);
qm->used-=(orig_size-f->size);
+#ifdef MALLOC_STATS
+ sr_event_exec(SREV_PKG_SET_USED, (void*)qm->used);
+ sr_event_exec(SREV_PKG_SET_REAL_USED, (void*)qm->real_used);
+#endif
#endif
}else if (f->size<size){
/* grow */
@@ -546,6 +564,9 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned long size)
f->size+=n->size+FRAG_OVERHEAD;
#if defined(DBG_F_MALLOC) || defined(MALLOC_STATS)
qm->real_used-=FRAG_OVERHEAD;
+#ifdef MALLOC_STATS
+ sr_event_exec(SREV_PKG_SET_REAL_USED, (void*)qm->real_used);
+#endif
#endif
/* split it if necessary */
if (f->size > size){
@@ -559,6 +580,10 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned long size)
#if defined(DBG_F_MALLOC) || defined(MALLOC_STATS)
qm->real_used+=(f->size-orig_size);
qm->used+=(f->size-orig_size);
+#ifdef MALLOC_STATS
+ sr_event_exec(SREV_PKG_SET_USED, (void*)qm->used);
+ sr_event_exec(SREV_PKG_SET_REAL_USED, (void*)qm->real_used);
+#endif
#endif
}else{
/* could not join => realloc */
diff --git a/mem/q_malloc.c b/mem/q_malloc.c
index 04c6dc9..a90c1e6 100644
--- a/mem/q_malloc.c
+++ b/mem/q_malloc.c
@@ -48,6 +48,9 @@
#include "../globals.h"
#include "memdbg.h"
#include "../cfg/cfg.h" /* memlog */
+#ifdef MALLOC_STATS
+#include "../events.h"
+#endif
/*useful macros*/
@@ -394,6 +397,10 @@ void* qm_malloc(struct qm_block* qm, unsigned long size)
qm->used+=f->size;
if (qm->max_real_used<qm->real_used)
qm->max_real_used=qm->real_used;
+#ifdef MALLOC_STATS
+ sr_event_exec(SREV_PKG_SET_USED, (void*)qm->used);
+ sr_event_exec(SREV_PKG_SET_REAL_USED, (void*)qm->real_used);
+#endif
#ifdef DBG_QM_MALLOC
f->file=file;
f->func=func;
@@ -452,6 +459,10 @@ void qm_free(struct qm_block* qm, void* p)
size=f->size;
qm->used-=size;
qm->real_used-=size;
+#ifdef MALLOC_STATS
+ sr_event_exec(SREV_PKG_SET_USED, (void*)qm->used);
+ sr_event_exec(SREV_PKG_SET_REAL_USED, (void*)qm->real_used);
+#endif
#ifdef QM_JOIN_FREE
/* mark this fragment as used (might fall into the middle of joined frags)
@@ -568,6 +579,10 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned long size)
*/
qm->real_used-=(orig_size-f->size);
qm->used-=(orig_size-f->size);
+#ifdef MALLOC_STATS
+ sr_event_exec(SREV_PKG_SET_USED, (void*)qm->used);
+ sr_event_exec(SREV_PKG_SET_REAL_USED, (void*)qm->real_used);
+#endif
}
}else if (f->size < size){
@@ -598,6 +613,10 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned long size)
}
qm->real_used+=(f->size-orig_size);
qm->used+=(f->size-orig_size);
+#ifdef MALLOC_STATS
+ sr_event_exec(SREV_PKG_SET_USED, (void*)qm->used);
+ sr_event_exec(SREV_PKG_SET_REAL_USED, (void*)qm->real_used);
+#endif
}else{
/* could not join => realloc */
#ifdef DBG_QM_MALLOC