diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2017-08-22 00:10:15 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2017-08-22 00:10:15 +0000 |
commit | bb14d5643b201963bf016eacb00a2ff49e6d86e7 (patch) | |
tree | 3e773b6b302196db235268eb2a7a5fece0daeb58 /sys/x86 | |
parent | 9b0ddce6bc6e64c8ce6c0b466ca19718bdbe7408 (diff) | |
download | src-bb14d5643b201963bf016eacb00a2ff49e6d86e7.tar.gz src-bb14d5643b201963bf016eacb00a2ff49e6d86e7.zip |
subr_smp: Clean up topology analysis, add additional layers
Rather than repeatedly nesting loops, separate concerns with a single loop
per call stack level. Use a table to drive the recursive routine. Handle
missing topology layers more gracefully (infer a single unit).
Analyze some additional optional layers which may be present on e.g. AMD Zen
systems (groups, aka dies, per package; and cachegroups, aka CCXes, per
group).
Display that additional information in the boot-time topology information,
when it is relevent (non-one).
Reviewed by: markj@, mjoras@ (earlier version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D12019
Notes
Notes:
svn path=/head/; revision=322776
Diffstat (limited to 'sys/x86')
-rw-r--r-- | sys/x86/x86/mp_x86.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index 5df2b6852395..c14b181913b2 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -662,18 +662,23 @@ cpu_mp_announce(void) { struct topo_node *node; const char *hyperthread; - int pkg_count; - int cores_per_pkg; - int thrs_per_core; + struct topo_analysis topology; printf("FreeBSD/SMP: "); - if (topo_analyze(&topo_root, 1, &pkg_count, - &cores_per_pkg, &thrs_per_core)) { - printf("%d package(s)", pkg_count); - if (cores_per_pkg > 0) - printf(" x %d core(s)", cores_per_pkg); - if (thrs_per_core > 1) - printf(" x %d hardware threads", thrs_per_core); + if (topo_analyze(&topo_root, 1, &topology)) { + printf("%d package(s)", topology.entities[TOPO_LEVEL_PKG]); + if (topology.entities[TOPO_LEVEL_GROUP] > 1) + printf(" x %d groups", + topology.entities[TOPO_LEVEL_GROUP]); + if (topology.entities[TOPO_LEVEL_CACHEGROUP] > 1) + printf(" x %d cache groups", + topology.entities[TOPO_LEVEL_CACHEGROUP]); + if (topology.entities[TOPO_LEVEL_CORE] > 0) + printf(" x %d core(s)", + topology.entities[TOPO_LEVEL_CORE]); + if (topology.entities[TOPO_LEVEL_THREAD] > 1) + printf(" x %d hardware threads", + topology.entities[TOPO_LEVEL_THREAD]); } else { printf("Non-uniform topology"); } @@ -681,13 +686,21 @@ cpu_mp_announce(void) if (disabled_cpus) { printf("FreeBSD/SMP Online: "); - if (topo_analyze(&topo_root, 0, &pkg_count, - &cores_per_pkg, &thrs_per_core)) { - printf("%d package(s)", pkg_count); - if (cores_per_pkg > 0) - printf(" x %d core(s)", cores_per_pkg); - if (thrs_per_core > 1) - printf(" x %d hardware threads", thrs_per_core); + if (topo_analyze(&topo_root, 0, &topology)) { + printf("%d package(s)", + topology.entities[TOPO_LEVEL_PKG]); + if (topology.entities[TOPO_LEVEL_GROUP] > 1) + printf(" x %d groups", + topology.entities[TOPO_LEVEL_GROUP]); + if (topology.entities[TOPO_LEVEL_CACHEGROUP] > 1) + printf(" x %d cache groups", + topology.entities[TOPO_LEVEL_CACHEGROUP]); + if (topology.entities[TOPO_LEVEL_CORE] > 0) + printf(" x %d core(s)", + topology.entities[TOPO_LEVEL_CORE]); + if (topology.entities[TOPO_LEVEL_THREAD] > 1) + printf(" x %d hardware threads", + topology.entities[TOPO_LEVEL_THREAD]); } else { printf("Non-uniform topology"); } |