svn commit: r222356 - projects/pseries/kern

Nathan Whitehorn nwhitehorn at FreeBSD.org
Fri May 27 14:27:29 UTC 2011


Author: nwhitehorn
Date: Fri May 27 14:27:28 2011
New Revision: 222356
URL: http://svn.freebsd.org/changeset/base/222356

Log:
  On multi-core, multi-threaded PPC systems, it is important that the threads
  be brought up in the order they are enumerated in the device tree (in
  particular, that thread 0 on each core be brought up first). The SLIST
  through which we loop to start the CPUs has all of its entries added with
  SLIST_INSERT_HEAD(), which means it is in reverse order of enumeration
  and so AP startup would always fail in such situation (causing a machine
  check or RTAS failure).
  
  The best fix is probably to change this from a LIST to a TAILQ, but fix
  this by looping through to add new cpus to the end of the list.

Modified:
  projects/pseries/kern/subr_pcpu.c

Modified: projects/pseries/kern/subr_pcpu.c
==============================================================================
--- projects/pseries/kern/subr_pcpu.c	Fri May 27 14:08:24 2011	(r222355)
+++ projects/pseries/kern/subr_pcpu.c	Fri May 27 14:27:28 2011	(r222356)
@@ -82,6 +82,7 @@ struct cpuhead cpuhead = SLIST_HEAD_INIT
 void
 pcpu_init(struct pcpu *pcpu, int cpuid, size_t size)
 {
+	struct pcpu *tail;
 
 	bzero(pcpu, size);
 	KASSERT(cpuid >= 0 && cpuid < MAXCPU,
@@ -89,7 +90,17 @@ pcpu_init(struct pcpu *pcpu, int cpuid, 
 	pcpu->pc_cpuid = cpuid;
 	pcpu->pc_cpumask = 1 << cpuid;
 	cpuid_to_pcpu[cpuid] = pcpu;
-	SLIST_INSERT_HEAD(&cpuhead, pcpu, pc_allcpu);
+	/*
+	 * It may be important that the CPU list stay ordered, so try to
+	 * install this PCPU at the end of the list instead of the beginnig.
+	 */
+	for (tail = SLIST_FIRST(&cpuhead); tail != NULL &&
+	    SLIST_NEXT(tail, pc_allcpu) != NULL;
+	    tail = SLIST_NEXT(tail, pc_allcpu)) {}
+	if (tail != NULL)
+		SLIST_INSERT_AFTER(tail, pcpu, pc_allcpu);
+	else
+		SLIST_INSERT_HEAD(&cpuhead, pcpu, pc_allcpu);
 	cpu_pcpu_init(pcpu, cpuid, size);
 	pcpu->pc_rm_queue.rmq_next = &pcpu->pc_rm_queue;
 	pcpu->pc_rm_queue.rmq_prev = &pcpu->pc_rm_queue;


More information about the svn-src-projects mailing list