kasan: resched in quarantine_remove_cache()
[linux-2.6-block.git] / mm / kasan / quarantine.c
index 6f1ed16308736918730ea836b5fecafc908e487b..4ac39f20757a8b116a7a3d66eea99c5a23057055 100644 (file)
@@ -283,8 +283,15 @@ void quarantine_remove_cache(struct kmem_cache *cache)
        on_each_cpu(per_cpu_remove_cache, cache, 1);
 
        spin_lock_irqsave(&quarantine_lock, flags);
-       for (i = 0; i < QUARANTINE_BATCHES; i++)
+       for (i = 0; i < QUARANTINE_BATCHES; i++) {
+               if (qlist_empty(&global_quarantine[i]))
+                       continue;
                qlist_move_cache(&global_quarantine[i], &to_free, cache);
+               /* Scanning whole quarantine can take a while. */
+               spin_unlock_irqrestore(&quarantine_lock, flags);
+               cond_resched();
+               spin_lock_irqsave(&quarantine_lock, flags);
+       }
        spin_unlock_irqrestore(&quarantine_lock, flags);
 
        qlist_free_all(&to_free, cache);