Skip to content

Commit

Permalink
mm, slab: periodically resched in drain_freelist()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Rientjes authored and Vlastimil Babka committed Jan 2, 2023
1 parent 88603b6 commit cc2e9d2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -2211,6 +2211,8 @@ static int drain_freelist(struct kmem_cache *cache,
raw_spin_unlock_irq(&n->list_lock);
slab_destroy(cache, slab);
nr_freed++;

cond_resched();
}
out:
return nr_freed;
Expand Down

0 comments on commit cc2e9d2

Please sign in to comment.