qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 45/45] tcg: enable multiple TCG contexts in s


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH v2 45/45] tcg: enable multiple TCG contexts in softmmu
Date: Mon, 17 Jul 2017 19:25:14 -1000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 07/16/2017 10:04 AM, Emilio G. Cota wrote:
+
+    /* claim the first free pointer in tcg_ctxs and increment n_tcg_ctxs */
+    for (i = 0; i < smp_cpus; i++) {
+        if (atomic_cmpxchg(&tcg_ctxs[i], NULL, s) == NULL) {
+            unsigned int n;
+
+            n = atomic_fetch_inc(&n_tcg_ctxs);

Surely this is too much effort. The increment on n_tcg_ctxs is sufficient to produce an index for assignment. We never free the contexts...

Which also suggests that it might be better to avoid an indirection in tcg_ctxs and allocate all of the structures in one big block? I.e.

TCGContext *tcg_ctxs;

// At the end of tcg_context_init.
#ifdef CONFIG_USER_ONLY
    tcg_ctxs = s;
#else
    // No need to zero; we'll completely overwrite each structure
    // during tcg_register_thread.
    tcg_ctxs = g_new(TCGContext, smp_cpus);
#endif


r~



reply via email to

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