ibm_newemac: Fixes memory leak in ibm_newemac ethernet driver
Subsystems (2)
PATCH 1/1 ibm_newemac: Fixes memory leak in ibm_newemac ethernet driver
From: Sathya Narayanan <[email protected]>
This patch addresses the memory leak happenning in drivers transmit queue under heavy load condition. Once the transmit queue becomes full, driver does an automatic wrapup of queue. During which the untransmitted SKB's are lost without getting freed up.
--- drivers/net/ibm_newemac/core.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/ibm_newemac/core.c +7 -0
@@ -1328,6 +1328,13 @@ static int emac_start_xmit(struct sk_buff *skb, struct net_device *ndev)DBG2 (dev,"xmit(%u) %d" NL , len, slot); +if (dev->tx_skb[slot] && dev->tx_desc[slot].data_ptr) { +dev_kfree_skb (dev->tx_skb[slot]); + dev->tx_skb[slot] =NULL ; + dev->tx_cnt--; + ++dev->estats.tx_dropped; + } + dev->tx_skb[slot] = skb; dev->tx_desc[slot].data_ptr = dma_map_single(&dev->ofdev->dev, skb->data, len,
Signature · 1 line
1.5.6
Quoted 6 lines · Stefan Roese
From: Sathya Narayanan <[email protected]>
This patch addresses the memory leak happenning in drivers transmit queue under heavy load condition. Once the transmit queue becomes full, driver does an automatic wrapup of queue. During which the untransmitted SKB's are lost without getting freed up.
This would be a bug. We should stop the queue when full instead.
Quoted 24 lines
Signed-off-by Sathya Narayanan <[email protected]>Signed-off-by Stefan Roese <[email protected]>--- drivers/net/ibm_newemac/core.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)drivers/net/ibm_newemac/core.c +7
-0@@ -1328,6 +1328,13 @@ static int emac_start_xmit(struct sk_buff *skb, struct net_device *ndev)DBG2 (dev,"xmit(%u) %d" NL , len, slot); +if (dev->tx_skb[slot] && dev->tx_desc[slot].data_ptr) { +dev_kfree_skb (dev->tx_skb[slot]); + dev->tx_skb[slot] =NULL ; + dev->tx_cnt--; + ++dev->estats.tx_dropped; + } + dev->tx_skb[slot] = skb; dev->tx_desc[slot].data_ptr = dma_map_single(&dev->ofdev->dev, skb->data, len,
Hi Benn,
Please find my comments below.
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 5 lines · Stefan Roese
From: Sathya Narayanan <[email protected]>
This patch addresses the memory leak happenning in drivers transmit queue under heavy load condition. Once the transmit queue becomes full, driver does an automatic wrapup of queue. During which the untransmitted SKB's
are
Quoted 1 line
lost without getting freed up.
This would be a bug. We should stop the queue when full instead.
Actually the meachanism of stopping the queue and starting it is already there. But even then due to some sync issue between the poll routine and xmit, we were resulted in using the slots of skb which was not actually got freed before.
I agree this could a bug , Since its not is not clear why buffers are not getting transferred timely?. But to handle this we should have a work around otherwise system may go out of memory. If we go for stopping the queue in these scenario also ( Where a unfreed skbs slot has been assigned to another ), Then kernel may call tx timeout, And reset the driver. In that case handelling this special case here could lead us better performance as compared to stopping the queue
Let me know your comments.
Quoted 8 lines
Quoted 8 lines
Signed-off-by Sathya Narayanan <[email protected]>Signed-off-by Stefan Roese <[email protected]>--- drivers/net/ibm_newemac/core.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
Quoted 22 lines
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/net/ibm_newemac/core.cdrivers/net/ibm_newemac/core.c static int emac_start_xmit(struct sk_buff *skb,
Quoted 4 lines
index aa407b2..ee868b6 100644
drivers/net/ibm_newemac/core.c +0
-0@@ -1328,6 +1328,13 @@ static int emac_start_xmit(struct sk_buff *skb,struct
net_device*ndev)Quoted 13 lines
drivers/net/ibm_newemac/core.c +7
-0DBG2 (dev,"xmit(%u) %d" NL , len, slot); +if (dev->tx_skb[slot] && dev->tx_desc[slot].data_ptr) { +dev_kfree_skb (dev->tx_skb[slot]); + dev->tx_skb[slot] =NULL ; + dev->tx_cnt--; + ++dev->estats.tx_dropped; + } + dev->tx_skb[slot] = skb; dev->tx_desc[slot].data_ptr = dma_map_single(&dev->ofdev->dev, skb->data, len,
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
Quoted 14 lines
Actually the meachanism of stopping the queue and starting it is already there. But even then due to some sync issue between the poll routine and xmit, we were resulted in using the slots of skb which was not actually got freed before.
I agree this could a bug , Since its not is not clear why buffers are not getting transferred timely?. But to handle this we should have a work around otherwise system may go out of memory. If we go for stopping the queue in these scenario also ( Where a unfreed skbs slot has been assigned to another ), Then kernel may call tx timeout, And reset the driver. In that case handelling this special case here could lead us better performance as compared to stopping the queue Let me know your comments.
Well, if we have a bug, we need to fix it. ie, understand how it is that the existing mechanism to stop the queue doesn't work, and prevent xmit from overwriting a non-clear transmit slot (possibly displaying an error to help us track down the bug).
I'll have to dig a bit, I'll see if I can find some time tomorrow.
Cheers,
Ben.
Quoted 15 lines · Benjamin Herrenschmidt
Quoted 14 lines
Actually the meachanism of stopping the queue and starting it is already there. But even then due to some sync issue between the poll routine and xmit, we were resulted in using the slots of skb which was not actually got freed before.
I agree this could a bug , Since its not is not clear why buffers are not getting transferred timely?. But to handle this we should have a work around otherwise system may go out of memory. If we go for stopping the queue in these scenario also ( Where a unfreed skbs slot has been assigned to another ), Then kernel may call tx timeout, And reset the driver. In that case handelling this special case here could lead us better performance as compared to stopping the queue Let me know your comments.
Quoted 6 lines
Well, if we have a bug, we need to fix it. ie, understand how it is that the existing mechanism to stop the queue doesn't work, and prevent xmit from overwriting a non-clear transmit slot (possibly displaying an error to help us track down the bug).
I'll have to dig a bit, I'll see if I can find some time tomorrow.
The reason could be sync issue between poll and xmit. I would like to have one clarification , Why in the present design no locks has been implemented to protect the queue from simulatenous access ??
Quoted 8 lines
Cheers,
Ben.
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev