All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] multipathd: memory leak from orphan_path()
@ 2016-07-22 21:20 Gi-Oh Kim
  0 siblings, 0 replies; only message in thread
From: Gi-Oh Kim @ 2016-07-22 21:20 UTC (permalink / raw)
  To: dm-devel, hare, snitzer, Elmar Gerdes


[-- Attachment #1.1: Type: text/plain, Size: 2222 bytes --]

Hello,

I checked the memory consuming of the multipathd and found it consumes too
much memory.
Following is the result I have got from 6 servers.
Longer running multipathd consumes more memory.

# ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,cmd --sort -rss | grep
multipath
root      2948     1  4376 66764  98572  0.0  0.0 00:00:01 /sbin/multipathd
root      3035     1  8648 71068 102876  0.0  0.1 00:09:11 /sbin/multipathd
root     39004     1 10236 137944 169752  0.0 0.1 03:20:43 /sbin/multipathd
root      3149     1 11976 139792 171600  0.0 0.2 05:37:37 /sbin/multipathd
root      3168     1 13792 76056 107864  0.0  0.3 07:04:41 /sbin/multipathd
root      3135     1 14920 142500 174308  0.0 0.4 08:49:38 /sbin/multipathd


So I did valgrind test with debian 0.4.9 version and I've got following
error.
pp->getuid is initialized by malloc but it is not freed.

==14958== 280 bytes in 4 blocks are definitely lost in loss record 2 of 3
==14958==    at 0x4C28C20: malloc (vg_replace_malloc.c:296)
==14958==    by 0x5702D2E: select_getuid (in /lib/libmultipath.so.0)
==14958==    by 0x56FFA0F: ??? (in /lib/libmultipath.so.0)
==14958==    by 0x5701707: pathinfo (in /lib/libmultipath.so.0)
==14958==    by 0x5701BDE: store_pathinfo (in /lib/libmultipath.so.0)
==14958==    by 0x5701F17: path_discovery (in /lib/libmultipath.so.0)
==14958==    by 0x407916: configure (main.c:1310)
==14958==    by 0x404B60: child (main.c:1623)
==14958==    by 0x404B60: main (main.c:1834)


Finally I've applied following patch.
The valgrind does not complain any more.
I checked the latest source but orphan_path() has no patch like that.
I'd appreciate if you would review my patch and give me any feedback.


------------------------- 8< ------------------
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index 6d2d45e..007b5eb 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -84,6 +84,8 @@ orphan_path (struct path * pp, const char *reason)
        pp->mpp = NULL;
        pp->dmstate = PSTATE_UNDEF;
        pp->uid_attribute = NULL;
+    if (pp->getuid)
+        free(pp->getuid);
        pp->getuid = NULL;
        prio_put(&pp->prio);
        checker_put(&pp->checker);

[-- Attachment #1.2: Type: text/html, Size: 5364 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-07-22 21:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-22 21:20 [RFC] multipathd: memory leak from orphan_path() Gi-Oh Kim

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.