From a92e8f57c562ebd59ca08e2d351ce32b5dbb9a64 Mon Sep 17 00:00:00 2001 From: jeff Date: Sat, 28 Jun 2003 22:07:42 +0000 Subject: - Construct a cpu topology map for Hyper Threading systems so that ULE may take advantage of them. --- sys/amd64/amd64/mp_machdep.c | 31 +++++++++++++++++++++++++++++++ sys/amd64/amd64/mptable.c | 31 +++++++++++++++++++++++++++++++ sys/amd64/include/mptable.h | 31 +++++++++++++++++++++++++++++++ sys/i386/i386/mp_machdep.c | 31 +++++++++++++++++++++++++++++++ sys/i386/i386/mptable.c | 31 +++++++++++++++++++++++++++++++ sys/i386/include/mptable.h | 31 +++++++++++++++++++++++++++++++ 6 files changed, 186 insertions(+) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index a58d3b4..9701476 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -282,6 +282,13 @@ int cpu_num_to_apic_id[NAPICID]; int io_num_to_apic_id[NAPICID]; int apic_id_to_logical[NAPICID]; +/* + * CPU topology map datastructures for HTT. + */ +struct cpu_group mp_groups[NAPICID]; +struct cpu_top mp_top; +struct cpu_top *smp_topology; + /* AP uses this during bootstrap. Do not staticize. */ char *bootSTK; @@ -1069,6 +1076,7 @@ static void mptable_hyperthread_fixup(u_int id_mask) { u_int i, id; + int logical; /* Nothing to do if there is no HTT support. */ if ((cpu_feature & CPUID_HTT) == 0) @@ -1101,6 +1109,29 @@ mptable_hyperthread_fixup(u_int id_mask) need_hyperthreading_fixup = 1; mp_maxid *= logical_cpus; mp_naps *= logical_cpus; + + /* + * Now setup the cpu topology map. + */ + mp_top.ct_count = mp_naps / logical_cpus; + mp_top.ct_group = mp_groups; + + /* + * The first logical id is directly after the last valid physical id. + */ + logical = mp_top.ct_count + 1; + + for (i = 0; i < mp_top.ct_count; i++) { + int j; + + mp_groups[i].cg_mask = (1 << i); + for (j = 1; j < logical_cpus; j++) + mp_groups[i].cg_mask |= (1 << logical++); + mp_groups[i].cg_count = logical_cpus; + mp_groups[i].cg_children = 0; + } + + smp_topology = &mp_top; } void diff --git a/sys/amd64/amd64/mptable.c b/sys/amd64/amd64/mptable.c index a58d3b4..9701476 100644 --- a/sys/amd64/amd64/mptable.c +++ b/sys/amd64/amd64/mptable.c @@ -282,6 +282,13 @@ int cpu_num_to_apic_id[NAPICID]; int io_num_to_apic_id[NAPICID]; int apic_id_to_logical[NAPICID]; +/* + * CPU topology map datastructures for HTT. + */ +struct cpu_group mp_groups[NAPICID]; +struct cpu_top mp_top; +struct cpu_top *smp_topology; + /* AP uses this during bootstrap. Do not staticize. */ char *bootSTK; @@ -1069,6 +1076,7 @@ static void mptable_hyperthread_fixup(u_int id_mask) { u_int i, id; + int logical; /* Nothing to do if there is no HTT support. */ if ((cpu_feature & CPUID_HTT) == 0) @@ -1101,6 +1109,29 @@ mptable_hyperthread_fixup(u_int id_mask) need_hyperthreading_fixup = 1; mp_maxid *= logical_cpus; mp_naps *= logical_cpus; + + /* + * Now setup the cpu topology map. + */ + mp_top.ct_count = mp_naps / logical_cpus; + mp_top.ct_group = mp_groups; + + /* + * The first logical id is directly after the last valid physical id. + */ + logical = mp_top.ct_count + 1; + + for (i = 0; i < mp_top.ct_count; i++) { + int j; + + mp_groups[i].cg_mask = (1 << i); + for (j = 1; j < logical_cpus; j++) + mp_groups[i].cg_mask |= (1 << logical++); + mp_groups[i].cg_count = logical_cpus; + mp_groups[i].cg_children = 0; + } + + smp_topology = &mp_top; } void diff --git a/sys/amd64/include/mptable.h b/sys/amd64/include/mptable.h index a58d3b4..9701476 100644 --- a/sys/amd64/include/mptable.h +++ b/sys/amd64/include/mptable.h @@ -282,6 +282,13 @@ int cpu_num_to_apic_id[NAPICID]; int io_num_to_apic_id[NAPICID]; int apic_id_to_logical[NAPICID]; +/* + * CPU topology map datastructures for HTT. + */ +struct cpu_group mp_groups[NAPICID]; +struct cpu_top mp_top; +struct cpu_top *smp_topology; + /* AP uses this during bootstrap. Do not staticize. */ char *bootSTK; @@ -1069,6 +1076,7 @@ static void mptable_hyperthread_fixup(u_int id_mask) { u_int i, id; + int logical; /* Nothing to do if there is no HTT support. */ if ((cpu_feature & CPUID_HTT) == 0) @@ -1101,6 +1109,29 @@ mptable_hyperthread_fixup(u_int id_mask) need_hyperthreading_fixup = 1; mp_maxid *= logical_cpus; mp_naps *= logical_cpus; + + /* + * Now setup the cpu topology map. + */ + mp_top.ct_count = mp_naps / logical_cpus; + mp_top.ct_group = mp_groups; + + /* + * The first logical id is directly after the last valid physical id. + */ + logical = mp_top.ct_count + 1; + + for (i = 0; i < mp_top.ct_count; i++) { + int j; + + mp_groups[i].cg_mask = (1 << i); + for (j = 1; j < logical_cpus; j++) + mp_groups[i].cg_mask |= (1 << logical++); + mp_groups[i].cg_count = logical_cpus; + mp_groups[i].cg_children = 0; + } + + smp_topology = &mp_top; } void diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index a58d3b4..9701476 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -282,6 +282,13 @@ int cpu_num_to_apic_id[NAPICID]; int io_num_to_apic_id[NAPICID]; int apic_id_to_logical[NAPICID]; +/* + * CPU topology map datastructures for HTT. + */ +struct cpu_group mp_groups[NAPICID]; +struct cpu_top mp_top; +struct cpu_top *smp_topology; + /* AP uses this during bootstrap. Do not staticize. */ char *bootSTK; @@ -1069,6 +1076,7 @@ static void mptable_hyperthread_fixup(u_int id_mask) { u_int i, id; + int logical; /* Nothing to do if there is no HTT support. */ if ((cpu_feature & CPUID_HTT) == 0) @@ -1101,6 +1109,29 @@ mptable_hyperthread_fixup(u_int id_mask) need_hyperthreading_fixup = 1; mp_maxid *= logical_cpus; mp_naps *= logical_cpus; + + /* + * Now setup the cpu topology map. + */ + mp_top.ct_count = mp_naps / logical_cpus; + mp_top.ct_group = mp_groups; + + /* + * The first logical id is directly after the last valid physical id. + */ + logical = mp_top.ct_count + 1; + + for (i = 0; i < mp_top.ct_count; i++) { + int j; + + mp_groups[i].cg_mask = (1 << i); + for (j = 1; j < logical_cpus; j++) + mp_groups[i].cg_mask |= (1 << logical++); + mp_groups[i].cg_count = logical_cpus; + mp_groups[i].cg_children = 0; + } + + smp_topology = &mp_top; } void diff --git a/sys/i386/i386/mptable.c b/sys/i386/i386/mptable.c index a58d3b4..9701476 100644 --- a/sys/i386/i386/mptable.c +++ b/sys/i386/i386/mptable.c @@ -282,6 +282,13 @@ int cpu_num_to_apic_id[NAPICID]; int io_num_to_apic_id[NAPICID]; int apic_id_to_logical[NAPICID]; +/* + * CPU topology map datastructures for HTT. + */ +struct cpu_group mp_groups[NAPICID]; +struct cpu_top mp_top; +struct cpu_top *smp_topology; + /* AP uses this during bootstrap. Do not staticize. */ char *bootSTK; @@ -1069,6 +1076,7 @@ static void mptable_hyperthread_fixup(u_int id_mask) { u_int i, id; + int logical; /* Nothing to do if there is no HTT support. */ if ((cpu_feature & CPUID_HTT) == 0) @@ -1101,6 +1109,29 @@ mptable_hyperthread_fixup(u_int id_mask) need_hyperthreading_fixup = 1; mp_maxid *= logical_cpus; mp_naps *= logical_cpus; + + /* + * Now setup the cpu topology map. + */ + mp_top.ct_count = mp_naps / logical_cpus; + mp_top.ct_group = mp_groups; + + /* + * The first logical id is directly after the last valid physical id. + */ + logical = mp_top.ct_count + 1; + + for (i = 0; i < mp_top.ct_count; i++) { + int j; + + mp_groups[i].cg_mask = (1 << i); + for (j = 1; j < logical_cpus; j++) + mp_groups[i].cg_mask |= (1 << logical++); + mp_groups[i].cg_count = logical_cpus; + mp_groups[i].cg_children = 0; + } + + smp_topology = &mp_top; } void diff --git a/sys/i386/include/mptable.h b/sys/i386/include/mptable.h index a58d3b4..9701476 100644 --- a/sys/i386/include/mptable.h +++ b/sys/i386/include/mptable.h @@ -282,6 +282,13 @@ int cpu_num_to_apic_id[NAPICID]; int io_num_to_apic_id[NAPICID]; int apic_id_to_logical[NAPICID]; +/* + * CPU topology map datastructures for HTT. + */ +struct cpu_group mp_groups[NAPICID]; +struct cpu_top mp_top; +struct cpu_top *smp_topology; + /* AP uses this during bootstrap. Do not staticize. */ char *bootSTK; @@ -1069,6 +1076,7 @@ static void mptable_hyperthread_fixup(u_int id_mask) { u_int i, id; + int logical; /* Nothing to do if there is no HTT support. */ if ((cpu_feature & CPUID_HTT) == 0) @@ -1101,6 +1109,29 @@ mptable_hyperthread_fixup(u_int id_mask) need_hyperthreading_fixup = 1; mp_maxid *= logical_cpus; mp_naps *= logical_cpus; + + /* + * Now setup the cpu topology map. + */ + mp_top.ct_count = mp_naps / logical_cpus; + mp_top.ct_group = mp_groups; + + /* + * The first logical id is directly after the last valid physical id. + */ + logical = mp_top.ct_count + 1; + + for (i = 0; i < mp_top.ct_count; i++) { + int j; + + mp_groups[i].cg_mask = (1 << i); + for (j = 1; j < logical_cpus; j++) + mp_groups[i].cg_mask |= (1 << logical++); + mp_groups[i].cg_count = logical_cpus; + mp_groups[i].cg_children = 0; + } + + smp_topology = &mp_top; } void -- cgit v1.1