Re: [RFC v3] net/core: add optional threading for backlog processing

From: Felix Fietkau
Date: Mon Feb 20 2023 - 03:23:20 EST


On 20.02.23 01:41, Hillf Danton wrote:
On Sun, 19 Feb 2023 14:10:05 +0100 Felix Fietkau <nbd@xxxxxxxx>
/* Network device is going away, flush any packets still pending */
static void flush_backlog(struct work_struct *work)
{
+ 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);
+ 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