qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] thread synchronization in qcow2.c and qcow2-cluster.c
@ 2010-04-27 16:06 Chunqiang (CQ) Tang
  2010-04-27 19:49 ` Stefan Hajnoczi
  0 siblings, 1 reply; 7+ messages in thread
From: Chunqiang (CQ) Tang @ 2010-04-27 16:06 UTC (permalink / raw)
  To: qemu-devel

Hi there,

I just started to read the code of qemu-kvm-0.12.3 recently, and was
puzzled by the thread synchronization issue in qcow2.c and
qcow2-cluster.c. Could someone please enlighten me? Thanks!

Specifically, I found that BDRVQcowState.cluster_allocs, which is a
QLIST_HEAD, may be accessed concurrently by two threads, but I could
not figure out how the two thread synchronize with each other to avoid
race conditions (e.g., through a lock?).

Stack trace of thread 1:
main -> main_loop -> kvm_main_loop -> main_loop_wait -> posix_aio_read
-> posix_aio_process_queue -> qcow_aio_write_cb ->
qcow2_alloc_cluster_offset (which may modify
BDRVQcowState.cluster_allocs)

Stack trace of thread 2:
ap_main_loop -> ... -> kvm_handle_io -> ... -> qcow_aio_writev ->
qcow_aio_write_cb -> qcow2_alloc_cluster_offset (which may modify
BDRVQcowState.cluster_allocs)

-- 
Best regards,
CQ Tang

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

end of thread, other threads:[~2010-04-28 14:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-27 16:06 [Qemu-devel] thread synchronization in qcow2.c and qcow2-cluster.c Chunqiang (CQ) Tang
2010-04-27 19:49 ` Stefan Hajnoczi
2010-04-27 20:39   ` Chunqiang (CQ) Tang
2010-04-27 21:26     ` Stefan Hajnoczi
2010-04-28  8:13       ` Stefan Hajnoczi
2010-04-28 14:59         ` Chunqiang (CQ) Tang
2010-04-28  9:08     ` Kevin Wolf

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).