Skip to contentSkip to conversation

Staging: netlogic: Remove unnecessary 'out of memory' message

PATCH In review Wentao Cai 2 participants 4 messages Mar 12, 2019 Staging

lore
Share & tools
lore

Wentao Cai

author
#0 lore raw

PATCH 1/1 Staging: netlogic: Remove unnecessary 'out of memory' message

Remove unnecessary 'out of memory' message to silence checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

---
 drivers/staging/netlogic/xlr_net.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/netlogic/xlr_net.c +1 -3
index 8554fcf4321b..10f14a5cf490 100644
@@ -185,10 +185,8 @@ static int xlr_net_fill_rx_ring(struct net_device *ndev)
 
 	for (i = 0; i < MAX_FRIN_SPILL / 4; i++) {
 		skb_data = xlr_alloc_skb();
-		if (!skb_data) {
-			netdev_err(ndev, "SKB allocation failed\n");
+		if (!skb_data)
 			return -ENOMEM;
-		}
 		send_to_rfr_fifo(priv, skb_data);
 	}
 	netdev_info(ndev, "Rx ring setup done\n");
Signature · 1 line
2.11.0
#1 lore raw
Quoted 3 lines · Wentao Cai

Remove unnecessary 'out of memory' message to silence checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

A better log message would explain why the message is not necessary. I guess that if you unfold this, you will end up at kmalloc, which provides a backtrace on failure, so the message is not very useful. But you should trace thrugh the definition to see that this is actually what happens.

julia

Quoted 32 lines
---
 drivers/staging/netlogic/xlr_net.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/netlogic/xlr_net.c +1 -4
index 8554fcf4321b..10f14a5cf490 100644
@@ -185,10 +185,8 @@ static int xlr_net_fill_rx_ring(struct net_device *ndev)
 
 	for (i = 0; i < MAX_FRIN_SPILL / 4; i++) {
 		skb_data = xlr_alloc_skb();
-		if (!skb_data) {
-			netdev_err(ndev, "SKB allocation failed\n");
+		if (!skb_data)
 			return -ENOMEM;
-		}
 		send_to_rfr_fifo(priv, skb_data);
 	}
 	netdev_info(ndev, "Rx ring setup done\n");
--

2.11.0

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190312093511.3789-1-etsai042%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 8 lines · Julia Lawall

A better log message would explain why the message is not necessary. I guess that if you unfold this, you will end up at kmalloc, which provides a backtrace on failure, so the message is not very useful. But you should trace thrugh the definition to see that this is actually what happens.

I traced down the memory alloc function to alloc_skb (network buffer alloc), all the way down to kmem_cache_alloc, which had
a trace_kmem_cache_alloc function to provide a skb alloc trace. I understand that "out of memory" message can be found in the stack dump done by the memory subsystem. Thus this "out of memory" error is unnecessary. But I don't know how to present this in log message. Is "Delete netdev_err since generic message can be found in stack dump" good for this?

Wentao

Quoted 42 lines

julia

Review

Quoted 7 lines
Signed-off-by Wentao Cai <[email protected] <javascript:>>

---

 drivers/staging/netlogic/xlr_net.c | 4 +--- 
 1 file changed, 1 insertion(+), 3 deletions(-) 
(quoted diff) +0 -0

b/drivers/staging/netlogic/xlr_net.c

drivers/staging/netlogic/xlr_net.c static int xlr_net_fill_rx_ring(struct net_device

Quoted 4 lines

index 8554fcf4321b..10f14a5cf490 100644

drivers/staging/netlogic/xlr_net.c +0 -0
@@ -185,10 +185,8 @@ static int xlr_net_fill_rx_ring(struct net_device 

*ndev)

Quoted 12 lines
drivers/staging/netlogic/xlr_net.c +1 -4
         for (i = 0; i < MAX_FRIN_SPILL / 4; i++) { 
                 skb_data = xlr_alloc_skb(); 
-                if (!skb_data) { 
-                        netdev_err(ndev, "SKB allocation failed\n"); 
+                if (!skb_data) 
                         return -ENOMEM; 
-                } 
                 send_to_rfr_fifo(priv, skb_data); 
         } 
         netdev_info(ndev, "Rx ring setup done\n"); 
-- 
Quoted 4 lines

2.11.0

Signature · 1 line
You received this message because you are subscribed to the Google 

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected] <javascript:>.

Quoted 1 line

To post to this group, send email to [email protected]

<javascript:>.

Quoted 1 line

To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/20190312093511.3789-1-etsai042%40gmail.com.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 11 lines · On Tue, 12 Mar 2019, [email protected] wrote:

On Tuesday, March 12, 2019 at 5:14:30 AM UTC-7, Julia Lawall wrote:

A better log message would explain why the message is not necessary. ᅵI guess that if you unfold this, you will end up at kmalloc, which provides a backtrace on failure, so the message is not very useful. ᅵBut you should trace thrugh the definition to see that this is actually what happens.ᅵ

Quoted 3 lines

I traced down the memory alloc function toᅵalloc_skb (network buffer alloc), all the way down to kmem_cache_alloc, which had aᅵtrace_kmem_cache_alloc function to provide a skb alloc trace. I understand that "out of memory" message can be found in the stack dump done by the memory subsystem. Thus this "out of memory" error is unnecessary. But I don't know how to present this in log message. Is "Deleteᅵnetdev_errᅵsince generic message can be found in stack dump" good for this?

OK, I'm not really sure where the backtrace is actually generated. Perhaps it would be better to say nothing than something incorrect.

julia

Quoted 47 lines

Wentao
ᅵᅵᅵ
ᅵ

      julia

      >
      > Signed-off-by: Wentao Cai <[email protected]>
      > ---
      > ᅵdrivers/staging/netlogic/xlr_net.c | 4 +---
      > ᅵ1 file changed, 1 insertion(+), 3 deletions(-)
      >
      > diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c
      > index 8554fcf4321b..10f14a5cf490 100644
      > --- a/drivers/staging/netlogic/xlr_net.c
      > +++ b/drivers/staging/netlogic/xlr_net.c
      > @@ -185,10 +185,8 @@ static int xlr_net_fill_rx_ring(struct net_device *ndev)
      >
      > ᅵᅵᅵᅵᅵᅵᅵᅵᅵfor (i = 0; i < MAX_FRIN_SPILL / 4; i++) {
      > ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵskb_data = xlr_alloc_skb();
      > -ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵif (!skb_data) {
      > -ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵnetdev_err(ndev, "SKB allocation failed\n");
      > +ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵif (!skb_data)
      > ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵreturn -ENOMEM;
      > -ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵ}
      > ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵsend_to_rfr_fifo(priv, skb_data);
      > ᅵᅵᅵᅵᅵᅵᅵᅵᅵ}
      > ᅵᅵᅵᅵᅵᅵᅵᅵᅵnetdev_info(ndev, "Rx ring setup done\n");
      > --
      > 2.11.0
      >
      > --
      > You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
      > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
      > To post to this group, send email to [email protected].
      > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190312093511.3789-1-etsai042%40gmail.com.
      > For more options, visit https://groups.google.com/d/optout.
      >

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/c09680e5-0bce-4c70-b601-4dd1a6b0d215%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.