From owner-svn-src-all@FreeBSD.ORG Sat Feb 12 02:08:24 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D18E51065697; Sat, 12 Feb 2011 02:08:24 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BF7D38FC1B; Sat, 12 Feb 2011 02:08:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p1C28O4W081425; Sat, 12 Feb 2011 02:08:24 GMT (envelope-from jmallett@svn.freebsd.org) Received: (from jmallett@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p1C28OfB081419; Sat, 12 Feb 2011 02:08:24 GMT (envelope-from jmallett@svn.freebsd.org) Message-Id: <201102120208.p1C28OfB081419@svn.freebsd.org> From: Juli Mallett Date: Sat, 12 Feb 2011 02:08:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218591 - in head/sys/mips: cavium include mips rmi sibyte X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Feb 2011 02:08:24 -0000 Author: jmallett Date: Sat Feb 12 02:08:24 2011 New Revision: 218591 URL: http://svn.freebsd.org/changeset/base/218591 Log: Allow the platform code to return a bitmask of running cores rather than just a number of cores, this allows for a sparse set of CPUs. Implement support for sparse core masks on Octeon. XXX jeff@ suggests that all_cpus should include cores that are offline or running other applications/OSes, so the platform API should be further extended to allow us to set all_cpus to include all cores that are physically-present as opposed to only those that are running FreeBSD. Submitted by: Bhanu Prakash (with modifications) Reviewed by: jchandra Glanced at by: kib, jeff, jhb Modified: head/sys/mips/cavium/octeon_mp.c head/sys/mips/include/hwfunc.h head/sys/mips/mips/mp_machdep.c head/sys/mips/rmi/xlr_machdep.c head/sys/mips/sibyte/sb_scd.c Modified: head/sys/mips/cavium/octeon_mp.c ============================================================================== --- head/sys/mips/cavium/octeon_mp.c Sat Feb 12 01:03:15 2011 (r218590) +++ head/sys/mips/cavium/octeon_mp.c Sat Feb 12 02:08:24 2011 (r218591) @@ -102,10 +102,10 @@ platform_init_ap(int cpuid) mips_wbflush(); } -int -platform_num_processors(void) +cpumask_t +platform_cpu_mask(void) { - return (bitcount32(octeon_bootinfo->core_mask)); + return (octeon_bootinfo->core_mask); } struct cpu_group * Modified: head/sys/mips/include/hwfunc.h ============================================================================== --- head/sys/mips/include/hwfunc.h Sat Feb 12 01:03:15 2011 (r218590) +++ head/sys/mips/include/hwfunc.h Sat Feb 12 02:08:24 2011 (r218591) @@ -89,9 +89,9 @@ void platform_ipi_clear(void); extern int platform_processor_id(void); /* - * Return the number of processors available on this platform. + * Return the cpumask of available processors. */ -extern int platform_num_processors(void); +extern cpumask_t platform_cpu_mask(void); /* * Return the topology of processors on this platform Modified: head/sys/mips/mips/mp_machdep.c ============================================================================== --- head/sys/mips/mips/mp_machdep.c Sat Feb 12 01:03:15 2011 (r218590) +++ head/sys/mips/mips/mp_machdep.c Sat Feb 12 02:08:24 2011 (r218591) @@ -200,12 +200,14 @@ start_ap(int cpuid) void cpu_mp_setmaxid(void) { + cpumask_t cpumask; - mp_ncpus = platform_num_processors(); + cpumask = platform_cpu_mask(); + mp_ncpus = bitcount32(cpumask); if (mp_ncpus <= 0) mp_ncpus = 1; - mp_maxid = min(mp_ncpus, MAXCPU) - 1; + mp_maxid = min(fls(cpumask), MAXCPU) - 1; } void @@ -231,24 +233,30 @@ void cpu_mp_start(void) { int error, cpuid; + cpumask_t cpumask; mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); - all_cpus = 1; /* BSP */ - for (cpuid = 1; cpuid < platform_num_processors(); ++cpuid) { + all_cpus = 0; + cpumask = platform_cpu_mask(); + + while (cpumask != 0) { + cpuid = ffs(cpumask) - 1; + cpumask &= ~(1 << cpuid); + if (cpuid >= MAXCPU) { printf("cpu_mp_start: ignoring AP #%d.\n", cpuid); continue; } - if ((error = start_ap(cpuid)) != 0) { - printf("AP #%d failed to start: %d\n", cpuid, error); - continue; + if (cpuid != platform_processor_id()) { + if ((error = start_ap(cpuid)) != 0) { + printf("AP #%d failed to start: %d\n", cpuid, error); + continue; + } + if (bootverbose) + printf("AP #%d started!\n", cpuid); } - - if (bootverbose) - printf("AP #%d started!\n", cpuid); - all_cpus |= 1 << cpuid; } Modified: head/sys/mips/rmi/xlr_machdep.c ============================================================================== --- head/sys/mips/rmi/xlr_machdep.c Sat Feb 12 01:03:15 2011 (r218590) +++ head/sys/mips/rmi/xlr_machdep.c Sat Feb 12 02:08:24 2011 (r218591) @@ -614,11 +614,11 @@ platform_processor_id(void) return (xlr_hwtid_to_cpuid[xlr_cpu_id()]); } -int -platform_num_processors(void) +cpumask_t +platform_cpu_mask(void) { - return (xlr_ncores * xlr_threads_per_core); + return (~0U >> (32 - (xlr_ncores * xlr_threads_per_core))); } struct cpu_group * Modified: head/sys/mips/sibyte/sb_scd.c ============================================================================== --- head/sys/mips/sibyte/sb_scd.c Sat Feb 12 01:03:15 2011 (r218590) +++ head/sys/mips/sibyte/sb_scd.c Sat Feb 12 02:08:24 2011 (r218591) @@ -242,11 +242,11 @@ sb_clear_mailbox(int cpu, uint64_t val) sb_store64(regaddr, val); } -int -platform_num_processors(void) +cpumask_t +platform_cpu_mask(void) { - return (SYSREV_NUM_PROCESSORS(sb_read_sysrev())); + return (~0U >> (32 - SYSREV_NUM_PROCESSORS(sb_read_sysrev()))); } #endif /* SMP */