Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Extend PCU:
details: https://anonhg.NetBSD.org/src/rev/fee3278afc10
branches: trunk
changeset: 764715:fee3278afc10
user: rmind <rmind%NetBSD.org@localhost>
date: Mon May 02 00:29:53 2011 +0000
description:
Extend PCU:
- Add pcu_ops_t::pcu_state_release() operation for PCU_RELEASE case.
- Add pcu_switchpoint() to perform release operation on context switch.
- Sprinkle const, misc. Also, sync MIPS with changes.
Per discussions with matt@.
diffstat:
sys/arch/mips/include/cpu.h | 5 +-
sys/arch/mips/mips/compat_16_machdep.c | 6 +-
sys/arch/mips/mips/cpu_subr.c | 7 +-
sys/arch/mips/mips/mips_fpu.c | 51 +++++++++---------
sys/arch/mips/mips/netbsd32_machdep.c | 7 +-
sys/arch/mips/mips/process_machdep.c | 7 +-
sys/arch/mips/mips/vm_machdep.c | 6 +-
sys/kern/kern_synch.c | 5 +-
sys/kern/subr_pcu.c | 91 ++++++++++++++++++++++-----------
sys/sys/pcu.h | 19 +++++-
10 files changed, 123 insertions(+), 81 deletions(-)
diffs (truncated from 499 to 300 lines):
diff -r ed5d7990ff65 -r fee3278afc10 sys/arch/mips/include/cpu.h
--- a/sys/arch/mips/include/cpu.h Mon May 02 00:17:35 2011 +0000
+++ b/sys/arch/mips/include/cpu.h Mon May 02 00:29:53 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.101 2011/04/14 05:07:30 cliff Exp $ */
+/* $NetBSD: cpu.h,v 1.102 2011/05/02 00:29:54 rmind Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -624,8 +624,7 @@
void fpu_discard(void);
void fpu_load(void);
void fpu_save(void);
-void fpu_save_lwp(struct lwp *);
-bool fpu_used_p(struct lwp *);
+bool fpu_used_p(void);
/* mips_machdep.c */
void dumpsys(void);
diff -r ed5d7990ff65 -r fee3278afc10 sys/arch/mips/mips/compat_16_machdep.c
--- a/sys/arch/mips/mips/compat_16_machdep.c Mon May 02 00:17:35 2011 +0000
+++ b/sys/arch/mips/mips/compat_16_machdep.c Mon May 02 00:29:53 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_16_machdep.c,v 1.19 2011/04/29 22:11:15 matt Exp $ */
+/* $NetBSD: compat_16_machdep.c,v 1.20 2011/05/02 00:29:54 rmind Exp $ */
/*-
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.19 2011/04/29 22:11:15 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.20 2011/05/02 00:29:54 rmind Exp $");
#ifdef _KERNEL_OPT
#include "opt_cputype.h"
@@ -131,7 +131,7 @@
#endif
/* Save the FP state, if necessary, then copy it. */
- ksc.sc_fpused = fpu_used_p(l);
+ ksc.sc_fpused = fpu_used_p();
#if !defined(NOFPU)
if (ksc.sc_fpused) {
/* if FPU has current state, save it first */
diff -r ed5d7990ff65 -r fee3278afc10 sys/arch/mips/mips/cpu_subr.c
--- a/sys/arch/mips/mips/cpu_subr.c Mon May 02 00:17:35 2011 +0000
+++ b/sys/arch/mips/mips/cpu_subr.c Mon May 02 00:29:53 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_subr.c,v 1.12 2011/05/02 00:17:35 matt Exp $ */
+/* $NetBSD: cpu_subr.c,v 1.13 2011/05/02 00:29:54 rmind 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.12 2011/05/02 00:17:35 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.13 2011/05/02 00:29:54 rmind Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -395,7 +395,8 @@
*flags |= _UC_CPU | _UC_TLSBASE;
/* Save floating point register context, if any. */
- if (fpu_used_p(l)) {
+ KASSERT(l == curlwp);
+ if (fpu_used_p()) {
size_t fplen;
/*
* If this process is the current FP owner, dump its
diff -r ed5d7990ff65 -r fee3278afc10 sys/arch/mips/mips/mips_fpu.c
--- a/sys/arch/mips/mips/mips_fpu.c Mon May 02 00:17:35 2011 +0000
+++ b/sys/arch/mips/mips/mips_fpu.c Mon May 02 00:29:53 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mips_fpu.c,v 1.4 2011/04/29 22:18:16 matt Exp $ */
+/* $NetBSD: mips_fpu.c,v 1.5 2011/05/02 00:29:54 rmind Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mips_fpu.c,v 1.4 2011/04/29 22:18:16 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mips_fpu.c,v 1.5 2011/05/02 00:29:54 rmind Exp $");
#include "opt_multiprocessor.h"
@@ -46,20 +46,26 @@
#include <mips/regnum.h>
#include <mips/pcb.h>
-static void mips_fpu_state_save(lwp_t *, bool);
+static void mips_fpu_state_save(lwp_t *);
static void mips_fpu_state_load(lwp_t *, bool);
+static void mips_fpu_state_release(lwp_t *);
static const pcu_ops_t mips_fpu_ops = {
.pcu_id = PCU_FPU,
.pcu_state_save = mips_fpu_state_save,
.pcu_state_load = mips_fpu_state_load,
+ .pcu_state_release = mips_fpu_state_release
+};
+
+/* XXX */
+const pcu_ops_t * const pcu_ops_md_defs[PCU_UNIT_COUNT] = {
+ [PCU_FPU] = &mips_fpu_ops
};
void
fpu_discard(void)
{
pcu_discard(&mips_fpu_ops);
- curlwp->l_md.md_utf->tf_regs[_R_SR] &= ~MIPS_SR_COP_1_BIT;
}
void
@@ -71,23 +77,17 @@
void
fpu_save(void)
{
- pcu_save_lwp(&mips_fpu_ops, curlwp);
+ pcu_save(&mips_fpu_ops);
+}
+
+bool
+fpu_used_p(void)
+{
+ return pcu_used_p(&mips_fpu_ops);
}
void
-fpu_save_lwp(lwp_t *l)
-{
- pcu_save_lwp(&mips_fpu_ops, l);
-}
-
-bool
-fpu_used_p(lwp_t *l)
-{
- return pcu_used(&mips_fpu_ops, l);
-}
-
-void
-mips_fpu_state_save(lwp_t *l, bool release)
+mips_fpu_state_save(lwp_t *l)
{
struct trapframe * const tf = l->l_md.md_utf;
struct pcb * const pcb = lwp_getpcb(l);
@@ -121,13 +121,6 @@
"n"(MIPS_COP_0_STATUS));
/*
- * Make sure we don't reenable FP when we return to userspace.
- */
- if (release) {
- tf->tf_regs[_R_SR] ^= MIPS_SR_COP_1_BIT;
- }
-
- /*
* save FPCSR and FP register values.
*/
#if !defined(__mips_o32)
@@ -352,3 +345,11 @@
:: "r"(fpcsr &~ MIPS_FPU_EXCEPTION_BITS), "r"(status),
"n"(MIPS_COP_0_STATUS));
}
+
+void
+mips_fpu_state_release(lwp_t *l)
+{
+
+ KASSERT(l == curlwp);
+ l->l_md.md_utf->tf_regs[_R_SR] &= ~MIPS_SR_COP_1_BIT;
+}
diff -r ed5d7990ff65 -r fee3278afc10 sys/arch/mips/mips/netbsd32_machdep.c
--- a/sys/arch/mips/mips/netbsd32_machdep.c Mon May 02 00:17:35 2011 +0000
+++ b/sys/arch/mips/mips/netbsd32_machdep.c Mon May 02 00:29:53 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.6 2011/02/24 04:28:47 joerg Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.7 2011/05/02 00:29:54 rmind Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.6 2011/02/24 04:28:47 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.7 2011/05/02 00:29:54 rmind Exp $");
#include "opt_compat_netbsd.h"
#include "opt_sa.h"
@@ -308,7 +308,8 @@
return 0;
}
- fpu_save_lwp(l);
+ KASSERT(l == curlwp);
+ fpu_save();
struct pcb * const pcb = lwp_getpcb(l);
cpustate.frame = *l->l_md.md_utf;
diff -r ed5d7990ff65 -r fee3278afc10 sys/arch/mips/mips/process_machdep.c
--- a/sys/arch/mips/mips/process_machdep.c Mon May 02 00:17:35 2011 +0000
+++ b/sys/arch/mips/mips/process_machdep.c Mon May 02 00:29:53 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: process_machdep.c,v 1.34 2011/04/29 22:09:08 matt Exp $ */
+/* $NetBSD: process_machdep.c,v 1.35 2011/05/02 00:29:54 rmind Exp $ */
/*
* Copyright (c) 1993 The Regents of the University of California.
@@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.34 2011/04/29 22:09:08 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.35 2011/05/02 00:29:54 rmind Exp $");
/*
* This file may seem a bit stylized, but that so that it's easier to port.
@@ -144,7 +144,8 @@
*regslen_p = sizeof(struct fpreg_oabi);
#endif
- fpu_save_lwp(l);
+ KASSERT(l == curlwp);
+ fpu_save();
memcpy(regs, &pcb->pcb_fpregs, sizeof(*regs));
return 0;
}
diff -r ed5d7990ff65 -r fee3278afc10 sys/arch/mips/mips/vm_machdep.c
--- a/sys/arch/mips/mips/vm_machdep.c Mon May 02 00:17:35 2011 +0000
+++ b/sys/arch/mips/mips/vm_machdep.c Mon May 02 00:29:53 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.137 2011/04/29 22:07:46 matt Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.138 2011/05/02 00:29:54 rmind Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.137 2011/04/29 22:07:46 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.138 2011/05/02 00:29:54 rmind Exp $");
#include "opt_ddb.h"
#include "opt_coredump.h"
@@ -100,7 +100,7 @@
#ifndef NOFPU
/* If parent LWP was using FPU, then save the FPU h/w state. */
- fpu_save_lwp(l1);
+ fpu_save();
#endif
/* Copy the PCB from parent. */
diff -r ed5d7990ff65 -r fee3278afc10 sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c Mon May 02 00:17:35 2011 +0000
+++ b/sys/kern/kern_synch.c Mon May 02 00:29:53 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_synch.c,v 1.287 2011/04/14 05:33:20 matt Exp $ */
+/* $NetBSD: kern_synch.c,v 1.288 2011/05/02 00:29:53 rmind Exp $ */
/*-
* Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.287 2011/04/14 05:33:20 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.288 2011/05/02 00:29:53 rmind Exp $");
#include "opt_kstack.h"
#include "opt_perfctrs.h"
@@ -790,6 +790,7 @@
*/
pmap_activate(l);
uvm_emap_switch(l);
+ pcu_switchpoint(l);
if (prevlwp != NULL) {
/* Normalize the count of the spin-mutexes */
diff -r ed5d7990ff65 -r fee3278afc10 sys/kern/subr_pcu.c
--- a/sys/kern/subr_pcu.c Mon May 02 00:17:35 2011 +0000
+++ b/sys/kern/subr_pcu.c Mon May 02 00:29:53 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_pcu.c,v 1.3 2011/02/19 20:19:54 matt Exp $ */
+/* $NetBSD: subr_pcu.c,v 1.4 2011/05/02 00:29:53 rmind Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
*/
Home |
Main Index |
Thread Index |
Old Index