svn commit: r211149 - in head/sys: amd64/amd64 i386/i386

Attilio Rao attilio at FreeBSD.org
Tue Aug 10 16:14:11 UTC 2010


Author: attilio
Date: Tue Aug 10 16:14:10 2010
New Revision: 211149
URL: http://svn.freebsd.org/changeset/base/211149

Log:
  Fix some places that may use cpumask_t while they still use 'int' types.
  While there, also fix some places assuming cpu type is 'int' while
  u_int is really meant.
  
  Note: this will also fix some possible races in per-cpu data accessings
  to be addressed in further commits.
  
  In collabouration with:	Yahoo! Incorporated (via sbruno and peter)
  Tested by:	gianni
  MFC after:	1 month

Modified:
  head/sys/amd64/amd64/mp_machdep.c
  head/sys/amd64/amd64/pmap.c
  head/sys/i386/i386/mp_machdep.c
  head/sys/i386/i386/pmap.c

Modified: head/sys/amd64/amd64/mp_machdep.c
==============================================================================
--- head/sys/amd64/amd64/mp_machdep.c	Tue Aug 10 15:22:48 2010	(r211148)
+++ head/sys/amd64/amd64/mp_machdep.c	Tue Aug 10 16:14:10 2010	(r211149)
@@ -127,7 +127,7 @@ extern inthand_t IDTVEC(fast_syscall), I
  * Local data and functions.
  */
 
-static u_int logical_cpus;
+static cpumask_t logical_cpus;
 static volatile cpumask_t ipi_nmi_pending;
 
 /* used to hold the AP's until we are ready to release them */
@@ -162,8 +162,8 @@ static int	start_all_aps(void);
 static int	start_ap(int apic_id);
 static void	release_aps(void *dummy);
 
-static int	hlt_logical_cpus;
-static u_int	hyperthreading_cpus;
+static cpumask_t	hlt_logical_cpus;
+static cpumask_t	hyperthreading_cpus;
 static cpumask_t	hyperthreading_cpus_mask;
 static int	hyperthreading_allowed = 1;
 static struct	sysctl_ctx_list logical_cpu_clist;
