From owner-svn-src-projects@FreeBSD.ORG Fri May 27 14:27:29 2011 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 22570106564A; Fri, 27 May 2011 14:27:29 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1223F8FC0A; Fri, 27 May 2011 14:27:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p4RERSvl039283; Fri, 27 May 2011 14:27:28 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4RERSUb039281; Fri, 27 May 2011 14:27:28 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201105271427.p4RERSUb039281@svn.freebsd.org> From: Nathan Whitehorn Date: Fri, 27 May 2011 14:27:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222356 - projects/pseries/kern X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2011 14:27:29 -0000 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;