Hui Su
unread,Aug 8, 2026, 3:14:11 PM (yesterday) Aug 8Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ryabin...@gmail.com, ak...@linux-foundation.org, kasa...@googlegroups.com, linu...@kvack.org, gli...@google.com, andre...@gmail.com, dvy...@google.com, vincenzo...@arm.com, linux-...@vger.kernel.org, Hui Su
kasan_quarantine_remove_cache() drops quarantine_lock and restores
interrupts after scanning each non-empty quarantine batch so that
cond_resched() can schedule during a long scan.
When no reschedule is pending, the unlock/IRQ restore and subsequent
IRQ save/relock cycle is unnecessary.
Check need_resched() before cycling quarantine_lock to avoid this
overhead when rescheduling is not needed.
Suggested-by: Andrew Morton <
ak...@linux-foundation.org>
Signed-off-by: Hui Su <
sh_...@163.com>
---
mm/kasan/quarantine.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c
index 6958aa713c67..db7170f6f1b2 100644
--- a/mm/kasan/quarantine.c
+++ b/mm/kasan/quarantine.c
@@ -368,10 +368,12 @@ void kasan_quarantine_remove_cache(struct kmem_cache *cache)
if (qlist_empty(&global_quarantine[i]))
continue;
qlist_move_cache(&global_quarantine[i], &to_free, cache);
- /* Scanning whole quarantine can take a while. */
- raw_spin_unlock_irqrestore(&quarantine_lock, flags);
- cond_resched();
- raw_spin_lock_irqsave(&quarantine_lock, flags);
+ if (need_resched()) {
+ /* Scanning whole quarantine can take a while. */
+ raw_spin_unlock_irqrestore(&quarantine_lock, flags);
+ cond_resched();
+ raw_spin_lock_irqsave(&quarantine_lock, flags);
+ }
}
raw_spin_unlock_irqrestore(&quarantine_lock, flags);
--
2.43.0