Skip to content

Commit f506d5a

Browse files
markjdbdag-erling
authored andcommittedMar 17, 2025·
uma: Avoid excessive per-CPU draining
After commit 389a3fa, uma_reclaim_domain(UMA_RECLAIM_DRAIN_CPU) calls uma_zone_reclaim_domain(UMA_RECLAIM_DRAIN_CPU) twice on each zone in addition to globally draining per-CPU caches. This was unintended and is unnecessarily slow; in particular, draining per-CPU caches requires binding to each CPU. Stop draining per-CPU caches when visiting each zone, just do it once in pcpu_cache_drain_safe() to minimize the amount of expensive sched_bind() calls. Fixes: 389a3fa ("uma: Add UMA_ZONE_UNMANAGED") MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: gallatin, kib Differential Revision: https://reviews.freebsd.org/D49349
1 parent 027b93c commit f506d5a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎sys/vm/uma_core.c

+7
Original file line numberDiff line numberDiff line change
@@ -5339,6 +5339,13 @@ uma_reclaim_domain(int req, int domain)
53395339
zone_foreach(uma_reclaim_domain_cb, &args);
53405340
break;
53415341
case UMA_RECLAIM_DRAIN_CPU:
5342+
/*
5343+
* Reclaim globally visible free items from all zones, then drain
5344+
* per-CPU buckets, then reclaim items freed while draining.
5345+
* This approach minimizes expensive context switching needed to
5346+
* drain each zone's per-CPU buckets.
5347+
*/
5348+
args.req = UMA_RECLAIM_DRAIN;
53425349
zone_foreach(uma_reclaim_domain_cb, &args);
53435350
pcpu_cache_drain_safe(NULL);
53445351
zone_foreach(uma_reclaim_domain_cb, &args);

0 commit comments

Comments
 (0)
Please sign in to comment.