diff options
author | sobomax <sobomax@FreeBSD.org> | 2009-02-25 01:49:01 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2009-02-25 01:49:01 +0000 |
commit | ba8a8daf8d72a5148614af6990c0a54582c18103 (patch) | |
tree | df5515e8faa4d61f0c64103267b2f6e0bdd413f1 /sys | |
parent | 37601fa768d9120f38f8149f21915a560f4c1034 (diff) | |
download | FreeBSD-src-ba8a8daf8d72a5148614af6990c0a54582c18103.zip FreeBSD-src-ba8a8daf8d72a5148614af6990c0a54582c18103.tar.gz |
Make machdep.hyperthreading_enabled tunable working with the SCHED_ULE.
Unlike with SCHED_BSD, however, it can only be set to 0 at boot time,
it's not possible to change it at runtime.
Reviewed by: jhb
MFC after: 1 month
Diffstat (limited to 'sys')
-rw-r--r-- | sys/amd64/amd64/mp_machdep.c | 52 | ||||
-rw-r--r-- | sys/i386/i386/mp_machdep.c | 52 |
2 files changed, 86 insertions, 18 deletions
diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 51e906a..a07b146 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -151,6 +151,7 @@ struct cpu_info { int cpu_present:1; int cpu_bsp:1; int cpu_disabled:1; + int cpu_hyperthread:1; } static cpu_info[MAX_APIC_ID + 1]; int cpu_apic_ids[MAXCPU]; int apic_cpuids[MAX_APIC_ID + 1]; @@ -353,11 +354,6 @@ cpu_mp_start(void) cpu_apic_ids[0] = boot_cpu_id; apic_cpuids[boot_cpu_id] = 0; - assign_cpu_ids(); - - /* Start each Application Processor */ - start_all_aps(); - /* Setup the initial logical CPUs info. */ logical_cpus = logical_cpus_mask = 0; if (cpu_feature & CPUID_HTT) @@ -404,6 +400,11 @@ cpu_mp_start(void) hyperthreading_cpus = logical_cpus; } + assign_cpu_ids(); + + /* Start each Application Processor */ + start_all_aps(); + set_interrupt_apic_ids(); } @@ -415,18 +416,26 @@ void cpu_mp_announce(void) { int i, x; + const char *hyperthread; /* List CPUs */ printf(" cpu0 (BSP): APIC ID: %2d\n", boot_cpu_id); for (i = 1, x = 0; x <= MAX_APIC_ID; x++) { if (!cpu_info[x].cpu_present || cpu_info[x].cpu_bsp) continue; + if (cpu_info[x].cpu_hyperthread) { + hyperthread = "/HT"; + } else { + hyperthread = ""; + } if (cpu_info[x].cpu_disabled) - printf(" cpu (AP): APIC ID: %2d (disabled)\n", x); + printf(" cpu (AP%s): APIC ID: %2d (disabled)\n", + hyperthread, x); else { KASSERT(i < mp_ncpus, ("mp_ncpus and actual cpus are out of whack")); - printf(" cpu%d (AP): APIC ID: %2d\n", i++, x); + printf(" cpu%d (AP%s): APIC ID: %2d\n", i++, + hyperthread, x); } } } @@ -642,11 +651,28 @@ assign_cpu_ids(void) { u_int i; + TUNABLE_INT_FETCH("machdep.hyperthreading_allowed", + &hyperthreading_allowed); + /* Check for explicitly disabled CPUs. */ for (i = 0; i <= MAX_APIC_ID; i++) { if (!cpu_info[i].cpu_present || cpu_info[i].cpu_bsp) continue; + if (hyperthreading_cpus > 1 && i % hyperthreading_cpus != 0) { + cpu_info[i].cpu_hyperthread = 1; +#if defined(SCHED_ULE) + /* + * Don't use HT CPU if it has been disabled by a + * tunable. + */ + if (hyperthreading_allowed == 0) { + cpu_info[i].cpu_disabled = 1; + continue; + } +#endif + } + /* Don't use this CPU if it has been disabled by a tunable. */ if (resource_disabled("lapic", i)) { cpu_info[i].cpu_disabled = 1; @@ -1198,6 +1224,16 @@ sysctl_hyperthreading_allowed(SYSCTL_HANDLER_ARGS) if (error || !req->newptr) return (error); +#ifdef SCHED_ULE + /* + * SCHED_ULE doesn't allow enabling/disabling HT cores at + * tun time. + */ + if (allowed != hyperthreading_allowed) + return (ENOTSUP); + return (error); +#endif + if (allowed) hlt_cpus_mask &= ~hyperthreading_cpus_mask; else @@ -1242,8 +1278,6 @@ cpu_hlt_setup(void *dummy __unused) * of hlt_logical_cpus. */ if (hyperthreading_cpus_mask) { - TUNABLE_INT_FETCH("machdep.hyperthreading_allowed", - &hyperthreading_allowed); SYSCTL_ADD_PROC(&logical_cpu_clist, SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, "hyperthreading_allowed", CTLTYPE_INT|CTLFLAG_RW, diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index d871017..d9c41d3 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -204,6 +204,7 @@ struct cpu_info { int cpu_present:1; int cpu_bsp:1; int cpu_disabled:1; + int cpu_hyperthread:1; } static cpu_info[MAX_APIC_ID + 1]; int cpu_apic_ids[MAXCPU]; int apic_cpuids[MAX_APIC_ID + 1]; @@ -400,11 +401,6 @@ cpu_mp_start(void) cpu_apic_ids[0] = boot_cpu_id; apic_cpuids[boot_cpu_id] = 0; - assign_cpu_ids(); - - /* Start each Application Processor */ - start_all_aps(); - /* Setup the initial logical CPUs info. */ logical_cpus = logical_cpus_mask = 0; if (cpu_feature & CPUID_HTT) @@ -451,6 +447,11 @@ cpu_mp_start(void) hyperthreading_cpus = logical_cpus; } + assign_cpu_ids(); + + /* Start each Application Processor */ + start_all_aps(); + set_interrupt_apic_ids(); } @@ -462,18 +463,26 @@ void cpu_mp_announce(void) { int i, x; + const char *hyperthread; /* List CPUs */ printf(" cpu0 (BSP): APIC ID: %2d\n", boot_cpu_id); for (i = 1, x = 0; x <= MAX_APIC_ID; x++) { if (!cpu_info[x].cpu_present || cpu_info[x].cpu_bsp) continue; + if (cpu_info[x].cpu_hyperthread) { + hyperthread = "/HT"; + } else { + hyperthread = ""; + } if (cpu_info[x].cpu_disabled) - printf(" cpu (AP): APIC ID: %2d (disabled)\n", x); + printf(" cpu (AP%s): APIC ID: %2d (disabled)\n", + hyperthread, x); else { KASSERT(i < mp_ncpus, ("mp_ncpus and actual cpus are out of whack")); - printf(" cpu%d (AP): APIC ID: %2d\n", i++, x); + printf(" cpu%d (AP%s): APIC ID: %2d\n", i++, + hyperthread, x); } } } @@ -682,11 +691,28 @@ assign_cpu_ids(void) { u_int i; + TUNABLE_INT_FETCH("machdep.hyperthreading_allowed", + &hyperthreading_allowed); + /* Check for explicitly disabled CPUs. */ for (i = 0; i <= MAX_APIC_ID; i++) { if (!cpu_info[i].cpu_present || cpu_info[i].cpu_bsp) continue; + if (hyperthreading_cpus > 1 && i % hyperthreading_cpus != 0) { + cpu_info[i].cpu_hyperthread = 1; +#if defined(SCHED_ULE) + /* + * Don't use HT CPU if it has been disabled by a + * tunable. + */ + if (hyperthreading_allowed == 0) { + cpu_info[i].cpu_disabled = 1; + continue; + } +#endif + } + /* Don't use this CPU if it has been disabled by a tunable. */ if (resource_disabled("lapic", i)) { cpu_info[i].cpu_disabled = 1; @@ -1369,6 +1395,16 @@ sysctl_hyperthreading_allowed(SYSCTL_HANDLER_ARGS) if (error || !req->newptr) return (error); +#ifdef SCHED_ULE + /* + * SCHED_ULE doesn't allow enabling/disabling HT cores at + * tun time. + */ + if (allowed != hyperthreading_allowed) + return (ENOTSUP); + return (error); +#endif + if (allowed) hlt_cpus_mask &= ~hyperthreading_cpus_mask; else @@ -1413,8 +1449,6 @@ cpu_hlt_setup(void *dummy __unused) * of hlt_logical_cpus. */ if (hyperthreading_cpus_mask) { - TUNABLE_INT_FETCH("machdep.hyperthreading_allowed", - &hyperthreading_allowed); SYSCTL_ADD_PROC(&logical_cpu_clist, SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, "hyperthreading_allowed", CTLTYPE_INT|CTLFLAG_RW, |