From: "Ömer Mete Kaya" <omermetekaya0@gmail.com>
To: marek.lindner@mailbox.org, sw@simonwunderlich.de,
antonio@mandelbit.com, sven@narfation.org
Cc: davem@davemloft.net, b.a.t.m.a.n@lists.open-mesh.org,
linux-kernel@vger.kernel.org,
syzbot+61b202fdc410840f0198@syzkaller.appspotmail.com,
"Ömer Mete Kaya" <omermetekaya0@gmail.com>
Subject: [PATCH net] batman-adv: reduce softirq drain in tt_purge loops
Date: Fri, 30 Oct 2026 02:59:51 +0300 [thread overview]
Message-ID: <20261030000222.286935-1-omermetekaya0@gmail.com> (raw)
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@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=61b202fdc410840f0198
Signed-off-by: Ömer Mete Kaya <omermetekaya0@gmail.com>
---
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/translation-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 batadv_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 = bat_priv->tt.local_hash;
struct hlist_head *head;
u32 i;
+ local_bh_disable();
for (i = 0; i < hash->size; i++) {
head = &hash->table[i];
list_lock = &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) == 63) {
+ local_bh_enable();
+ cond_resched();
+ local_bh_disable();
+ }
}
+ local_bh_enable();
}
/**
@@ -2363,11 +2371,12 @@ static void batadv_tt_global_purge(struct batadv_priv *bat_priv)
char *msg = NULL;
u32 i;
+ local_bh_disable();
for (i = 0; i < hash->size; i++) {
head = &hash->table[i];
list_lock = &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 = container_of(tt_common,
@@ -2387,8 +2396,15 @@ static void batadv_tt_global_purge(struct batadv_priv *bat_priv)
batadv_tt_global_entry_put(tt_global);
}
- spin_unlock_bh(list_lock);
+ spin_unlock(list_lock);
+
+ if ((i & 63) == 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 = container_of(delayed_work, struct batadv_priv_tt, work);
bat_priv = 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 >= 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 /= 2;
--
2.56.0
next reply other threads:[~2026-10-30 0:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 23:59 Ömer Mete Kaya [this message]
2026-10-30 8:25 ` Sven Eckelmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261030000222.286935-1-omermetekaya0@gmail.com \
--to=omermetekaya0@gmail.com \
--cc=antonio@mandelbit.com \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=marek.lindner@mailbox.org \
--cc=sven@narfation.org \
--cc=sw@simonwunderlich.de \
--cc=syzbot+61b202fdc410840f0198@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®