Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Nov 2009 19:16:34 +0000 (UTC)
From:      Doug Ambrisko <ambrisko@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org
Subject:   svn commit: r198998 - in stable/6/sys: amd64/amd64 i386/i386
Message-ID:  <200911061916.nA6JGYrm026353@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ambrisko
Date: Fri Nov  6 19:16:33 2009
New Revision: 198998
URL: http://svn.freebsd.org/changeset/base/198998

Log:
  Fix botched merge.  This was in an old repo. that I thought was current.
  Check in the real working code.
  
  Pointy hat to:	ambrisko

Modified:
  stable/6/sys/amd64/amd64/mp_machdep.c
  stable/6/sys/i386/i386/mp_machdep.c

Modified: stable/6/sys/amd64/amd64/mp_machdep.c
==============================================================================
--- stable/6/sys/amd64/amd64/mp_machdep.c	Fri Nov  6 18:51:05 2009	(r198997)
+++ stable/6/sys/amd64/amd64/mp_machdep.c	Fri Nov  6 19:16:33 2009	(r198998)
@@ -133,6 +133,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];
 static int cpu_apic_ids[MAXCPU];
 
@@ -342,11 +343,6 @@ cpu_mp_start(void)
 		KASSERT(boot_cpu_id == PCPU_GET(apic_id),
 		    ("BSP's APIC ID doesn't match boot_cpu_id"));
 
-	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)
@@ -394,6 +390,12 @@ cpu_mp_start(void)
 			hyperthreading_cpus = logical_cpus;
 	}
 
+	assign_cpu_ids();
+
+	/* Start each Application Processor */
+	start_all_aps();
+
+
 	set_interrupt_apic_ids();
 }
 
@@ -404,9 +406,10 @@ cpu_mp_start(void)
 void
 cpu_mp_announce(void)
 {
+	const char *hyperthread;
 	int i;
 
-	/* List active CPUs first. */
+	/* List Active CPUs first. */
 	printf(" cpu0 (BSP): APIC ID: %2d\n", boot_cpu_id);
 	for (i = 1; i < mp_ncpus; i++) {
 		if (cpu_info[cpu_apic_ids[i]].cpu_hyperthread)
@@ -414,7 +417,7 @@ cpu_mp_announce(void)
 		else
 			hyperthread = "";
 		printf(" cpu%d (AP%s): APIC ID: %2d\n", i, hyperthread,
-		    cpu_apic_ids[i]);
+			cpu_apic_ids[i]);
 	}
 
 	/* List disabled CPUs last. */
@@ -426,7 +429,7 @@ cpu_mp_announce(void)
 		else
 			hyperthread = "";
 		printf("  cpu (AP%s): APIC ID: %2d (disabled)\n", hyperthread,
-		    i);
+			i);
 	}
 }
 
@@ -645,6 +648,9 @@ assign_cpu_ids(void)
 		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;
+
 		/* Don't use this CPU if it has been disabled by a tunable. */
 		if (resource_disabled("lapic", i)) {
 			cpu_info[i].cpu_disabled = 1;
@@ -655,18 +661,17 @@ assign_cpu_ids(void)
 	/*
 	 * Assign CPU IDs to local APIC IDs and disable any CPUs
 	 * beyond MAXCPU.  CPU 0 is always assigned to the BSP.
-	 *
+	 * 
 	 * To minimize confusion for userland, we attempt to number
-	 * CPUs such that all threads and cores in a package are
-	 * grouped together.  For now we assume that the BSP is always
+	 * CPUs such that all the threads and cores in a package are
+	 * grouped together. For now we assume that the BSP is always
 	 * the first thread in a package and just start adding APs
 	 * starting with the BSP's APIC ID.
 	 */
 	mp_ncpus = 1;
 	cpu_apic_ids[0] = boot_cpu_id;
-	apic_cpuids[boot_cpu_id] = 0;
-	for (i = boot_cpu_id + 1; i != boot_cpu_id;
-	     i == MAX_APIC_ID ? i = 0 : i++) {
+	for (i = boot_cpu_id + 1; i != boot_cpu_id; 
+		 i == MAX_APIC_ID ? i = 0 : i++) {
 		if (!cpu_info[i].cpu_present || cpu_info[i].cpu_bsp ||
 		    cpu_info[i].cpu_disabled)
 			continue;

Modified: stable/6/sys/i386/i386/mp_machdep.c
==============================================================================
--- stable/6/sys/i386/i386/mp_machdep.c	Fri Nov  6 18:51:05 2009	(r198997)
+++ stable/6/sys/i386/i386/mp_machdep.c	Fri Nov  6 19:16:33 2009	(r198998)
@@ -217,6 +217,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];
 static int cpu_apic_ids[MAXCPU];
 
@@ -418,11 +419,6 @@ cpu_mp_start(void)
 		KASSERT(boot_cpu_id == PCPU_GET(apic_id),
 		    ("BSP's APIC ID doesn't match boot_cpu_id"));
 
-	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)
@@ -470,6 +466,11 @@ cpu_mp_start(void)
 			hyperthreading_cpus = logical_cpus;
 	}
 
