Send Linux-ha-cvs mailing list submissions to
        linux-ha-cvs@lists.linux-ha.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."


Today's Topics:

   1. Linux-HA CVS: lib by andrew from 
      (linux-ha-cvs@lists.linux-ha.org)
   2. Linux-HA CVS: include by andrew from 
      (linux-ha-cvs@lists.linux-ha.org)
   3. Linux-HA CVS: lib by andrew from 
      (linux-ha-cvs@lists.linux-ha.org)


----------------------------------------------------------------------

Message: 1
Date: Thu,  6 Jul 2006 04:55:10 -0600 (MDT)
From: linux-ha-cvs@lists.linux-ha.org
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/crm/common


Modified Files:
        utils.c 


Log Message:
More tweaks for trying to pin down the memory leak

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/utils.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -3 -r1.59 -r1.60
--- utils.c     6 Jul 2006 09:30:27 -0000       1.59
+++ utils.c     6 Jul 2006 10:55:09 -0000       1.60
@@ -1,4 +1,4 @@
-/* $Id: utils.c,v 1.59 2006/07/06 09:30:27 andrew Exp $ */
+/* $Id: utils.c,v 1.60 2006/07/06 10:55:09 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -1216,7 +1216,7 @@
        if(saved_stats == NULL) {
                return;
        }
-       crm_debug("Saving memory stats: %s", location);
+       crm_debug_2("Saving memory stats: %s", location);
        *saved_stats = *stats;
 }
 
@@ -1272,7 +1272,7 @@
 {
        gboolean increase = TRUE;
        gboolean was_change = FALSE;
-       gboolean reset_on_change = TRUE;
+       gboolean reset_on_change = (log_level != LOG_ERR);
 
        volatile cl_mem_stats_t *stats = cl_malloc_getstats();
 
@@ -1319,10 +1319,10 @@
                      delta_allocs, delta_frees, delta_allocs - delta_frees,
                      delta_bytes, delta_req);
        
-       if(reset_on_change) {
+       if(reset_on_change && increase) {
                *stats = *saved_stats;          
        }
-       return TRUE;
+       return increase;
 }
 
 void




------------------------------

Message: 2
Date: Thu,  6 Jul 2006 07:30:24 -0600 (MDT)
From: linux-ha-cvs@lists.linux-ha.org
Subject: [Linux-ha-cvs] Linux-HA CVS: include by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : include

Dir     : linux-ha/include/crm/common


Modified Files:
        util.h 


Log Message:
More memory usage changes

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/include/crm/common/util.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -3 -r1.37 -r1.38
--- util.h      6 Jul 2006 09:30:28 -0000       1.37
+++ util.h      6 Jul 2006 13:30:23 -0000       1.38
@@ -1,4 +1,4 @@
-/* $Id: util.h,v 1.37 2006/07/06 09:30:28 andrew Exp $ */
+/* $Id: util.h,v 1.38 2006/07/06 13:30:23 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -96,11 +96,14 @@
 
 extern void crm_save_mem_stats(const char *location, cl_mem_stats_t 
*saved_stats);
 
-extern gboolean crm_diff_mem_stats(int log_level, const char *location, 
cl_mem_stats_t *saved_stats);
+extern gboolean crm_diff_mem_stats(
+       int log_level_up, int log_level_down, const char *location,
+       volatile cl_mem_stats_t *stats, volatile cl_mem_stats_t *saved_stats);
 
 extern void crm_xml_nbytes(crm_data_t *xml, long *bytes, long *allocs, long 
*frees);
 
-extern void crm_adjust_mem_stats(long bytes, long allocs, long frees);
+extern void crm_adjust_mem_stats(
+       volatile cl_mem_stats_t *stats, long bytes, long allocs, long frees);
 
 extern char *generate_transition_magic_v202(
        const char *transition_key, int op_status);
@@ -144,4 +147,6 @@
 extern void crm_make_daemon(
        const char *name, gboolean daemonize, const char *pidfile);
 
+extern cl_mem_stats_t *crm_running_stats;
+
 #endif




------------------------------

Message: 3
Date: Thu,  6 Jul 2006 07:30:24 -0600 (MDT)
From: linux-ha-cvs@lists.linux-ha.org
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/crm/common


Modified Files:
        ipc.c utils.c 


Log Message:
More memory usage changes

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/ipc.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- ipc.c       6 Jul 2006 09:30:27 -0000       1.24
+++ ipc.c       6 Jul 2006 13:30:23 -0000       1.25
@@ -1,4 +1,4 @@
-/* $Id: ipc.c,v 1.24 2006/07/06 09:30:27 andrew Exp $ */
+/* $Id: ipc.c,v 1.25 2006/07/06 13:30:23 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -111,7 +111,7 @@
        }
        
        crm_log_message_adv(all_is_good?LOG_MSG:LOG_WARNING,"HA[outbound]",msg);
-       crm_diff_mem_stats(LOG_DEBUG, __PRETTY_FUNCTION__, &saved_stats);
+       crm_diff_mem_stats(LOG_DEBUG, LOG_DEBUG, __PRETTY_FUNCTION__, NULL, 
&saved_stats);
        return all_is_good;
 }
 
@@ -159,7 +159,7 @@
        ipc_client->ops->resume_io(ipc_client);
        
        
crm_log_message_adv(all_is_good?LOG_MSG:LOG_WARNING,"IPC[outbound]",msg);
-       crm_diff_mem_stats(LOG_DEBUG, __PRETTY_FUNCTION__, &saved_stats);
+       crm_diff_mem_stats(LOG_DEBUG, LOG_DEBUG, __PRETTY_FUNCTION__, NULL, 
&saved_stats);
        
        return all_is_good;
 }
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/utils.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -3 -r1.60 -r1.61
--- utils.c     6 Jul 2006 10:55:09 -0000       1.60
+++ utils.c     6 Jul 2006 13:30:24 -0000       1.61
@@ -1,4 +1,4 @@
-/* $Id: utils.c,v 1.60 2006/07/06 10:55:09 andrew Exp $ */
+/* $Id: utils.c,v 1.61 2006/07/06 13:30:24 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -1194,19 +1194,17 @@
 void
 crm_zero_mem_stats(volatile cl_mem_stats_t *stats)
 {
-       volatile cl_mem_stats_t *active_stats = NULL;
-       if(stats != NULL) {
-               cl_malloc_setstats(stats);
-       }
-       crm_debug("Resetting memory stats");
-       active_stats = cl_malloc_getstats();
-       active_stats->numalloc = 0;
-       active_stats->numfree = 0;
-       active_stats->numrealloc = 0;
-       active_stats->nbytes_req = 0;
-       active_stats->nbytes_alloc = 0;
-       active_stats->mallocbytes = 0;
-       active_stats->arena = 0;
+       if(stats == NULL) {
+               crm_debug("Resetting global memory stats");
+               stats = cl_malloc_getstats();
+       }
+       stats->numalloc = 0;
+       stats->numfree = 0;
+       stats->numrealloc = 0;
+       stats->nbytes_req = 0;
+       stats->nbytes_alloc = 0;
+       stats->mallocbytes = 0;
+       stats->arena = 0;
 }
 
 void
@@ -1250,79 +1248,83 @@
 }
 
 void
-crm_adjust_mem_stats(long bytes, long allocs, long frees) 
-{
-       volatile cl_mem_stats_t *stats = cl_malloc_getstats();
-
+crm_adjust_mem_stats(volatile cl_mem_stats_t *stats, long bytes, long allocs, 
long frees) 
+{      
        if(bytes == 0&& allocs == 0 && frees == 0) {
                return;
        }
 
+       if(stats == NULL) {
+               stats = cl_malloc_getstats();
+       }
+       
        stats->nbytes_alloc -= bytes;
        stats->numalloc     -= allocs;
        stats->numfree      -= frees;
 
-       crm_debug("Adjusting CIB Memory usage by: %10ld bytes, %5ld allocs, 
%5ld frees",
+       crm_debug("Adjusted CIB Memory usage by: %10ld bytes, %5ld allocs, %5ld 
frees",
                  bytes, allocs, frees);
 }
 
+cl_mem_stats_t *crm_running_stats = NULL;
 
 gboolean
-crm_diff_mem_stats(int log_level, const char *location, cl_mem_stats_t 
*saved_stats)
+crm_diff_mem_stats(int log_level_up, int log_level_down, const char *location,
+                  volatile cl_mem_stats_t *stats, volatile cl_mem_stats_t 
*saved_stats)
 {
-       gboolean increase = TRUE;
-       gboolean was_change = FALSE;
-       gboolean reset_on_change = (log_level != LOG_ERR);
-
-       volatile cl_mem_stats_t *stats = cl_malloc_getstats();
-
-       static long running_total = 0;
-       static long running_total_bytes = 0;
+       long delta_allocs = 0;
+       long delta_frees  = 0;
+       long delta_bytes  = 0;
+       long delta_req    = 0;
 
-       long last_running_total = running_total;
-       long last_running_total_bytes = running_total_bytes;
+       gboolean increase = TRUE;
+       gboolean reset_on_change = (log_level_up != LOG_ERR);
 
-       long delta_allocs = stats->numalloc - saved_stats->numalloc;
-       long delta_frees  = stats->numfree - saved_stats->numfree;
-       long delta_bytes  = stats->nbytes_alloc - saved_stats->nbytes_alloc;
-       long delta_req    = stats->nbytes_req - saved_stats->nbytes_req;
 /*     long delta_malloc = stats->mallocbytes - saved_stats->mallocbytes; */
