diff options
author | marcel <marcel@FreeBSD.org> | 2013-02-12 17:38:35 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2013-02-12 17:38:35 +0000 |
commit | 6da471ce0205104fc4ba5b07ac0e084a5a77c6fd (patch) | |
tree | c8c52799a5a0b960dc595e6e48111ec85c630061 /sys/ia64/ia64/machdep.c | |
parent | bd362fd0fc450c392064fa6ab3f45e7a22abba89 (diff) | |
download | FreeBSD-src-6da471ce0205104fc4ba5b07ac0e084a5a77c6fd.zip FreeBSD-src-6da471ce0205104fc4ba5b07ac0e084a5a77c6fd.tar.gz |
Eliminate the PC_CURTHREAD symbol and load the current thread's
thread structure pointer atomically from r13 (the pcpu pointer)
for the current CPU/core.
Add a CTASSERT in machdep.c to make sure that pc_curthread is in
fact the first field in struct pcpu.
The only non-atomic operations left were those related to process-
space operations, such as casuword, subyte, suword16, fubyte,
fuword16, copyin, copyout and their variations.
The casuword function has been re-structured more complete than
the others. This way we have an example of a better bundling
without introducing a lot of risk when we get it wrong. The
other functions can be rebundled in separate commits and with
the appropriate testing.
Diffstat (limited to 'sys/ia64/ia64/machdep.c')
-rw-r--r-- | sys/ia64/ia64/machdep.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index fbc35d1..98bcf44 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -98,6 +98,22 @@ __FBSDID("$FreeBSD$"); #include <machine/unwind.h> #include <machine/vmparam.h> +/* + * For atomicity reasons, we demand that pc_curthread is the first + * field in the struct pcpu. It allows us to read the pointer with + * a single atomic instruction: + * ld8 %curthread = [r13] + * Otherwise we would first have to calculate the load address and + * store the result in a temporary register and that for the load: + * add %temp = %offsetof(struct pcpu), r13 + * ld8 %curthread = [%temp] + * A context switch inbetween the add and the ld8 could have the + * thread migrate to a different core. In that case, %curthread + * would be the thread running on the original core and not actually + * the current thread. + */ +CTASSERT(offsetof(struct pcpu, pc_curthread) == 0); + static SYSCTL_NODE(_hw, OID_AUTO, freq, CTLFLAG_RD, 0, ""); static SYSCTL_NODE(_machdep, OID_AUTO, cpu, CTLFLAG_RD, 0, ""); |