i386/85655: [patch] expose cpu info for i386 systems
Ben Thomas
bthomas at virtualiron.com
Fri Sep 2 18:00:41 GMT 2005
>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 at 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:
More information about the freebsd-i386
mailing list