Module Name: src
Committed By: skrll
Date: Mon Oct 31 12:49:04 UTC 2016
Modified Files:
src/sys/arch/mips/include: cpu.h
src/sys/arch/mips/mips: cpu_subr.c
Log Message:
Pre-allocate some kcpuset_ts so that we don't try and allocate in the
wrong context.
To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/mips/include/cpu.h
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/mips/mips/cpu_subr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/mips/include/cpu.h
diff -u src/sys/arch/mips/include/cpu.h:1.120 src/sys/arch/mips/include/cpu.h:1.121
--- src/sys/arch/mips/include/cpu.h:1.120 Sat Jul 16 01:59:05 2016
+++ src/sys/arch/mips/include/cpu.h Mon Oct 31 12:49:04 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.120 2016/07/16 01:59:05 macallan Exp $ */
+/* $NetBSD: cpu.h,v 1.121 2016/10/31 12:49:04 skrll Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -150,6 +150,9 @@ struct cpu_info {
#define CPUF_RUNNING 0x04 /* CPU is running */
#define CPUF_PAUSED 0x08 /* CPU is paused */
#define CPUF_USERPMAP 0x20 /* CPU has a user pmap activated */
+ kcpuset_t *ci_multicastcpus;
+ kcpuset_t *ci_watchcpus;
+ kcpuset_t *ci_ddbcpus;
#endif
};
Index: src/sys/arch/mips/mips/cpu_subr.c
diff -u src/sys/arch/mips/mips/cpu_subr.c:1.29 src/sys/arch/mips/mips/cpu_subr.c:1.30
--- src/sys/arch/mips/mips/cpu_subr.c:1.29 Tue Aug 23 07:29:46 2016
+++ src/sys/arch/mips/mips/cpu_subr.c Mon Oct 31 12:49:04 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_subr.c,v 1.29 2016/08/23 07:29:46 skrll Exp $ */
+/* $NetBSD: cpu_subr.c,v 1.30 2016/10/31 12:49:04 skrll Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.29 2016/08/23 07:29:46 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.30 2016/10/31 12:49:04 skrll Exp $");
#include "opt_ddb.h"
#include "opt_cputype.h"
@@ -285,6 +285,10 @@ cpu_attach_common(device_t self, struct
* Initialize IPI framework for this cpu instance
*/
ipi_init(ci);
+
+ kcpuset_create(&ci->ci_multicastcpus, true);
+ kcpuset_create(&ci->ci_watchcpus, true);
+ kcpuset_create(&ci->ci_ddbcpus, true);
#endif
}
@@ -659,18 +663,17 @@ void
cpu_multicast_ipi(const kcpuset_t *kcp, int tag)
{
struct cpu_info * const ci = curcpu();
- kcpuset_t *kcp2;
+ kcpuset_t *kcp2 = ci->ci_multicastcpus;
if (kcpuset_match(cpus_running, ci->ci_data.cpu_kcpuset))
return;
- kcpuset_clone(&kcp2, kcp);
+ kcpuset_copy(kcp2, kcp);
kcpuset_remove(kcp2, ci->ci_data.cpu_kcpuset);
for (cpuid_t cii; (cii = kcpuset_ffs(kcp2)) != 0; ) {
kcpuset_clear(kcp2, --cii);
(void)cpu_send_ipi(cpu_lookup(cii), tag);
}
- kcpuset_destroy(kcp2);
}
int
@@ -684,8 +687,8 @@ static void
cpu_ipi_wait(const char *s, const kcpuset_t *watchset, const kcpuset_t *wanted)
{
bool done = false;
- kcpuset_t *kcp;
- kcpuset_create(&kcp, false);
+ struct cpu_info * const ci = curcpu();
+ kcpuset_t *kcp = ci->ci_watchcpus;
/* some finite amount of time */
@@ -708,8 +711,6 @@ cpu_ipi_wait(const char *s, const kcpuse
printf("\n");
}
}
-
- kcpuset_destroy(kcp);
}
/*
@@ -797,19 +798,17 @@ void
cpu_pause_others(void)
{
struct cpu_info * const ci = curcpu();
- kcpuset_t *kcp;
-
if (cold || kcpuset_match(cpus_running, ci->ci_data.cpu_kcpuset))
return;
- kcpuset_clone(&kcp, cpus_running);
+ kcpuset_t *kcp = ci->ci_ddbcpus;
+
+ kcpuset_copy(kcp, cpus_running);
kcpuset_remove(kcp, ci->ci_data.cpu_kcpuset);
kcpuset_remove(kcp, cpus_paused);
cpu_broadcast_ipi(IPI_SUSPEND);
cpu_ipi_wait("pause", cpus_paused, kcp);
-
- kcpuset_destroy(kcp);
}
/*
@@ -818,19 +817,17 @@ cpu_pause_others(void)
void
cpu_resume(cpuid_t cii)
{
- kcpuset_t *kcp;
-
if (__predict_false(cold))
return;
- kcpuset_create(&kcp, true);
+ struct cpu_info * const ci = curcpu();
+ kcpuset_t *kcp = ci->ci_ddbcpus;
+
kcpuset_set(kcp, cii);
kcpuset_atomicly_remove(cpus_resumed, cpus_resumed);
kcpuset_atomic_clear(cpus_paused, cii);
cpu_ipi_wait("resume", cpus_resumed, kcp);
-
- kcpuset_destroy(kcp);
}
/*
@@ -839,19 +836,18 @@ cpu_resume(cpuid_t cii)
void
cpu_resume_others(void)
{
- kcpuset_t *kcp;
-
if (__predict_false(cold))
return;
+ struct cpu_info * const ci = curcpu();
+ kcpuset_t *kcp = ci->ci_ddbcpus;
+
kcpuset_atomicly_remove(cpus_resumed, cpus_resumed);
- kcpuset_clone(&kcp, cpus_paused);
+ kcpuset_copy(kcp, cpus_paused);
kcpuset_atomicly_remove(cpus_paused, cpus_paused);
/* CPUs awake on cpus_paused clear */
cpu_ipi_wait("resume", cpus_resumed, kcp);
-
- kcpuset_destroy(kcp);
}
bool