Skip to contentSkip to conversation

memory leak in user mode network stack

Qemu-devel Juergen Keil 2 participants 2 messages Sep 13, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

apparently there is a qemu memory leak when -user-net is used. ftp'ing a ~500Mbyte file from the host os to the guest os increases memory usage for the "qemu -m 256" process from ~280mb to almost 2gb.

It seems the problem is in slirp/if.c, if_start(). If fetches queued mbuf's, sends them, but does not return the mbufs to the free mbuf pool.

Shouldn't if_start() return mbufs to the free mbuf pool after transmitting the data, like this?

Index: if.c
===================================================================
RCS file: /cvsroot/qemu/qemu/slirp/if.c,v retrieving revision 1.1
diff -u -B -c -8 -r1.1 if.c
cvs diff: conflicting specifications of output style
*** if.c 22 Apr 2004 00:10:47 -0000 1.1
--- if.c 13 Sep 2004 16:29:32 -0000
***************
*** 310,320 ****
--- 310,322 ----

                if (--ifm->ifq_so->so_queued == 0)
                   /* If there's no more queued, reset nqueued */
                   ifm->ifq_so->so_nqueued = 0;
        }
  
        /* Encapsulate the packet for sending */
          if_encap(ifm->m_data, ifm->m_len);

+ m_free(ifm);
+

        if (if_queued)
           goto again;

}

#1 lore raw

I can verify this behaviour; I have a bug filed on the savannah site.

D

Quoted 44 lines · Juergen Keil

Hi,

apparently there is a qemu memory leak when -user-net is used. ftp'ing a ~500Mbyte file from the host os to the guest os increases memory usage for the "qemu -m 256" process from ~280mb to almost 2gb.

It seems the problem is in slirp/if.c, if_start(). If fetches queued mbuf's, sends them, but does not return the mbufs to the free mbuf pool.

Shouldn't if_start() return mbufs to the free mbuf pool after transmitting the data, like this?

Index: if.c
===================================================================
RCS file: /cvsroot/qemu/qemu/slirp/if.c,v retrieving revision 1.1
diff -u -B -c -8 -r1.1 if.c
cvs diff: conflicting specifications of output style
*** if.c 22 Apr 2004 00:10:47 -0000 1.1
--- if.c 13 Sep 2004 16:29:32 -0000
***************
*** 310,320 ****
--- 310,322 ----

                if (--ifm->ifq_so->so_queued == 0)
                   /* If there's no more queued, reset nqueued */
                   ifm->ifq_so->so_nqueued = 0;
        }
  
        /* Encapsulate the packet for sending */
          if_encap(ifm->m_data, ifm->m_len);

+ m_free(ifm);
+

        if (if_queued)
           goto again;

}

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Signature · 1 line
Darryl Dixon <[email protected]>