Skip to content

Commit

Permalink
Revert "net: rtnetlink: remove local list in __linkwatch_run_queue()"
Browse files Browse the repository at this point in the history
This reverts commit b8dbbbc ("net: rtnetlink: remove local list
in __linkwatch_run_queue()"). It's evidently broken when there's a
non-urgent work that gets added back, and then the loop can never
finish.

While reverting, add a note about that.

Reported-by: Marek Szyprowski <[email protected]>
Fixes: b8dbbbc ("net: rtnetlink: remove local list in __linkwatch_run_queue()")
Signed-off-by: Johannes Berg <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jmberg-intel authored and davem330 committed Dec 11, 2023
1 parent 18c5c0a commit 9a64d4c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions net/core/link_watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ static void __linkwatch_run_queue(int urgent_only)
#define MAX_DO_DEV_PER_LOOP 100

int do_dev = MAX_DO_DEV_PER_LOOP;
/* Use a local list here since we add non-urgent
* events back to the global one when called with
* urgent_only=1.
*/
LIST_HEAD(wrk);

/* Give urgent case more budget */
if (urgent_only)
Expand All @@ -213,11 +218,12 @@ static void __linkwatch_run_queue(int urgent_only)
clear_bit(LW_URGENT, &linkwatch_flags);

spin_lock_irq(&lweventlist_lock);
while (!list_empty(&lweventlist) && do_dev > 0) {
list_splice_init(&lweventlist, &wrk);

while (!list_empty(&wrk) && do_dev > 0) {
struct net_device *dev;

dev = list_first_entry(&lweventlist, struct net_device,
link_watch_list);
dev = list_first_entry(&wrk, struct net_device, link_watch_list);
list_del_init(&dev->link_watch_list);

if (!netif_device_present(dev) ||
Expand All @@ -235,6 +241,9 @@ static void __linkwatch_run_queue(int urgent_only)
spin_lock_irq(&lweventlist_lock);
}

/* Add the remaining work back to lweventlist */
list_splice_init(&wrk, &lweventlist);

if (!list_empty(&lweventlist))
linkwatch_schedule_work(0);
spin_unlock_irq(&lweventlist_lock);
Expand Down

0 comments on commit 9a64d4c

Please sign in to comment.