All of lore.kernel.org
 help / color / mirror / Atom feed
From: Evgeny Voevodin <e.voevodin@samsung.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	i.mitsyanko@samsung.com, kyungmin.park@samsung.com,
	d.solodkiy@samsung.com, m.kozlov@samsung.com
Subject: Re: [Qemu-devel] [PATCH v2] TCG: Convert global variables to be TLS.
Date: Fri, 02 Mar 2012 10:08:50 +0400	[thread overview]
Message-ID: <4F5063F2.5060908@samsung.com> (raw)
In-Reply-To: <20120301075146.GA2937@cs.nctu.edu.tw>

On 01.03.2012 11:51, 陳韋任 wrote:
>> If you're serious about multithreading TCG then I think the first
>> steps are:
>>   * fix existing race conditions
>>   * think very hard
>>   * come up with an overall design for what you're proposing
>
>    As COREMU [1] point out, current QEMU atomic instruction emulation approach is
> problematic. For example, guest application might use x86 xchg instruction to
> implement spin lock/unlock (addr is a shared memory space).
>
>
>        spin_unlock:                   spin_lock:
>
>                                       try:
>                                         r10 = 1;
>                                         xchg addr, r10;
>                                         if (r10 == 0)
>                                           goto success;
>        *addr = 0;                     fail:
>                                         pause;
>                                         if (*addr != 0)
>                                           goto fail;
>
>                                         goto try;
>
>                                       success:
>
>
> After QEMU translation, guest xchg instruction becomes
>
>        spin_unlock:                   spin_lock:
>
>                                       helper_lock;
>
>        *addr = 0;                     T0 = r10;
>                                       T1 = *addr;
>                                       *addr = T0;
>                                       r10 = T1;
>
>                                       helper_unlock;
>
>    You can the see the atomicity on which spin lock/unlock rely is broken.
> "*addr = 0" can happened in the between of helper_lock/helper_unlock.
> COREMU solve this by using a lightway software transaction memory to emulate
> atomic instructions. I think this issue is quite important if we want to make
> TCG multithreaded, right? Is there a better way to solve this?
>
> Regards,
> chenwj
>
> [1]
> http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.6011&rep=rep1&type=pdf
>

In COREMU implementation they rely on support of single-word CAS 
instructions by the host architecture. And if such support presents, we 
can use CASN algorithm if we need multiple-word CAS. So, this approach 
limits supported host architectures. The general question - is there 
some host which QEMU can run on and which doesn't support CAS?

-- 
Kind regards,
Evgeny Voevodin,
Leading Software Engineer,
ASWG, Moscow R&D center, Samsung Electronics
e-mail: e.voevodin@samsung.com

  reply	other threads:[~2012-03-02  6:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27 11:06 [Qemu-devel] [PATCH] TCG: Convert global variables to be TLS Evgeny Voevodin
2012-02-27 11:06 ` Evgeny Voevodin
2012-02-27 11:43 ` Evgeny Voevodin
2012-02-27 12:13 ` [Qemu-devel] [PATCH v2] " Evgeny Voevodin
2012-02-27 12:35   ` Peter Maydell
2012-02-28  3:13     ` Evgeny Voevodin
2012-02-28  8:10       ` Peter Maydell
2012-02-29  3:26         ` 陳韋任
2012-02-29  3:43           ` Evgeny Voevodin
2012-02-29  3:46             ` 陳韋任
2012-02-29  4:01               ` Evgeny Voevodin
2012-03-01  7:51         ` 陳韋任
2012-03-02  6:08           ` Evgeny Voevodin [this message]
2012-03-01  8:22       ` Andreas Färber
2012-03-01  8:27         ` Peter Maydell
2012-03-01 10:57           ` Evgeny Voevodin

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=4F5063F2.5060908@samsung.com \
    --to=e.voevodin@samsung.com \
    --cc=d.solodkiy@samsung.com \
    --cc=i.mitsyanko@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=m.kozlov@samsung.com \
    --cc=peter.maydell@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.