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: mgmt by andrew from (linux-ha-cvs@lists.linux-ha.org) 2. Linux-HA CVS: lib by andrew from (linux-ha-cvs@lists.linux-ha.org) ---------------------------------------------------------------------- Message: 1 Date: Thu, 6 Jul 2006 03:30:27 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: mgmt by andrew from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : andrew Host : Project : linux-ha Module : mgmt Dir : linux-ha/mgmt/daemon Modified Files: mgmt_crm.c Log Message: Dont delete messages in the send_(ipc|ha)_helpers to make memory leak checking easier Compensate for CIB configuration growth - enables tracking of almost all memory (de)allocations in the CIB =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/mgmt/daemon/mgmt_crm.c,v retrieving revision 1.61 retrieving revision 1.62 diff -u -3 -r1.61 -r1.62 --- mgmt_crm.c 5 Jul 2006 22:56:42 -0000 1.61 +++ mgmt_crm.c 6 Jul 2006 09:30:27 -0000 1.62 @@ -853,8 +853,10 @@ crm_free(key); if(send_ipc_message(crmd_channel, cmd)) { + crm_msg_del(cmd); return 0; } + crm_msg_del(cmd); return -1; } @@ -871,8 +873,10 @@ CRM_SYSTEM_CRMD, client_name, our_pid); if(send_ipc_message(crmd_channel, cmd)) { + crm_msg_del(cmd); return 0; } + crm_msg_del(cmd); return -1; } ------------------------------ Message: 2 Date: Thu, 6 Jul 2006 03:30:28 -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 msg.c utils.c Log Message: Dont delete messages in the send_(ipc|ha)_helpers to make memory leak checking easier Compensate for CIB configuration growth - enables tracking of almost all memory (de)allocations in the CIB =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/ipc.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -3 -r1.23 -r1.24 --- ipc.c 29 May 2006 11:53:53 -0000 1.23 +++ ipc.c 6 Jul 2006 09:30:27 -0000 1.24 @@ -1,4 +1,4 @@ -/* $Id: ipc.c,v 1.23 2006/05/29 11:53:53 andrew Exp $ */ +/* $Id: ipc.c,v 1.24 2006/07/06 09:30:27 andrew Exp $ */ /* * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]> * @@ -52,6 +52,8 @@ send_ha_message(ll_cluster_t *hb_conn, HA_Message *msg, const char *node, gboolean force_ordered) { gboolean all_is_good = TRUE; + cl_mem_stats_t saved_stats; + crm_save_mem_stats(__PRETTY_FUNCTION__, &saved_stats); if (msg == NULL) { crm_err("cant send NULL message"); @@ -100,6 +102,7 @@ ipc = hb_conn->llc_ops->ipcchan(hb_conn); } if(ipc != NULL) { + ipc->ops->resume_io(ipc); send_q = ipc->send_queue; } if(send_q != NULL) { @@ -108,15 +111,18 @@ } crm_log_message_adv(all_is_good?LOG_MSG:LOG_WARNING,"HA[outbound]",msg); + crm_diff_mem_stats(LOG_DEBUG, __PRETTY_FUNCTION__, &saved_stats); return all_is_good; } /* frees msg */ gboolean -crm_send_ipc_message(IPC_Channel *ipc_client, HA_Message *msg, gboolean server) +send_ipc_message(IPC_Channel *ipc_client, HA_Message *msg) { gboolean all_is_good = TRUE; int fail_level = LOG_WARNING; + cl_mem_stats_t saved_stats; + crm_save_mem_stats(__PRETTY_FUNCTION__, &saved_stats); if(ipc_client != NULL && ipc_client->conntype == IPC_CLIENT) { fail_level = LOG_ERR; @@ -149,10 +155,11 @@ } else if(ipc_client->conntype == IPC_CLIENT) { CRM_CHECK(ipc_client->send_queue->current_qlen < ipc_client->send_queue->max_qlen, ;); } - } - + } + ipc_client->ops->resume_io(ipc_client); + crm_log_message_adv(all_is_good?LOG_MSG:LOG_WARNING,"IPC[outbound]",msg); - crm_msg_del(msg); + crm_diff_mem_stats(LOG_DEBUG, __PRETTY_FUNCTION__, &saved_stats); return all_is_good; } =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/msg.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- msg.c 8 May 2006 07:42:19 -0000 1.8 +++ msg.c 6 Jul 2006 09:30:27 -0000 1.9 @@ -1,4 +1,4 @@ -/* $Id: msg.c,v 1.8 2006/05/08 07:42:19 andrew Exp $ */ +/* $Id: msg.c,v 1.9 2006/07/06 09:30:27 andrew Exp $ */ /* * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]> * @@ -148,6 +148,7 @@ crm_debug_4("hello message sent"); free_xml(hello_node); + crm_msg_del(hello); } @@ -322,6 +323,7 @@ if (reply != NULL) { was_sent = send_ipc_message(ipc_channel, reply); + crm_msg_del(reply); } return was_sent; } =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/utils.c,v retrieving revision 1.58 retrieving revision 1.59 diff -u -3 -r1.58 -r1.59 --- utils.c 4 Jul 2006 15:17:45 -0000 1.58 +++ utils.c 6 Jul 2006 09:30:27 -0000 1.59 @@ -1,4 +1,4 @@ -/* $Id: utils.c,v 1.58 2006/07/04 15:17:45 andrew Exp $ */ +/* $Id: utils.c,v 1.59 2006/07/06 09:30:27 andrew Exp $ */ /* * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]> * @@ -1220,51 +1220,109 @@ *saved_stats = *stats; } +void +crm_xml_nbytes(crm_data_t *xml, long *bytes, long *allocs, long *frees) +{ + crm_data_t *xml_copy = NULL; + volatile cl_mem_stats_t *stats = cl_malloc_getstats(); + + if(xml == NULL) { + *bytes = 0; + *allocs = 0; + *frees = 0; + return; + } + + *bytes = 0 - stats->nbytes_alloc; + *allocs = 0 - stats->numalloc; + *frees = 0 - stats->numfree; + + xml_copy = copy_xml(xml); + + *bytes += stats->nbytes_alloc; + *allocs += stats->numalloc; + *frees += stats->numfree; + + crm_debug_3("XML size: %ld bytes, %ld allocs, %ld frees", + *bytes, *allocs, *frees); + + free_xml(xml_copy); +} + +void +crm_adjust_mem_stats(long bytes, long allocs, long frees) +{ + volatile cl_mem_stats_t *stats = cl_malloc_getstats(); + + if(bytes == 0&& allocs == 0 && frees == 0) { + return; + } + + stats->nbytes_alloc -= bytes; + stats->numalloc -= allocs; + stats->numfree -= frees; + + crm_debug("Adjusting CIB Memory usage by: %10ld bytes, %5ld allocs, %5ld frees", + bytes, allocs, frees); +} + + gboolean crm_diff_mem_stats(int log_level, const char *location, cl_mem_stats_t *saved_stats) { + gboolean increase = TRUE; + gboolean was_change = FALSE; + gboolean reset_on_change = TRUE; + volatile cl_mem_stats_t *stats = cl_malloc_getstats(); - if(saved_stats->nbytes_alloc < stats->nbytes_alloc) { - crm_log_maybe(log_level, - "Memory usage increase detected at %s:" - " %lu alloc's vs. %lu free's (%lu)" - " (%lu bytes not freed: req=%lu, alloc'd=%lu)", - location, - stats->numalloc - saved_stats->numalloc, - stats->numfree - saved_stats->numfree, - (stats->numalloc - saved_stats->numalloc) - (stats->numfree - saved_stats->numfree), - stats->nbytes_alloc - saved_stats->nbytes_alloc, - stats->nbytes_req - saved_stats->nbytes_req, - stats->mallocbytes - saved_stats->mallocbytes); - return TRUE; - - } else if(saved_stats->nbytes_alloc > stats->nbytes_alloc) { - crm_log_maybe(log_level+2, - "Memory usage decrease detected at %s:" - " %lu alloc's vs. %lu free's (%lu)" - " (%lu bytes not freed: req=%lu, alloc'd=%lu)", - location, - saved_stats->numalloc - stats->numalloc, - saved_stats->numfree - stats->numfree, - (saved_stats->numalloc - stats->numalloc) - (saved_stats->numfree - stats->numfree), - saved_stats->nbytes_alloc - stats->nbytes_alloc, - saved_stats->nbytes_req - stats->nbytes_req, - saved_stats->mallocbytes - stats->mallocbytes); - return TRUE; - } - crm_debug_2("Memory usage constant at %s:" - " %lu alloc's vs. %lu free's (%lu)" - " (%lu bytes not freed: req=%lu, alloc'd=%lu)", - location, - stats->numalloc, - stats->numfree, - stats->numalloc - stats->numfree, - stats->nbytes_alloc, - stats->nbytes_req, - stats->mallocbytes); + static long running_total = 0; + static long running_total_bytes = 0; + + long last_running_total = running_total; + long last_running_total_bytes = running_total_bytes; + + 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; */ - return FALSE; + 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(was_change == FALSE) { + 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) { + increase = FALSE; + } + + crm_log_maybe(increase?log_level:log_level+2, + "Running total %10ld (%10ld bytes)" + " 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, + increase?"increase":"decrease", location, + delta_allocs, delta_frees, delta_allocs - delta_frees, + delta_bytes, delta_req); + + if(reset_on_change) { + *stats = *saved_stats; + } + 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 24 ********************************************