Date: Fri, 02 Sep 2005 13:59:26 -0400 From: Ben Thomas <bthomas@virtualiron.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: i386/85655: [patch] expose cpu info for i386 systems Message-ID: <431892FE.5030302@virtualiron.com> Resent-Message-ID: <200509021800.j82I0b2s055263@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 85655 >Category: i386 >Synopsis: [patch] expose cpu info for i386 systems >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-i386 >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Sep 02 18:00:36 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Ben Thomas >Release: FreeBSD 5.4-RELEASE i386 >Organization: Virtual Iron Software >Environment: System: FreeBSD bthomas4.katana-technology.com 5.4-RELEASE FreeBSD 5.4-RELEASE #10: Sun Aug 28 13:48:00 EDT 2005 ben@bthomas4.katana-technology.com:/usr/obj/usr/home/ben/BSD/RELENG_5_4_0_RELEASE/src/sys/BEN i386 >Description: This change makes some slight modifications: - add "packed" attribute to the cpu_info structure to make it a bit smaller - add the hyperthread index to the structure - expose the entire structure via a machdep sysctl (I probably should have also added an .h file for the user/kernel to agree on the structure format) This patch is against the 5_4_0_RELEASE code >How-To-Repeat: >Fix: --- mp_machdep.c-DIFF begins here --- --- /usr/src.original/sys/i386/i386/mp_machdep.c Sun May 1 01:38:13 2005 +++ /usr/src/sys/i386/i386/mp_machdep.c Fri Aug 12 17:29:11 2005 @@ -202,9 +202,12 @@ int cpu_present:1; int cpu_bsp:1; int cpu_disabled:1; -} static cpu_info[MAXCPU]; + unsigned char cpu_htt; +} __attribute__((packed)) static cpu_info[MAXCPU]; static int cpu_apic_ids[MAXCPU]; +SYSCTL_OPAQUE(_machdep, OID_AUTO, cpu_info, CTLFLAG_RD, &cpu_info, sizeof(cpu_info), "S,cpu_info", "CPU Information"); + /* Holds pending bitmap based IPIs per CPU */ static volatile u_int cpu_ipi_pending[MAXCPU]; @@ -284,7 +287,8 @@ void cpu_add(u_int apic_id, char boot_cpu) { - + int cores; + if (apic_id >= MAXCPU) { printf("SMP: CPU %d exceeds maximum CPU %d, ignoring\n", apic_id, MAXCPU - 1); @@ -304,7 +308,12 @@ if (bootverbose) printf("SMP: Added CPU %d (%s)\n", apic_id, boot_cpu ? "BSP" : "AP"); - + if ((cpu_feature & CPUID_HTT) == 0) + cores = 1; + else + cores = (cpu_procinfo & CPUID_HTT_CORES) >> 16; + + cpu_info[apic_id].cpu_htt = apic_id % cores; } void --- mp_machdep.c-DIFF ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?431892FE.5030302>