qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] aarch64: use TSX for ldrex/strex


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH] aarch64: use TSX for ldrex/strex
Date: Wed, 17 Aug 2016 10:22:05 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 08/15/2016 08:49 AM, Emilio G. Cota wrote:
+void HELPER(xbegin)(CPUARMState *env)
+{
+    uintptr_t ra = GETPC();
+    int status;
+    int retries = 100;
+
+ retry:
+    status = _xbegin();
+    if (status != _XBEGIN_STARTED) {
+        if (status && retries) {
+            retries--;
+            goto retry;
+        }
+        if (parallel_cpus) {
+            cpu_loop_exit_atomic(ENV_GET_CPU(env), ra);
+        }
+    }
+}
+
+void HELPER(xend)(void)
+{
+    if (_xtest()) {
+        _xend();
+    } else {
+        assert(!parallel_cpus);
+        parallel_cpus = true;
+    }
+}
+

Interesting idea.

FWIW, there are two other extant HTM implementations: ppc64 and s390x. As I recall, the s390 (but not the ppc64) transactions do not roll back the fp registers. Which suggests that we need special support within the TCG proglogue. Perhaps folding these operations into special TCG opcodes.

I believe that power8 has HTM, and there's one of those in the gcc compile farm, so this should be relatively easy to try out.

We increase the chances of success of the transaction if we minimize the amount of non-target code that's executed while the transaction is running. That suggests two things:

(1) that it would be doubly helpful to incorporate the transaction start directly into TCG code generation rather than as a helper and

(2) that we should start a new TB upon encountering a load-exclusive, so that we maximize the chance of the store-exclusive being a part of the same TB and thus have *nothing* extra between the beginning and commit of the transaction.



r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]