Skip to contentSkip to conversation

net/core: add optional threading for backlog processing

RFC Felix Fietkau 1 participant 1 message Feb 20, 2023 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 35 lines · Hillf Danton

On Sun, 19 Feb 2023 14:10:05 +0100 Felix Fietkau <[email protected]>

Quoted 34 lines

/* Network device is going away, flush any packets still pending */ static void flush_backlog(struct work_struct *work)
{

(quoted diff) +14 -0
+	unsigned int process_queue_empty;
+	bool threaded, flush_processq;
 	struct sk_buff *skb, *tmp;
 	struct softnet_data *sd;
@@ -5792,8 +5794,15 @@ static void flush_backlog(struct work_struct *work)
 			input_queue_head_incr(sd);
 		}
 	}
+
+	threaded = test_bit(NAPI_STATE_THREADED, &sd->backlog.state);
+	flush_processq = threaded &&
+			 !skb_queue_empty_lockless(&sd->process_queue);
 	rps_unlock_irq_enable(sd);
 
+	if (threaded)
+		goto out;
+
 	skb_queue_walk_safe(&sd->process_queue, skb, tmp) {
 		if (skb->dev->reg_state == NETREG_UNREGISTERING) {
 			__skb_unlink(skb, &sd->process_queue);
@@ -5801,7 +5810,16 @@ static void flush_backlog(struct work_struct *work)
 			input_queue_head_incr(sd);
 		}
 	}
+
+out:
 	local_bh_enable();
+
+	while (flush_processq) {
+		msleep(1);
Quoted 8 lines

Review static void flush_backlog(struct work_struct *work) · line 5823

Quoted 5 lines
(quoted diff) +4 -0
+		rps_lock_irq_disable(sd);
+		flush_processq = process_queue_empty == sd->process_queue_empty;
+		rps_unlock_irq_enable(sd);
+	}
 }

Have hard time guessing how this wait works given process_queue_empty not initialized. Is this random check intended?

Please check my initial reply to this patch. I forgot to amend the commit with the missing initialization lines before sending out the patch.

- Felix