Skip to content

Commit 4cdc8a7

Browse files
leitaohtejun
authored andcommitted
workqueue: set WQ_AFFN_CACHE_SHARD as the default affinity scope
Set WQ_AFFN_CACHE_SHARD as the default affinity scope for unbound workqueues. On systems where many CPUs share one LLC, the previous default (WQ_AFFN_CACHE) collapses all CPUs to a single worker pool, causing heavy spinlock contention on pool->lock. WQ_AFFN_CACHE_SHARD subdivides each LLC into smaller groups, providing a better balance between locality and contention. Users can revert to the previous behavior with workqueue.default_affinity_scope=cache. On systems with 8 or fewer cores per LLC, CACHE_SHARD produces a single shard covering the entire LLC, making it functionally identical to the previous CACHE default. The sharding only activates when an LLC has more than 8 cores. Signed-off-by: Breno Leitao <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 5920d04 commit 4cdc8a7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/workqueue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ static bool wq_topo_initialized __read_mostly = false;
450450
static struct kmem_cache *pwq_cache;
451451

452452
static struct wq_pod_type wq_pod_types[WQ_AFFN_NR_TYPES];
453-
static enum wq_affn_scope wq_affn_dfl = WQ_AFFN_CACHE;
453+
static enum wq_affn_scope wq_affn_dfl = WQ_AFFN_CACHE_SHARD;
454454

455455
/* buf for wq_update_unbound_pod_attrs(), protected by CPU hotplug exclusion */
456456
static struct workqueue_attrs *unbound_wq_update_pwq_attrs_buf;

0 commit comments

Comments
 (0)