Subject: CVS commit: [wrstuden-fixsa] src/sys
To: None <source-changes@NetBSD.org>
From: Bill Stouder-Studenmund <wrstuden@netbsd.org>
List: source-changes
Date: 05/17/2007 22:53:07
Module Name: src
Committed By: wrstuden
Date: Thu May 17 22:53:07 UTC 2007
Modified Files:
src/sys/kern [wrstuden-fixsa]: kern_sa.c kern_synch.c
src/sys/sys [wrstuden-fixsa]: savar.h
Log Message:
Adjust how we handle allocating an SA Event structure used to inform
the application that we are blocking.
Since we only generate BLOCKED upcalls when the thread "on" the
vp blocks and further since the first thing we do after this is
run the upcall delivery code (we switch to the lwp lying around for
this very purpose), we will never generate more BLOCKED upcalls than
we have vps. We have an invariant, let's use it.
So we add a pointer to the vp structure, and store an upcall event
data structure in it. When we block in sa_switch(), we use that
structure. When we deliver an upcall into userland, if our vp is
lacking an upcall event structure, we don't free the upcall
event structure for the event we just delivered, we instead hang it
off of the vp.
We thus no longer need to allocate memory when blocking.
This version of the code contains a panic() in the case that we do
not have an upcall event structure available in sa_switch(). Keep this in
mind before putting this version into a production environment.
It has been suggested that it would be easier to embed an upcall event
structure in the virtual processor structure, given the invariant above.
The problem is that while we only can generate one BLOCKED per vp, we
do not necessarily deliver that upcall immediately to userland. If there
were pending upcalls, we deliver them first. As such, we can have code
running on the vp before the BLOCKED event is delivered. If _that_ code
blocks, we have no where to store that information. Thus we limit ourselves
to holding a pointer to separately-allocated memory.
To generate a diff of this commit:
cvs rdiff -r1.87 -r1.87.4.1 src/sys/kern/kern_sa.c
cvs rdiff -r1.173 -r1.173.4.1 src/sys/kern/kern_synch.c
cvs rdiff -r1.20 -r1.20.10.1 src/sys/sys/savar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.