Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mips Pre-allocate some kcpuset_ts so that we don't ...
details: https://anonhg.NetBSD.org/src/rev/f432f5a13d43
branches: trunk
changeset: 348636:f432f5a13d43
user: skrll <skrll%NetBSD.org@localhost>
date: Mon Oct 31 12:49:04 2016 +0000
description:
Pre-allocate some kcpuset_ts so that we don't try and allocate in the
wrong context.
diffstat:
sys/arch/mips/include/cpu.h | 5 +++-
sys/arch/mips/mips/cpu_subr.c | 44 +++++++++++++++++++-----------------------
2 files changed, 24 insertions(+), 25 deletions(-)
diffs (159 lines):
diff -r e53c633b3ec6 -r f432f5a13d43 sys/arch/mips/include/cpu.h
--- a/sys/arch/mips/include/cpu.h Mon Oct 31 12:27:22 2016 +0000
+++ b/sys/arch/mips/include/cpu.h Mon Oct 31 12:49:04 2016 +0000
@@ -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 @@
#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
};
diff -r e53c633b3ec6 -r f432f5a13d43 sys/arch/mips/mips/cpu_subr.c
--- a/sys/arch/mips/mips/cpu_subr.c Mon Oct 31 12:27:22 2016 +0000
+++ b/sys/arch/mips/mips/cpu_subr.c Mon Oct 31 12:49:04 2016 +0000
@@ -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 @@
* 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 @@
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 @@
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 @@
printf("\n");
}
}
-
- kcpuset_destroy(kcp);
}
/*
@@ -797,19 +798,17 @@
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 @@
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 @@
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
Home |
Main Index |
Thread Index |
Old Index