Skip to contentSkip to conversation

Fix memory leak for copy-receiver of netfront

PATCH In review Kasai Takanori 2 participants 3 messages Jun 11, 2008 – Jun 12, 2008 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix memory leak for copy-receiver of netfront

Hi all,

We found the problem of the memory leak when working with copy- receiver of netfront.

The source of a problem is that the fragment page is not released with dev_kfree_skb() because the nr_frags variable of skb is set to 0.

This is the patch to fix memory leak in netfront.

A guest kernel does panic if attaching and detaching VNIF is repeated. Because guest memory becomes empty, and OOM killer is run. It is a log of that time as follows.

------------------------------------------------------------------------
<dom0 log>

# xm network-attach guest
# xm network-detach guest 0
# xm network-attach guest
# xm network-detach guest 1
... repeat ...
# xm network-attach guest
# xm network-detach guest 179
# xm network-attach guest
# xm network-detach guest 180
Error: Domain 'guest' does not exist.

<guest log>

# free -m
             total       used       free     shared    buffers     
cached
Mem:           512        504          8          0         23        
174
-/+ buffers/cache:        305        206
Swap:          511          0        511
... repeat ...
# free -m
             total       used       free     shared    buffers     
cached
Mem:           512        509          2          0          0          
1
-/+ buffers/cache:        507          4
Swap:          511         50        461
awk invoked oom-killer: gfp_mask=0x201d2, order=0, oomkilladj=-17
Call Trace:
 [<a00000010001d160>] show_stack+0x40/0xa0
                                sp=e00000001e0a7a70 bsp=e00000001e0a1480
 [<a00000010001d1f0>] dump_stack+0x30/0x60
                                sp=e00000001e0a7c40 bsp=e00000001e0a1468
 [<a00000010011b1b0>] out_of_memory+0xf0/0x780
                                sp=e00000001e0a7c40 bsp=e00000001e0a1430
 [<a000000100121040>] __alloc_pages+0x420/0x540
                                sp=e00000001e0a7cd0 bsp=e00000001e0a13b8
... snip ...
Kernel panic - not syncing: Out of memory and no killable processes...
------------------------------------------------------------------------

Best Regards,

---
Takanori Kasai

# HG changeset patch
# User [email protected]
# Date 1213152670 -32400
# Node ID 34c91cf0ba1419f7660b800e0dcb7a1c335e32be # Parent 5db911a71eac6b0b19e74398f0750ce12fb1b94b Fix memory leak for copy-receiver of netfront.

drivers/xen/netfront/netfront.c +0 -1
diff -r 5db911a71eac -r 34c91cf0ba14 drivers/xen/netfront/netfront.c
@@ -1667,7 +1667,6 @@ static void netif_release_rx_bufs_copy(s
 		np->grant_rx_ref[i] = GRANT_INVALID_REF;
 		add_id_to_freelist(np->rx_skbs, i);
 
-		skb_shinfo(skb)->nr_frags = 0;
 		dev_kfree_skb(skb);
 	}
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 9 lines · Kasai Takanori

Hi all,

We found the problem of the memory leak when working with copy- receiver of netfront.

The source of a problem is that the fragment page is not released with dev_kfree_skb() because the nr_frags variable of skb is set to 0.

This is the patch to fix memory leak in netfront.

This code doesn't apply to the current 2.6.25 version of netfront. The only similar code I could see is:

               skb = np->rx_skbs[id];
               mfn = gnttab_end_foreign_transfer_ref(ref);
               gnttab_release_grant_reference(&np->gref_rx_head, ref);
               np->grant_rx_ref[id] = GRANT_INVALID_REF;

               if (0 == mfn) {
                       skb_shinfo(skb)->nr_frags = 0;
                       dev_kfree_skb(skb);
                       noxfer++;
                       continue;
               }

Would you mind reviewing the 2.6.25 version of netfront to see if it needs a patch?

Thanks,
J

#2 lore raw

Hi Jeremy,

I reviewed the 2.6.25 versions of netfront.

First of all, the xennet_release_rx_bufs() function is freeing processing of flipping mode.
Therefore, more memory leaks are generated.

It is necessary to change to the freeing processing of the copy-receiver mode referring to the following patch.
http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/41918416db51

And, if this patch that we made is applied, the memory leak will not be generated.

Best Regards,

---
Takanori Kasai

---------- Original Message ----------

Quoted 45 lines
Date:     2008/06/12
From:     Jeremy Fitzhardinge <[email protected]>
To:       Kasai Takanori <[email protected]>

Cc: xen-devel <[email protected]>
Subject: Re: [Xen-devel] [PATCH]Fix memory leak for copy-receiver of
netfront

Quoted 10 lines · Kasai Takanori

Hi all,

We found the problem of the memory leak when working with copy- receiver of netfront.

The source of a problem is that the fragment page is not released with dev_kfree_skb() because the nr_frags variable of skb is set to 0.

This is the patch to fix memory leak in netfront.

This code doesn't apply to the current 2.6.25 version of netfront. The only similar code I could see is:

               skb = np->rx_skbs[id];
               mfn = gnttab_end_foreign_transfer_ref(ref);
               gnttab_release_grant_reference(&np->gref_rx_head, ref);
               np->grant_rx_ref[id] = GRANT_INVALID_REF;

               if (0 == mfn) {
                       skb_shinfo(skb)->nr_frags = 0;
                       dev_kfree_skb(skb);
                       noxfer++;
                       continue;
               }

Would you mind reviewing the 2.6.25 version of netfront to see if it needs a patch?

Thanks,
J

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel