Infrastructure for lazy istream sync in the pmap module:

- Add a bitmask for the CPUs which need an isync before this pmap returns
  to userspace on that CPU.
- Define PMAP_USERRET(), a utility macro for userret() to use to process
  the deferred isync, and call it as appropriate in userret().
This commit is contained in:
thorpej 2000-03-01 02:22:03 +00:00
parent b4dbebce1a
commit 908f6bc4cd
2 changed files with 66 additions and 4 deletions

View File

@ -1,4 +1,41 @@
/* $NetBSD: trap.c,v 1.50 1999/12/04 21:19:57 ragge Exp $ */
/* $NetBSD: trap.c,v 1.51 2000/03/01 02:22:03 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
* NASA Ames Research Center.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -64,7 +101,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.50 1999/12/04 21:19:57 ragge Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.51 2000/03/01 02:22:03 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -77,6 +114,7 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.50 1999/12/04 21:19:57 ragge Exp $");
#include <sys/ktrace.h>
#endif
#include <vm/vm.h>
#include <uvm/uvm_extern.h>
#include <machine/cpu.h>
@ -146,6 +184,9 @@ userret(p, pc, oticks)
{
int sig, s;
/* Do any deferred user pmap operations. */
PMAP_USERRET(vm_map_pmap(&p->p_vmspace->vm_map));
/* take pending signals */
while ((sig = CURSIG(p)) != 0)
postsig(sig);
@ -164,6 +205,7 @@ userret(p, pc, oticks)
p->p_stats->p_ru.ru_nivcsw++;
mi_switch();
splx(s);
PMAP_USERRET(vm_map_pmap(&p->p_vmspace->vm_map));
while ((sig = CURSIG(p)) != 0)
postsig(sig);
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: pmap.h,v 1.32 1999/11/28 19:53:11 thorpej Exp $ */
/* $NetBSD: pmap.h,v 1.33 2000/03/01 02:22:03 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -113,6 +113,7 @@ struct pmap {
unsigned int *pm_asn; /* address space number */
unsigned long *pm_asngen; /* ASN generation number */
unsigned long pm_cpus; /* mask of CPUs using pmap */
unsigned long pm_needisync; /* mask of CPUs needing isync */
};
typedef struct pmap *pmap_t;
@ -300,6 +301,25 @@ pmap_l3pte(pmap, v, l2pte)
#define PMAP_LOCK(pmap) simple_lock(&(pmap)->pm_slock)
#define PMAP_UNLOCK(pmap) simple_unlock(&(pmap)->pm_slock)
/*
* Macro for processing deferred I-stream synchronization.
*
* The pmap module may defer syncing the user I-stream until the
* return to userspace, since the IMB PALcode op can be quite
* expensive. Since user instructions won't be executed until
* the return to userspace, this can be deferred until userret().
*/
#define PMAP_USERRET(pmap) \
do { \
u_long cpu_mask = (1UL << cpu_number()); \
\
if ((pmap)->pm_needisync & cpu_mask) { \
alpha_atomic_clearbits_q(&(pmap)->pm_needisync, \
cpu_mask); \
alpha_pal_imb(); \
} \
} while (0)
#endif /* _KERNEL */
#endif /* _PMAP_MACHINE_ */