Skip to content

Commit cc2e9d2

Browse files
rientjestehcaster
authored andcommitted
mm, slab: periodically resched in drain_freelist()
drain_freelist() can be called with a very large number of slabs to free, such as for kmem_cache_shrink(), or depending on various settings of the slab cache when doing periodic reaping. If there is a potentially long list of slabs to drain, periodically schedule to ensure we aren't saturating the cpu for too long. Signed-off-by: David Rientjes <rientjes@google.com> Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
1 parent 88603b6 commit cc2e9d2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mm/slab.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,6 +2211,8 @@ static int drain_freelist(struct kmem_cache *cache,
22112211
raw_spin_unlock_irq(&n->list_lock);
22122212
slab_destroy(cache, slab);
22132213
nr_freed++;
2214+
2215+
cond_resched();
22142216
}
22152217
out:
22162218
return nr_freed;

0 commit comments

Comments
 (0)