Skip to contentSkip to conversation

Freeing skbs (again)

DISCUSSION Jacob Gorm Hansen 2 participants 3 messages Apr 27, 2004

lore
Share & tools
lore
#0 lore raw

My situation is this:

- interrupts are off
- one xenolinux network device is active
- there are buffered rx requests in the rx_ring
- I need to reset this ring in a minute
- I wish to free all the out-of-band pages allocated in my guest OS, so they are not leaked when I reset the ring

I am trying this:

NET_RING_IDX i = np->net_idx->rx_resp_prod;

while (i != np->net_idx->rx_req_prod)
{
unsigned short id =
np->net_ring->rx_ring[MASK_NET_RX_IDX(i++)].req.id;

    struct sk_buff* skb = np->rx_skbs[id];
    dev_kfree_skb_any(skb);
}

-- which crashes on dev_kfree_skb_any().

Can anyone tell my why I cannot free these skbs?

Thanks,
Jacob

-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297

#1 lore raw
Quoted 6 lines · Jacob Gorm Hansen
    struct sk_buff* skb = np->rx_skbs[id];
    dev_kfree_skb_any(skb);
}

-- which crashes on dev_kfree_skb_any().

I guess I know why now. The skb->head ptrs all point to pages that are no longer mapped, this is why accessing data pointed to by skb_shinfo() (which the dealloc routine does) is bad. I could manually kfree(skb->head); but this still leaves empty mappings in the virtual memory map :-(

I guess I need to flush the rings instead, but I suppose that means xen-queued outgoing packets will be dropped? Maybe I will just have to live with that.

Jacob

-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297

#2 lore raw
Quoted 9 lines

I guess I know why now. The skb->head ptrs all point to pages that are no longer mapped, this is why accessing data pointed to by skb_shinfo() (which the dealloc routine does) is bad. I could manually kfree(skb->head); but this still leaves empty mappings in the virtual memory map :-(

I guess I need to flush the rings instead, but I suppose that means xen-queued outgoing packets will be dropped? Maybe I will just have to live with that.

NETOP_FLUSH_BUFFERS causes Xen to flush all the buffers it can. This is every transmit buffer and every receive buffer /except/ for trasnmit buffers that have been queued at the physical NIC. For these the guest OS must spin/block until responses have been received some (short) time later.

If you want all pending tx packets be to be sent then you should spin on the tx_cons and _prod indexes /before/ calling NETOP_FLUSH_BUFFERS.

-- Keir

-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297