qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* hexagon: modeling a shared lock state
@ 2024-01-24 15:07 Brian Cain
  2024-01-25  0:22 ` Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Cain @ 2024-01-24 15:07 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel@nongnu.org, Sid Manning, Marco Liebel,
	Matheus Bernardino, richard.henderson@linaro.org

[-- Attachment #1: Type: text/plain, Size: 1745 bytes --]

Philippe,

For hexagon sysemu, while internally reviewing patches to be upstreamed we noticed that our design for a lock instruction is not quite suitable.  The k0lock instruction will halt if some other hexagon hardware CPU has already claimed the kernel lock, only to continue executing once some CPU executes the unlock instruction.  We modeled this using a lock state enumeration member { OWNER, WAITING, UNLOCKED } in *each* vCPU and atomically transitioning the lock required us to have vCPU[n] write the updated lock state to vCPU[m] when unlocking.

In context: https://github.com/quic/qemu/blob/hexagon_sysemu_20_dec_2023/target/hexagon/op_helper.c#L1790-L1821

So instead, maybe it makes more sense to have a system device hold a single representation of the lock's state and each vCPU can do some kind of access via load/store and/or interrupts to/from the device?  I was thinking of raising an interrupt on the lock device at the vCPU's k0lock instruction to indicate demand for the lock, and then the device could raise an interrupt to one of the vCPUs when it's granted the lock.  One drawback for this is that this might add significant latency to the uncontested lock case.  So I also considered doing a load of some part of the lock device's memory that could indicate whether the lock was available, and if available it would claim it with a store (both ld/st while holding BQL).  Only if unavailable it would halt and raise the interrupt.  Is it possible to create an address space that's independent of the true system memory map for this use case or would we need to carve out some memory from the existing memory map for this synthetic device?  Or - do you have a suggestion for a better approach overall?

-Brian

[-- Attachment #2: Type: text/html, Size: 3835 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-27  2:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-24 15:07 hexagon: modeling a shared lock state Brian Cain
2024-01-25  0:22 ` Richard Henderson
2024-01-25 16:28   ` Brian Cain
2024-01-27  2:19     ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).