+	assign_cpu_ids();
+
+	/* Start each Application Processor */
+	start_all_aps();
+
 	set_interrupt_apic_ids();
 }
 
@@ -480,11 +481,12 @@ cpu_mp_start(void)
 void
 cpu_mp_announce(void)
 {
+	const char *hyperthread;
 	int i;
 
 	POSTCODE(MP_ANNOUNCE_POST);
 
-	/* List active CPUs first. */
+	/* List Active CPUs first. */
 	printf(" cpu0 (BSP): APIC ID: %2d\n", boot_cpu_id);
 	for (i = 1; i < mp_ncpus; i++) {
 		if (cpu_info[cpu_apic_ids[i]].cpu_hyperthread)
@@ -492,11 +494,11 @@ cpu_mp_announce(void)
 		else
 			hyperthread = "";
 		printf(" cpu%d (AP%s): APIC ID: %2d\n", i, hyperthread,
-		    cpu_apic_ids[i]);
+				cpu_apic_ids[i]);
 	}
 
 	/* List disabled CPUs last. */
-	for (i = 0; i <= MAX_APIC_ID; i++) {
+	for (i=0 ; i<= MAX_APIC_ID; i++ ) {
 		if (!cpu_info[i].cpu_present || !cpu_info[i].cpu_disabled)
 			continue;
 		if (cpu_info[i].cpu_hyperthread)
@@ -504,7 +506,7 @@ cpu_mp_announce(void)
 		else
 			hyperthread = "";
 		printf("  cpu (AP%s): APIC ID: %2d (disabled)\n", hyperthread,
-		    i);
+			i);
 	}
 }
 
@@ -723,6 +725,9 @@ assign_cpu_ids(void)
 		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;
+
 		/* Don't use this CPU if it has been disabled by a tunable. */
 		if (resource_disabled("lapic", i)) {
 			cpu_info[i].cpu_disabled = 1;
@@ -735,16 +740,15 @@ assign_cpu_ids(void)
 	 * beyond MAXCPU.  CPU 0 is always assigned to the BSP.
 	 *
 	 * To minimize confusion for userland, we attempt to number
-	 * CPUs such that all threads and cores in a package are
-	 * grouped together.  For now we assume that the BSP is always
+	 * CPUs such that all the threads and cores in a package are
+	 * grouped together. For now we assume that the BSP is always
 	 * the first thread in a package and just start adding APs
 	 * starting with the BSP's APIC ID.
 	 */
 	mp_ncpus = 1;
 	cpu_apic_ids[0] = boot_cpu_id;
-	apic_cpuids[boot_cpu_id] = 0;
 	for (i = boot_cpu_id + 1; i != boot_cpu_id;
-	     i == MAX_APIC_ID ? i = 0 : i++) {
+		 i == MAX_APIC_ID ? i = 0 : i++) {
 		if (!cpu_info[i].cpu_present || cpu_info[i].cpu_bsp ||
 		    cpu_info[i].cpu_disabled)
 			continue;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911061916.nA6JGYrm026353>