-       
-       running_total += delta_allocs;
-       running_total -= delta_frees;
-       running_total_bytes += delta_bytes;
 
-       if(running_total != last_running_total) {
-               was_change = TRUE;
-       }
-       if(running_total_bytes != last_running_total_bytes) {
-               was_change = TRUE;
+       if(stats == NULL && saved_stats == NULL) {
+               crm_err("Comparision doesnt make sense");
+               return FALSE;
+               
+       } else if(stats == NULL) {
+               stats = cl_malloc_getstats();
+
+       } else if(saved_stats == NULL) {
+               saved_stats = cl_malloc_getstats();
        }
 
-       if(was_change == FALSE) {
+       delta_allocs = stats->numalloc - saved_stats->numalloc;
+       delta_frees  = stats->numfree - saved_stats->numfree;
+       delta_bytes  = stats->nbytes_alloc - saved_stats->nbytes_alloc;
+       delta_req    = stats->nbytes_req - saved_stats->nbytes_req;
+       
+       if(delta_bytes == 0) {
                crm_debug("Memory usage constant at %s: %ld alloc's %ld free's",
                          location, delta_allocs, delta_frees);
                return FALSE;
        }
 
-       if(saved_stats->nbytes_alloc > stats->nbytes_alloc) {
+       if(delta_bytes < 0) {
                increase = FALSE;
+               reset_on_change = (log_level_down != LOG_ERR);
        }
 
-       crm_log_maybe(increase?log_level:log_level+2,
-                     "Running total %10ld (%10ld bytes)"
-                     " Memory usage %s detected at %s:\t"
+       crm_log_maybe(increase?log_level_up:log_level_down,
+                     "Memory usage %s detected at %s:\t"
                      " %10ld alloc's vs. %10ld free's (%5ld change"
-                     " %10ld bytes leaked: %10ld requested)",
-                     running_total, running_total_bytes,
+                     " %10ld bytes leaked)",
                      increase?"increase":"decrease", location,
                      delta_allocs, delta_frees, delta_allocs - delta_frees,
-                     delta_bytes, delta_req);
+                     delta_bytes);
        
-       if(reset_on_change && increase) {
-               *stats = *saved_stats;          
+       if(reset_on_change) {
+               crm_debug("resetting %s stats", location);
+               *stats = *saved_stats;
+               if(crm_running_stats) {
+                       crm_adjust_mem_stats(crm_running_stats, delta_bytes, 
delta_allocs, delta_frees);
+               }
        }
-       return increase;
+       return TRUE;
 }
 
 void




------------------------------

_______________________________________________
Linux-ha-cvs mailing list
Linux-ha-cvs@lists.linux-ha.org
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs


End of Linux-ha-cvs Digest, Vol 32, Issue 26
********************************************

Reply via email to