@@ -1321,8 +1321,11 @@ ipi_nmi_handler()
 void
 cpustop_handler(void)
 {
-	int cpu = PCPU_GET(cpuid);
-	int cpumask = PCPU_GET(cpumask);
+	cpumask_t cpumask;
+	u_int cpu;
+
+	cpu = PCPU_GET(cpuid);
+	cpumask = PCPU_GET(cpumask);
 
 	savectx(&stoppcbs[cpu]);
 
@@ -1349,9 +1352,12 @@ cpustop_handler(void)
 void
 cpususpend_handler(void)
 {
+	cpumask_t cpumask;
 	register_t cr3, rf;
-	int cpu = PCPU_GET(cpuid);
-	int cpumask = PCPU_GET(cpumask);
+	u_int cpu;
+
+	cpu = PCPU_GET(cpuid);
+	cpumask = PCPU_GET(cpumask);
 
 	rf = intr_disable();
 	cr3 = rcr3();
@@ -1523,13 +1529,15 @@ SYSINIT(cpu_hlt, SI_SUB_SMP, SI_ORDER_AN
 int
 mp_grab_cpu_hlt(void)
 {
-	u_int mask = PCPU_GET(cpumask);
+	cpuset_t mask;
 #ifdef MP_WATCHDOG
-	u_int cpuid = PCPU_GET(cpuid);
+	u_int cpuid;
 #endif
 	int retval;
 
+	mask = PCPU_GET(cpumask);
 #ifdef MP_WATCHDOG
+	cpuid = PCPU_GET(cpuid);
 	ap_watchdog(cpuid);
 #endif
 

Modified: head/sys/amd64/amd64/pmap.c
==============================================================================
--- head/sys/amd64/amd64/pmap.c	Tue Aug 10 15:22:48 2010	(r211148)
+++ head/sys/amd64/amd64/pmap.c	Tue Aug 10 16:14:10 2010	(r211149)
@@ -926,8 +926,7 @@ pmap_update_pde_invalidate(vm_offset_t v
 void
 pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
 {
-	u_int cpumask;
-	u_int other_cpus;
+	cpumask_t cpumask, other_cpus;
 
 	sched_pin();
 	if (pmap == kernel_pmap || pmap->pm_active == all_cpus) {
@@ -947,8 +946,7 @@ pmap_invalidate_page(pmap_t pmap, vm_off
 void
 pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
 {
-	u_int cpumask;
-	u_int other_cpus;
+	cpumask_t cpumask, other_cpus;
 	vm_offset_t addr;
 
 	sched_pin();
@@ -972,8 +970,7 @@ pmap_invalidate_range(pmap_t pmap, vm_of
 void
 pmap_invalidate_all(pmap_t pmap)
 {
-	u_int cpumask;
-	u_int other_cpus;
+	cpumask_t cpumask, other_cpus;
 
 	sched_pin();
 	if (pmap == kernel_pmap || pmap->pm_active == all_cpus) {

Modified: head/sys/i386/i386/mp_machdep.c
==============================================================================
--- head/sys/i386/i386/mp_machdep.c	Tue Aug 10 15:22:48 2010	(r211148)
+++ head/sys/i386/i386/mp_machdep.c	Tue Aug 10 16:14:10 2010	(r211149)
@@ -174,7 +174,7 @@ static u_long *ipi_statclock_counts[MAXC
  * Local data and functions.
  */
 
-static u_int logical_cpus;
+static cpumask_t logical_cpus;
 static volatile cpumask_t ipi_nmi_pending;
 
 /* used to hold the AP's until we are ready to release them */
@@ -210,8 +210,8 @@ static int	start_all_aps(void);
 static int	start_ap(int apic_id);
 static void	release_aps(void *dummy);
 
-static int	hlt_logical_cpus;
-static u_int	hyperthreading_cpus;
+static cpumask_t	hlt_logical_cpus;
+static cpumask_t	hyperthreading_cpus;
 static cpumask_t	hyperthreading_cpus_mask;
 static int	hyperthreading_allowed = 1;
 static struct	sysctl_ctx_list logical_cpu_clist;
@@ -1408,8 +1408,11 @@ ipi_nmi_handler()
 void
 cpustop_handler(void)
 {
-	int cpu = PCPU_GET(cpuid);
-	int cpumask = PCPU_GET(cpumask);
+	cpumask_t cpumask;
+	u_int cpu;
+
+	cpu = PCPU_GET(cpuid);
+	cpumask = PCPU_GET(cpumask);
 
 	savectx(&stoppcbs[cpu]);
 
@@ -1577,13 +1580,15 @@ SYSINIT(cpu_hlt, SI_SUB_SMP, SI_ORDER_AN
 int
 mp_grab_cpu_hlt(void)
 {
-	u_int mask = PCPU_GET(cpumask);
+	cpuset_t mask;
 #ifdef MP_WATCHDOG
-	u_int cpuid = PCPU_GET(cpuid);
+	u_int cpuid;
 #endif
 	int retval;
 
+	mask = PCPU_GET(cpumask);
 #ifdef MP_WATCHDOG
+	cpuid = PCPU_GET(cpuid);
 	ap_watchdog(cpuid);
 #endif
 

Modified: head/sys/i386/i386/pmap.c
==============================================================================
--- head/sys/i386/i386/pmap.c	Tue Aug 10 15:22:48 2010	(r211148)
+++ head/sys/i386/i386/pmap.c	Tue Aug 10 16:14:10 2010	(r211149)
@@ -949,8 +949,7 @@ pmap_update_pde_invalidate(vm_offset_t v
 void
 pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
 {
-	u_int cpumask;
-	u_int other_cpus;
+	cpumask_t cpumask, other_cpus;
 
 	sched_pin();
 	if (pmap == kernel_pmap || pmap->pm_active == all_cpus) {
@@ -970,8 +969,7 @@ pmap_invalidate_page(pmap_t pmap, vm_off
 void
 pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
 {
-	u_int cpumask;
-	u_int other_cpus;
+	cpumask_t cpumask, other_cpus;
 	vm_offset_t addr;
 
 	sched_pin();
@@ -995,8 +993,7 @@ pmap_invalidate_range(pmap_t pmap, vm_of
 void
 pmap_invalidate_all(pmap_t pmap)
 {
-	u_int cpumask;
-	u_int other_cpus;
+	cpumask_t cpumask, other_cpus;
 
 	sched_pin();
 	if (pmap == kernel_pmap || pmap->pm_active == all_cpus) {


More information about the svn-src-head mailing list