Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 May 2011 15:02:42 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r222258 - in projects/pseries/powerpc: include pseries
Message-ID:  <201105241502.p4OF2gU7073251@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Tue May 24 15:02:42 2011
New Revision: 222258
URL: http://svn.freebsd.org/changeset/base/222258

Log:
  Provide SMP topology detection and bump MAXCPU to match other platforms.

Modified:
  projects/pseries/powerpc/include/param.h
  projects/pseries/powerpc/pseries/platform_chrp.c

Modified: projects/pseries/powerpc/include/param.h
==============================================================================
--- projects/pseries/powerpc/include/param.h	Tue May 24 14:36:32 2011	(r222257)
+++ projects/pseries/powerpc/include/param.h	Tue May 24 15:02:42 2011	(r222258)
@@ -68,7 +68,7 @@
 #endif
 
 #if defined(SMP) || defined(KLD_MODULE)
-#define	MAXCPU		4	
+#define	MAXCPU		32	
 #else
 #define	MAXCPU		1
 #endif /* SMP || KLD_MODULE */

Modified: projects/pseries/powerpc/pseries/platform_chrp.c
==============================================================================
--- projects/pseries/powerpc/pseries/platform_chrp.c	Tue May 24 14:36:32 2011	(r222257)
+++ projects/pseries/powerpc/pseries/platform_chrp.c	Tue May 24 15:02:42 2011	(r222258)
@@ -69,6 +69,9 @@ static int chrp_smp_first_cpu(platform_t
 static int chrp_smp_next_cpu(platform_t, struct cpuref *cpuref);
 static int chrp_smp_get_bsp(platform_t, struct cpuref *cpuref);
 static int chrp_smp_start_cpu(platform_t, struct pcpu *cpu);
+#ifdef SMP
+static struct cpu_group *chrp_smp_topo(platform_t plat);
+#endif
 static void chrp_reset(platform_t);
 
 static platform_method_t chrp_methods[] = {
@@ -82,6 +85,9 @@ static platform_method_t chrp_methods[] 
 	PLATFORMMETHOD(platform_smp_next_cpu,	chrp_smp_next_cpu),
 	PLATFORMMETHOD(platform_smp_get_bsp,	chrp_smp_get_bsp),
 	PLATFORMMETHOD(platform_smp_start_cpu,	chrp_smp_start_cpu),
+#ifdef SMP
+	PLATFORMMETHOD(platform_smp_topo,	chrp_smp_topo),
+#endif
 
 	PLATFORMMETHOD(platform_reset,		chrp_reset),
 
@@ -312,6 +318,39 @@ chrp_smp_start_cpu(platform_t plat, stru
 	return ((pc->pc_awake) ? 0 : EBUSY);
 }
 
+#ifdef SMP
+static struct cpu_group *
+chrp_smp_topo(platform_t plat)
+{
+	struct pcpu *pc, *last_pc;
+	int i, ncores, ncpus;
+
+	ncores = ncpus = 0;
+	last_pc = NULL;
+	for (i = 0; i <= mp_maxid; i++) {
+		pc = pcpu_find(i);
+		if (pc == NULL)
+			continue;
+		if (last_pc == NULL || pc->pc_hwref != last_pc->pc_hwref)
+			ncores++;
+		last_pc = pc;
+		ncpus++;
+	}
+
+	if (ncpus % ncores != 0) {
+		printf("WARNING: Irregular SMP topology. Performance may be "
+		     "suboptimal (%d CPUS, %d cores)\n", ncpus, ncores);
+		return (smp_topo_none());
+	}
+
+	/* Don't do anything fancier for non-threaded SMP */
+	if (ncpus == ncores)
+		return (smp_topo_none());
+
+	return (smp_topo_1level(CG_SHARE_L1, ncpus / ncores, CG_FLAG_SMT));
+}
+#endif
+
 static void
 chrp_reset(platform_t platform)
 {



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