From: mbroz@sourceware.org <mbroz@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 ./WHATS_NEW libdm/ioctl/libdm-iface.c lib ...
Date: 10 Apr 2009 09:56:59 -0000 [thread overview]
Message-ID: <20090410095659.18696.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mbroz at sourceware.org 2009-04-10 09:56:59
Modified files:
. : WHATS_NEW
libdm/ioctl : libdm-iface.c
libdm/mm : pool-debug.c pool-fast.c pool.c
Log message:
Helper function to catch memory pool leaks.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1084&r2=1.1085
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/mm/pool-debug.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/mm/pool-fast.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/mm/pool.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5
--- LVM2/WHATS_NEW 2009/04/10 09:56:00 1.1084
+++ LVM2/WHATS_NEW 2009/04/10 09:56:58 1.1085
@@ -1,5 +1,6 @@
Version 2.02.46 -
================================
+ Add memory pool leaks detection.
Use copy of PV structure when manipulating with global PV lists.
Always return exit error status when locking of volume group fails.
Fix mirror log convert validation question.
--- LVM2/libdm/ioctl/libdm-iface.c 2009/02/12 20:42:07 1.56
+++ LVM2/libdm/ioctl/libdm-iface.c 2009/04/10 09:56:58 1.57
@@ -1817,12 +1817,15 @@
update_devs();
}
+void dm_pools_check_leaks(void);
+
void dm_lib_exit(void)
{
dm_lib_release();
if (_dm_bitset)
dm_bitset_destroy(_dm_bitset);
_dm_bitset = NULL;
+ dm_pools_check_leaks();
dm_dump_memory();
_version_ok = 1;
_version_checked = 0;
--- LVM2/libdm/mm/pool-debug.c 2009/04/02 15:02:18 1.7
+++ LVM2/libdm/mm/pool-debug.c 2009/04/10 09:56:59 1.8
@@ -30,7 +30,9 @@
} pool_stats;
struct dm_pool {
+ struct dm_list list;
const char *name;
+ void *orig_pool; /* to pair it with first allocation call */
int begun;
struct block *object;
@@ -65,10 +67,13 @@
mem->stats.bytes = 0;
mem->stats.maxbytes = 0;
+ mem->orig_pool = mem;
+
#ifdef DEBUG_POOL
log_debug("Created mempool %s", name);
#endif
+ dm_list_add(&_dm_pools, &mem->list);
return mem;
}
@@ -103,6 +108,7 @@
{
_pool_stats(p, "Destroying");
_free_blocks(p, p->blocks);
+ dm_list_del(&p->list);
dm_free(p);
}
--- LVM2/libdm/mm/pool-fast.c 2008/11/03 18:59:59 1.6
+++ LVM2/libdm/mm/pool-fast.c 2009/04/10 09:56:59 1.7
@@ -21,6 +21,7 @@
};
struct dm_pool {
+ struct dm_list list;
struct chunk *chunk, *spare_chunk; /* spare_chunk is a one entry free
list to stop 'bobbling' */
size_t chunk_size;
@@ -51,6 +52,7 @@
while (new_size < p->chunk_size)
new_size <<= 1;
p->chunk_size = new_size;
+ dm_list_add(&_dm_pools, &p->list);
return p;
}
@@ -65,6 +67,7 @@
c = pr;
}
+ dm_list_del(&p->list);
dm_free(p);
}
--- LVM2/libdm/mm/pool.c 2008/11/03 18:59:59 1.4
+++ LVM2/libdm/mm/pool.c 2009/04/10 09:56:59 1.5
@@ -15,6 +15,10 @@
#include "dmlib.h"
+/* FIXME: thread unsafe */
+static DM_LIST_INIT(_dm_pools);
+void dm_pools_check_leaks(void);
+
#ifdef DEBUG_POOL
#include "pool-debug.c"
#else
@@ -52,3 +56,22 @@
return ptr;
}
+
+void dm_pools_check_leaks(void)
+{
+ struct dm_pool *p;
+
+ if (dm_list_empty(&_dm_pools))
+ return;
+
+ log_error("You have a memory leak (not released memory pool):");
+ dm_list_iterate_items(p, &_dm_pools) {
+#ifdef DEBUG_POOL
+ log_error(" [%p] %s (%u bytes)",
+ p->orig_pool,
+ p->name, p->stats.bytes);
+#else
+ log_error(" [%p]", p);
+#endif
+ }
+}
reply other threads:[~2009-04-10 9:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090410095659.18696.qmail@sourceware.org \
--to=mbroz@sourceware.org \
--cc=lvm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.