Skip to content

Commit 51d2787

Browse files
Igor Druzhiningregkh
authored andcommitted
xen-netback: fix occasional leak of grant ref mappings under memory pressure
[ Upstream commit 99e87f5 ] Zero-copy callback flag is not yet set on frag list skb at the moment xenvif_handle_frag_list() returns -ENOMEM. This eventually results in leaking grant ref mappings since xenvif_zerocopy_callback() is never called for these fragments. Those eventually build up and cause Xen to kill Dom0 as the slots get reused for new mappings: "d0v0 Attempt to implicitly unmap a granted PTE c010000329fce005" That behavior is observed under certain workloads where sudden spikes of page cache writes coexist with active atomic skb allocations from network traffic. Additionally, rework the logic to deal with frag_list deallocation in a single place. Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6e7339d commit 51d2787

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

drivers/net/xen-netback/netback.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,11 +1538,6 @@ static int xenvif_handle_frag_list(struct xenvif_queue *queue, struct sk_buff *s
15381538
skb_frag_size_set(&frags[i], len);
15391539
}
15401540

1541-
/* Copied all the bits from the frag list -- free it. */
1542-
skb_frag_list_init(skb);
1543-
xenvif_skb_zerocopy_prepare(queue, nskb);
1544-
kfree_skb(nskb);
1545-
15461541
/* Release all the original (foreign) frags. */
15471542
for (f = 0; f < skb_shinfo(skb)->nr_frags; f++)
15481543
skb_frag_unref(skb, f);
@@ -1611,6 +1606,8 @@ static int xenvif_tx_submit(struct xenvif_queue *queue)
16111606
xenvif_fill_frags(queue, skb);
16121607

16131608
if (unlikely(skb_has_frag_list(skb))) {
1609+
struct sk_buff *nskb = skb_shinfo(skb)->frag_list;
1610+
xenvif_skb_zerocopy_prepare(queue, nskb);
16141611
if (xenvif_handle_frag_list(queue, skb)) {
16151612
if (net_ratelimit())
16161613
netdev_err(queue->vif->dev,
@@ -1619,6 +1616,9 @@ static int xenvif_tx_submit(struct xenvif_queue *queue)
16191616
kfree_skb(skb);
16201617
continue;
16211618
}
1619+
/* Copied all the bits from the frag list -- free it. */
1620+
skb_frag_list_init(skb);
1621+
kfree_skb(nskb);
16221622
}
16231623

16241624
skb->dev = queue->vif->dev;

0 commit comments

Comments
 (0)