From eee87314d302a0d99aef4517738bd13f4e6eb56d Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Sun, 27 Aug 2017 05:14:48 +0000 Subject: [PATCH] Improve scheduler performance Improve scheduler performance by flattening nonsensical topology layers (layers with only one child don't serve any purpose). This is especially relevant on non-AMD Zen systems after r322776. On my dual core Intel laptop, this brings the kern.sched.topology_spec table down from three levels to two. Submitted by: jeff Reviewed by: attilio Sponsored by: Dell EMC Isilon --- sys/kern/subr_smp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 5fb3692dfc2..81e11ee70e7 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -630,6 +630,15 @@ smp_topo(void) panic("Built bad topology at %p. CPU mask (%s) != (%s)", top, cpusetobj_strprint(cpusetbuf, &top->cg_mask), cpusetobj_strprint(cpusetbuf2, &all_cpus)); + + /* + * Collapse nonsense levels that may be created out of convenience by + * the MD layers. They cause extra work in the search functions. + */ + while (top->cg_children == 1) { + top = &top->cg_child[0]; + top->cg_parent = NULL; + } return (top); }