qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Chunqiang (CQ) Tang" <tangchq@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] thread synchronization in qcow2.c and qcow2-cluster.c
Date: Tue, 27 Apr 2010 12:06:17 -0400	[thread overview]
Message-ID: <s2g50c1b8771004270906v69ad619cycc188f212fb0440a@mail.gmail.com> (raw)

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

             reply	other threads:[~2010-04-27 16:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-27 16:06 Chunqiang (CQ) Tang [this message]
2010-04-27 19:49 ` [Qemu-devel] thread synchronization in qcow2.c and qcow2-cluster.c 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s2g50c1b8771004270906v69ad619cycc188f212fb0440a@mail.gmail.com \
    --to=tangchq@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).