netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] macvlan.c: schedule port->bc_work even if error
  2019-11-25  6:59 [PATCH] macvlan.c: schedule port->bc_work even if error Menglong Dong
@ 2019-11-25  6:58 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-11-25  6:58 UTC (permalink / raw)
  To: dong.menglong
  Cc: petrm, jiri, gustavo, liuhangbin, ap420073, jwi, mcroce, tglx,
	netdev, linux-kernel, xue.zhihong, wang.yi59, jiang.xuexin

From: Menglong Dong <dong.menglong@zte.com.cn>
Date: Mon, 25 Nov 2019 14:59:03 +0800

> While enqueueing a broadcast skb to port->bc_queue, schedule_work()
> is called to add port->bc_work, which processes the skbs in
> bc_queue, to "events" work queue. If port->bc_queue is full, the
> skb will be discarded and schedule_work(&port->bc_work) won't be
> called. However, if port->bc_queue is full and port->bc_work is not
> running or pending, port->bc_queue will keep full and schedule_work()
> won't be called any more, and all broadcast skbs to macvlan will be
> discarded. This case can happen:
> 
> macvlan_process_broadcast() is the pending function of port->bc_work,
> it moves all the skbs in port->bc_queue to the queue "list", and
> processes the skbs in "list". During this, new skbs will keep being
> added to port->bc_queue in macvlan_broadcast_enqueue(), and
> port->bc_queue may already full when macvlan_process_broadcast()
> return. This may happen, especially when there are a lot of real-time
> threads and the process is preempted.
> 
> Fix this by calling schedule_work(&port->bc_work) even if
> port->bc_work is full in macvlan_broadcast_enqueue()
> 
> Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>

The subsystem prefix in your Subject line should not be a source
file, but the name of the module or area you are making changes
to.

Therefore this should be "macvlan: " not "macvlan.c: "

You must also provide an appropriate Fixes: tag when fixing a problem
like this.

Thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] macvlan.c: schedule port->bc_work even if error
@ 2019-11-25  6:59 Menglong Dong
  2019-11-25  6:58 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Menglong Dong @ 2019-11-25  6:59 UTC (permalink / raw)
  To: davem
  Cc: petrm, jiri, gustavo, liuhangbin, ap420073, jwi, mcroce, tglx,
	netdev, linux-kernel, xue.zhihong, wang.yi59, jiang.xuexin,
	Menglong Dong

While enqueueing a broadcast skb to port->bc_queue, schedule_work()
is called to add port->bc_work, which processes the skbs in
bc_queue, to "events" work queue. If port->bc_queue is full, the
skb will be discarded and schedule_work(&port->bc_work) won't be
called. However, if port->bc_queue is full and port->bc_work is not
running or pending, port->bc_queue will keep full and schedule_work()
won't be called any more, and all broadcast skbs to macvlan will be
discarded. This case can happen:

macvlan_process_broadcast() is the pending function of port->bc_work,
it moves all the skbs in port->bc_queue to the queue "list", and
processes the skbs in "list". During this, new skbs will keep being
added to port->bc_queue in macvlan_broadcast_enqueue(), and
port->bc_queue may already full when macvlan_process_broadcast()
return. This may happen, especially when there are a lot of real-time
threads and the process is preempted.

Fix this by calling schedule_work(&port->bc_work) even if
port->bc_work is full in macvlan_broadcast_enqueue()

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
---
 drivers/net/macvlan.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 940192c..ef2c4f7 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -359,10 +359,11 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
 	}
 	spin_unlock(&port->bc_queue.lock);
 
+	schedule_work(&port->bc_work);
+
 	if (err)
 		goto free_nskb;
-
-	schedule_work(&port->bc_work);
+
 	return;
 
 free_nskb:
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-25  6:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-25  6:59 [PATCH] macvlan.c: schedule port->bc_work even if error Menglong Dong
2019-11-25  6:58 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).