comment
This commit is contained in:
parent
e3482212aa
commit
673662ef94
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_synch.c,v 1.299 2012/03/03 00:22:24 matt Exp $ */
|
||||
/* $NetBSD: kern_synch.c,v 1.300 2012/04/18 13:44:19 yamt 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.299 2012/03/03 00:22:24 matt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.300 2012/04/18 13:44:19 yamt Exp $");
|
||||
|
||||
#include "opt_kstack.h"
|
||||
#include "opt_perfctrs.h"
|
||||
|
@ -755,6 +755,10 @@ mi_switch(lwp_t *l)
|
|||
|
||||
KASSERT(l->l_cpu == ci);
|
||||
splx(oldspl);
|
||||
/*
|
||||
* note that, unless the caller disabled preemption,
|
||||
* we can be preempted at any time after the above splx() call.
|
||||
*/
|
||||
retval = 1;
|
||||
} else {
|
||||
/* Nothing to do - just unlock and return. */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_pcu.c,v 1.10 2011/09/27 01:02:39 jym Exp $ */
|
||||
/* $NetBSD: subr_pcu.c,v 1.11 2012/04/18 13:43:13 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
|
@ -57,7 +57,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_pcu.c,v 1.10 2011/09/27 01:02:39 jym Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_pcu.c,v 1.11 2012/04/18 13:43:13 yamt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/cpu.h>
|
||||
|
@ -75,6 +75,13 @@ static void pcu_lwp_op(const pcu_ops_t *, lwp_t *, int);
|
|||
/* XXX */
|
||||
extern const pcu_ops_t * const pcu_ops_md_defs[];
|
||||
|
||||
/*
|
||||
* pcu_switchpoint: release PCU state if the LWP is being run on another CPU.
|
||||
*
|
||||
* On each context switches, called by mi_switch() with IPL_SCHED.
|
||||
* 'l' is an LWP which is just we switched to. (the new curlwp)
|
||||
*/
|
||||
|
||||
void
|
||||
pcu_switchpoint(lwp_t *l)
|
||||
{
|
||||
|
@ -88,6 +95,7 @@ pcu_switchpoint(lwp_t *l)
|
|||
/* PCUs are not in use. */
|
||||
return;
|
||||
}
|
||||
/* commented out as we know we are already at IPL_SCHED */
|
||||
/* s = splsoftclock(); */
|
||||
for (id = 0; id < PCU_UNIT_COUNT; id++) {
|
||||
if ((pcu_inuse & (1 << id)) == 0) {
|
||||
|
@ -103,6 +111,12 @@ pcu_switchpoint(lwp_t *l)
|
|||
/* splx(s); */
|
||||
}
|
||||
|
||||
/*
|
||||
* pcu_discard_all: discard PCU state of the given LWP.
|
||||
*
|
||||
* Used by exec and LWP exit.
|
||||
*/
|
||||
|
||||
void
|
||||
pcu_discard_all(lwp_t *l)
|
||||
{
|
||||
|
@ -133,10 +147,19 @@ pcu_discard_all(lwp_t *l)
|
|||
splx(s);
|
||||
}
|
||||
|
||||
/*
|
||||
* pcu_save_all: save PCU state of the given LWP so that eg. coredump can
|
||||
* examine it.
|
||||
*/
|
||||
|
||||
void
|
||||
pcu_save_all(lwp_t *l)
|
||||
{
|
||||
const uint32_t pcu_inuse = l->l_pcu_used;
|
||||
/*
|
||||
* Unless LW_WCORE, we aren't releasing since this LWP isn't giving
|
||||
* up PCU, just saving it.
|
||||
*/
|
||||
const int flags = PCU_SAVE | (l->l_flag & LW_WCORE ? PCU_RELEASE : 0);
|
||||
|
||||
/*
|
||||
|
@ -162,10 +185,6 @@ pcu_save_all(lwp_t *l)
|
|||
continue;
|
||||
}
|
||||
const pcu_ops_t * const pcu = pcu_ops_md_defs[id];
|
||||
/*
|
||||
* We aren't releasing since this LWP isn't giving up PCU,
|
||||
* just saving it.
|
||||
*/
|
||||
pcu_lwp_op(pcu, l, flags);
|
||||
}
|
||||
splx(s);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pcu.h,v 1.8 2011/06/06 22:04:34 matt Exp $ */
|
||||
/* $NetBSD: pcu.h,v 1.9 2012/04/18 13:42:11 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
|
@ -49,6 +49,20 @@
|
|||
|
||||
#if PCU_UNIT_COUNT > 0
|
||||
|
||||
/*
|
||||
* pcu_state_save(lwp)
|
||||
* save the current CPU's state into the given LWP's MD storage.
|
||||
*
|
||||
* pcu_state_load(lwp, used)
|
||||
* load PCU state from the given LWP's MD storage to the current CPU.
|
||||
* the 'used' argument is true if it isn't the first time the LWP uses
|
||||
* the PCU.
|
||||
*
|
||||
* pcu_state_release(lwp)
|
||||
* tell MD code detect the next use of the PCU on the LWP, and call
|
||||
* pcu_load().
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
u_int pcu_id;
|
||||
void (*pcu_state_save)(lwp_t *);
|
||||
|
|
Loading…
Reference in New Issue