Subject: New mutex implementation for ARM
To: None <email@example.com>
From: Jason Thorpe <firstname.lastname@example.org>
Date: 03/09/2007 11:27:16
It saddened me that kmutex_t was 20 bytes on ARM, so I fixed it to be
the optimal 8-bytes. The restartable atomic sequence I added to
support this can also be used for rwlock_t, eliminating the need to
block interrupts to manipulate it; I'll make that change shortly.
Ben -- you need to update acorn26 to do the RAS check for _lock_cas()
-- see the LOCK_CAS_CHECK macro in include/arm32/frame.h.
Uwe -- you might want to use this as a model for what to do for sh3.
Everyone else -- you might want to enable the LOCKDEBUG option in your
kernels for a while. Matt Thomas did so while testing these changes
for me and found a latent bug in the Shark interrupt code.
Begin forwarded message:
> From: Jason R Thorpe <email@example.com>
> Date: March 9, 2007 11:21:59 AM PST
> To: source-changes@NetBSD.org
> Subject: CVS commit: src/sys/arch
> Reply-To: firstname.lastname@example.org
> Module Name: src
> Committed By: thorpej
> Date: Fri Mar 9 19:21:59 UTC 2007
> Modified Files:
> src/sys/arch/arm/arm: arm_machdep.c
> src/sys/arch/arm/arm32: genassym.cf irq_dispatch.S
> src/sys/arch/arm/conf: files.arm
> src/sys/arch/arm/include: mutex.h
> src/sys/arch/arm/include/arm32: frame.h
> src/sys/arch/arm/iomd: iomd_irq.S
> src/sys/arch/arm/ofw: ofw_irq.S
> src/sys/arch/arm/sa11x0: sa11x0_irq.S
> src/sys/arch/arm/xscale: i80200_irq.S
> src/sys/arch/shark/isa: isa_irq.S
> Log Message:
> Rewrite the ARM mutex implementation to be of the simple-mutex
> Because pre-v6 ARM lacks support for an atomic compare-and-swap, we
> implement _lock_cas() as a restartable atomic squence that is checked
> in the IRQ handler right before AST processing. (This is safe
> for all practical purposes, there are no SMP pre-v6 ARM systems.)
> This can serve as a model for other non-MP platforms that lack the
> necessary atomic operations for mutexes (SuperH, for example).
> Upshots of this change:
> - kmutex_t is now down to 8 bytes on ARM; about as good as we can get.
> - ARM2 systems don't have to trap and emulate SWP or SWPB for mutexes.
> The acorn26 port is not updated by this commit to do the
> That is left as an exercise for the port maintainer.
> Reviewed and tested by Matt Thomas.
> To generate a diff of this commit:
> cvs rdiff -r1.13 -r1.14 src/sys/arch/arm/arm/arm_machdep.c
> cvs rdiff -r1.31 -r1.32 src/sys/arch/arm/arm32/genassym.cf
> cvs rdiff -r1.7 -r1.8 src/sys/arch/arm/arm32/irq_dispatch.S
> cvs rdiff -r1.82 -r1.83 src/sys/arch/arm/conf/files.arm
> cvs rdiff -r1.6 -r1.7 src/sys/arch/arm/include/mutex.h
> cvs rdiff -r1.14 -r1.15 src/sys/arch/arm/include/arm32/frame.h
> cvs rdiff -r1.5 -r1.6 src/sys/arch/arm/iomd/iomd_irq.S
> cvs rdiff -r1.6 -r1.7 src/sys/arch/arm/ofw/ofw_irq.S
> cvs rdiff -r1.9 -r1.10 src/sys/arch/arm/sa11x0/sa11x0_irq.S
> cvs rdiff -r1.13 -r1.14 src/sys/arch/arm/xscale/i80200_irq.S
> cvs rdiff -r1.6 -r1.7 src/sys/arch/shark/isa/isa_irq.S
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.