[PATCH] batman-adv: batch softirq drain in tt_purge to fix workque= lockup
From: =3D?UTF-8?q?=3DC3=3D96mer=3D20Mete=3D20Kaya?=3D
Date: Wed Oct 28 2026 - 14:38:11 EST
Replace per-bucket spin_lock_bh()/spin_unlock_bh() with outer
local_bh_disable()/enable() and periodic drain every 64 buckets
to avoid excessive softirq processing during TT purge.
Add may_sleep parameter to batadv_tt_local_purge() since it is
called both from workqueue context (where cond_resched is safe)
and under commit_lock spinlock in batadv_tt_local_resize_to_mtu()
(where sleeping is not allowed).
Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
Reported-by: syzbot+61b202fdc410840f0198@xxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: =C3=96mer Mete Kaya <omermetekaya0@xxxxxxxxx>
---
net/batman-adv/translation-table.c | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translatio=
n-table.c
index 68f79853032e..915f5589e056 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1386,21 +1386,29 @@ static void batadv_tt_local_purge_list(struct batad=
v_priv *bat_priv,
* inactive or not
*/
static void batadv_tt_local_purge(struct batadv_priv *bat_priv,
- int timeout)
+ int timeout, bool may_sleep)
{
spinlock_t *list_lock; /* protects write access to the hash lists */
struct batadv_hashtable *hash =3D bat_priv->tt.local_hash;
struct hlist_head *head;
u32 i;
+ local_bh_disable();
for (i =3D 0; i < hash->size; i++) {
head =3D &hash->table[i];
list_lock =3D &hash->list_locks[i];
- spin_lock_bh(list_lock);
+ spin_lock(list_lock);
batadv_tt_local_purge_list(bat_priv, head, timeout);
- spin_unlock_bh(list_lock);
+ spin_unlock(list_lock);
+
+ if (may_sleep && (i & 63) =3D=3D 63) {
+ local_bh_enable();
+ cond_resched();
+ local_bh_disable();
+ }
}
+ local_bh_enable();
}
/**
@@ -2363,11 +2371,12 @@ static void batadv_tt_global_purge(struct batadv_pr=
iv *bat_priv)
char *msg =3D NULL;
u32 i;
+ local_bh_disable();
for (i =3D 0; i < hash->size; i++) {
head =3D &hash->table[i];
list_lock =3D &hash->list_locks[i];
- spin_lock_bh(list_lock);
+ spin_lock(list_lock);
hlist_for_each_entry_safe(tt_common, node_tmp, head,
hash_entry) {
tt_global =3D container_of(tt_common,
@@ -2387,8 +2396,15 @@ static void batadv_tt_global_purge(struct batadv_pri=
v *bat_priv)
batadv_tt_global_entry_put(tt_global);
}
- spin_unlock_bh(list_lock);
+ spin_unlock(list_lock);
+
+ if ((i & 63) =3D=3D 63) {
+ local_bh_enable();
+ cond_resched();
+ local_bh_disable();
+ }
}
+ local_bh_enable();
}
/**
@@ -3750,7 +3766,7 @@ static void batadv_tt_purge(struct work_struct *work)
priv_tt =3D container_of(delayed_work, struct batadv_priv_tt, work);
bat_priv =3D container_of(priv_tt, struct batadv_priv, tt);
- batadv_tt_local_purge(bat_priv, BATADV_TT_LOCAL_TIMEOUT);
+ batadv_tt_local_purge(bat_priv, BATADV_TT_LOCAL_TIMEOUT, true);
batadv_tt_global_purge(bat_priv);
batadv_tt_req_purge(bat_priv);
batadv_tt_roam_purge(bat_priv);
@@ -4156,7 +4172,7 @@ void batadv_tt_local_resize_to_mtu(struct net_device =
*mesh_iface)
if (packet_size_max >=3D table_size)
break;
- batadv_tt_local_purge(bat_priv, timeout);
+ batadv_tt_local_purge(bat_priv, timeout, false);
batadv_tt_local_purge_pending_clients(bat_priv);
timeout /=3D 2;
--
2.56.0