From 77c39e17fa72d82a2ba0a483a23add85cd6a8b8b Mon Sep 17 00:00:00 2001
From: Paul Saab <ps@FreeBSD.org>
Date: Tue, 12 Aug 2003 17:01:10 +0000
Subject: [PATCH] Halted CPU's should not accumulate time.

Reviewed by:	jhb
---
 sys/amd64/amd64/mp_machdep.c | 12 ++++++------
 sys/amd64/amd64/mptable.c    | 12 ++++++------
 sys/amd64/include/mptable.h  | 12 ++++++------
 sys/i386/i386/mp_machdep.c   | 12 ++++++------
 sys/i386/i386/mptable.c      | 12 ++++++------
 sys/i386/include/mptable.h   | 12 ++++++------
 6 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index 0bb0fc752a7d..142ad9c0e76f 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -341,6 +341,10 @@ void		ap_init(void);
 static int	apic_int_is_bus_type(int intr, int bus_type);
 static void	release_aps(void *dummy);
 
+static int	hlt_cpus_mask;
+static int	hlt_logical_cpus = 1;
+static struct	sysctl_ctx_list logical_cpu_clist;
+
 /*
  * initialize all the SMP locks
  */
@@ -2679,7 +2683,7 @@ forward_statclock(void)
 	if (!smp_started || cold || panicstr)
 		return;
 
-	map = PCPU_GET(other_cpus) & ~stopped_cpus ;
+	map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask);
 	if (map != 0)
 		ipi_selected(map, IPI_STATCLOCK);
 }
@@ -2711,7 +2715,7 @@ forward_hardclock(void)
 	if (!smp_started || cold || panicstr)
 		return;
 
-	map = PCPU_GET(other_cpus) & ~stopped_cpus ;
+	map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask);
 	if (map != 0)
 		ipi_selected(map, IPI_HARDCLOCK);
 }
@@ -2791,10 +2795,6 @@ release_aps(void *dummy __unused)
 
 SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL);
 
-static int	hlt_cpus_mask;
-static int	hlt_logical_cpus = 1;
-static struct	sysctl_ctx_list logical_cpu_clist;
-
 static int
 sysctl_hlt_cpus(SYSCTL_HANDLER_ARGS)
 {
diff --git a/sys/amd64/amd64/mptable.c b/sys/amd64/amd64/mptable.c
index 0bb0fc752a7d..142ad9c0e76f 100644
--- a/sys/amd64/amd64/mptable.c
+++ b/sys/amd64/amd64/mptable.c
@@ -341,6 +341,10 @@ void		ap_init(void);
 static int	apic_int_is_bus_type(int intr, int bus_type);
 static void	release_aps(void *dummy);
 
+static int	hlt_cpus_mask;
+static int	hlt_logical_cpus = 1;
+static struct	sysctl_ctx_list logical_cpu_clist;
+
 /*
  * initialize all the SMP locks
  */
@@ -2679,7 +2683,7 @@ forward_statclock(void)
 	if (!smp_started || cold || panicstr)
 		return;
 
-	map = PCPU_GET(other_cpus) & ~stopped_cpus ;
+	map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask);
 	if (map != 0)
 		ipi_selected(map, IPI_STATCLOCK);
 }
@@ -2711,7 +2715,7 @@ forward_hardclock(void)
 	if (!smp_started || cold || panicstr)
 		return;
 
-	map = PCPU_GET(other_cpus) & ~stopped_cpus ;
+	map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask);
 	if (map != 0)
 		ipi_selected(map, IPI_HARDCLOCK);
 }
@@ -2791,10 +2795,6 @@ release_aps(void *dummy __unused)
 
 SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL);
 
-static int	hlt_cpus_mask;
-static int	hlt_logical_cpus = 1;
-static struct	sysctl_ctx_list logical_cpu_clist;
-
 static int
 sysctl_hlt_cpus(SYSCTL_HANDLER_ARGS)
 {
diff --git a/sys/amd64/include/mptable.h b/sys/amd64/include/mptable.h
index 0bb0fc752a7d..142ad9c0e76f 100644
--- a/sys/amd64/include/mptable.h
+++ b/sys/amd64/include/mptable.h
@@ -341,6 +341,10 @@ void		ap_init(void);
 static int	apic_int_is_bus_type(int intr, int bus_type);
 static void	release_aps(void *dummy);
 
+static int	hlt_cpus_mask;
+static int	hlt_logical_cpus = 1;
+static struct	sysctl_ctx_list logical_cpu_clist;
+
 /*
  * initialize all the SMP locks
  */
@@ -2679,7 +2683,7 @@ forward_statclock(void)
 	if (!smp_started || cold || panicstr)
 		return;
 
-	map = PCPU_GET(other_cpus) & ~stopped_cpus ;
+	map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask);
 	if (map != 0)
 		ipi_selected(map, IPI_STATCLOCK);
 }
@@ -2711,7 +2715,7 @@ forward_hardclock(void)
 	if (!smp_started || cold || panicstr)
 		return;
 
-	map = PCPU_GET(other_cpus) & ~stopped_cpus ;
+	map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask);
 	if (map != 0)
 		ipi_selected(map, IPI_HARDCLOCK);
 }
@@ -2791,10 +2795,6 @@ release_aps(void *dummy __unused)
 
 SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL);
 
-static int	hlt_cpus_mask;
-static int	hlt_logical_cpus = 1;
-static struct	sysctl_ctx_list logical_cpu_clist;
-
 static int
 sysctl_hlt_cpus(SYSCTL_HANDLER_ARGS)
 {
diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c
index 0bb0fc752a7d..142ad9c0e76f 100644
--- a/sys/i386/i386/mp_machdep.c
+++ b/sys/i386/i386/mp_machdep.c
@@ -341,6 +341,10 @@ void		ap_init(void);
 static int	apic_int_is_bus_type(int intr, int bus_type);
 static void	release_aps(void *dummy);
 
+static int	hlt_cpus_mask;
+static int	hlt_logical_cpus = 1;
+static struct	sysctl_ctx_list logical_cpu_clist;
+
 /*
  * initialize all the SMP locks
  */
@@ -2679,7 +2683,7 @@ forward_statclock(void)
 	if (!smp_started || cold || panicstr)
 		return;
 
-	map = PCPU_GET(other_cpus) & ~stopped_cpus ;
+	map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask);
 	if (map != 0)
 		ipi_selected(map, IPI_STATCLOCK);
 }
@@ -2711,7 +2715,7 @@ forward_hardclock(void)
 	if (!smp_started || cold || panicstr)
 		return;
 
-	map = PCPU_GET(other_cpus) & ~stopped_cpus ;
+	map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask);
 	if (map != 0)
 		ipi_selected(map, IPI_HARDCLOCK);
 }
@@ -2791,10 +2795,6 @@ release_aps(void *dummy __unused)
 
 SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL);
 
-static int	hlt_cpus_mask;
-static int	hlt_logical_cpus = 1;
-static struct	sysctl_ctx_list logical_cpu_clist;
-
 static int
 sysctl_hlt_cpus(SYSCTL_HANDLER_ARGS)
 {
diff --git a/sys/i386/i386/mptable.c b/sys/i386/i386/mptable.c
index 0bb0fc752a7d..142ad9c0e76f 100644
--- a/sys/i386/i386/mptable.c
+++ b/sys/i386/i386/mptable.c
@@ -341,6 +341,10 @@ void		ap_init(void);
 static int	apic_int_is_bus_type(int intr, int bus_type);
 static void	release_aps(void *dummy);
 
+static int	hlt_cpus_mask;
+static int	hlt_logical_cpus = 1;
+static struct	sysctl_ctx_list logical_cpu_clist;
+
 /*
  * initialize all the SMP locks
  */
@@ -2679,7 +2683,7 @@ forward_statclock(void)
 	if (!smp_started || cold || panicstr)
 		return;
 
-	map = PCPU_GET(other_cpus) & ~stopped_cpus ;
+	map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask);
 	if (map != 0)
 		ipi_selected(map, IPI_STATCLOCK);
 }
@@ -2711,7 +2715,7 @@ forward_hardclock(void)
 	if (!smp_started || cold || panicstr)
 		return;
 
-	map = PCPU_GET(other_cpus) & ~stopped_cpus ;
+	map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask);
 	if (map != 0)
 		ipi_selected(map, IPI_HARDCLOCK);
 }
@@ -2791,10 +2795,6 @@ release_aps(void *dummy __unused)
 
 SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL);
 
-static int	hlt_cpus_mask;
-static int	hlt_logical_cpus = 1;
-static struct	sysctl_ctx_list logical_cpu_clist;
-
 static int
 sysctl_hlt_cpus(SYSCTL_HANDLER_ARGS)
 {
diff --git a/sys/i386/include/mptable.h b/sys/i386/include/mptable.h
index 0bb0fc752a7d..142ad9c0e76f 100644
--- a/sys/i386/include/mptable.h
+++ b/sys/i386/include/mptable.h
@@ -341,6 +341,10 @@ void		ap_init(void);
 static int	apic_int_is_bus_type(int intr, int bus_type);
 static void	release_aps(void *dummy);
 
+static int	hlt_cpus_mask;
+static int	hlt_logical_cpus = 1;
+static struct	sysctl_ctx_list logical_cpu_clist;
+
 /*
  * initialize all the SMP locks
  */
@@ -2679,7 +2683,7 @@ forward_statclock(void)
 	if (!smp_started || cold || panicstr)
 		return;
 
-	map = PCPU_GET(other_cpus) & ~stopped_cpus ;
+	map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask);
 	if (map != 0)
 		ipi_selected(map, IPI_STATCLOCK);
 }
@@ -2711,7 +2715,7 @@ forward_hardclock(void)
 	if (!smp_started || cold || panicstr)
 		return;
 
-	map = PCPU_GET(other_cpus) & ~stopped_cpus ;
+	map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask);
 	if (map != 0)
 		ipi_selected(map, IPI_HARDCLOCK);
 }
@@ -2791,10 +2795,6 @@ release_aps(void *dummy __unused)
 
 SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL);
 
-static int	hlt_cpus_mask;
-static int	hlt_logical_cpus = 1;
-static struct	sysctl_ctx_list logical_cpu_clist;
-
 static int
 sysctl_hlt_cpus(SYSCTL_HANDLER_ARGS)
 {