[PATCH v3 60/68] accel/tcg: Factor rr_cpu_exec() out for re-use

Philippe Mathieu-Daudé posted 68 patches 4 months, 2 weeks ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Stefano Stabellini <sstabellini@kernel.org>, Anthony PERARD <anthony@xenproject.org>, Paul Durrant <paul@xen.org>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, "Dr. David Alan Gilbert" <dave@treblig.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Reinoud Zandijk <reinoud@netbsd.org>, Sunil Muthuswamy <sunilmut@microsoft.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Peter Xu <peterx@redhat.com>, David Hildenbrand <david@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Alexander Graf <agraf@csgraf.de>
There is a newer version of this series
[PATCH v3 60/68] accel/tcg: Factor rr_cpu_exec() out for re-use
Posted by Philippe Mathieu-Daudé 4 months, 2 weeks ago
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/tcg-accel-ops-rr.h |  2 ++
 accel/tcg/tcg-accel-ops-rr.c | 31 ++++++++++++++++++++-----------
 2 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/accel/tcg/tcg-accel-ops-rr.h b/accel/tcg/tcg-accel-ops-rr.h
index 2a76a296127..a73fe5b94a6 100644
--- a/accel/tcg/tcg-accel-ops-rr.h
+++ b/accel/tcg/tcg-accel-ops-rr.h
@@ -18,4 +18,6 @@ void rr_kick_vcpu_thread(CPUState *unused);
 /* start the round robin vcpu thread */
 void rr_start_vcpu_thread(CPUState *cpu);
 
+int rr_cpu_exec(CPUState *cpu);
+
 #endif /* TCG_ACCEL_OPS_RR_H */
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index f5af7818d51..a9150802369 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -169,6 +169,25 @@ static int rr_cpu_count(void)
     return cpu_count;
 }
 
+int rr_cpu_exec(CPUState *cpu)
+{
+    int ret;
+
+    bql_unlock();
+    if (icount_enabled()) {
+        icount_prepare_for_run(cpu);
+    }
+
+    ret = tcg_cpu_exec(cpu);
+
+    if (icount_enabled()) {
+        icount_process_data(cpu);
+    }
+    bql_lock();
+
+    return ret;
+}
+
 static void *rr_vcpu_register(CPUState *cpu)
 {
     Notifier *force_rcu = g_new(Notifier, 1);
@@ -269,17 +288,7 @@ static void *rr_cpu_thread_fn(void *arg)
                               (cpu->singlestep_enabled & SSTEP_NOTIMER) == 0);
 
             if (cpu_can_run(cpu)) {
-                int r;
-
-                bql_unlock();
-                if (icount_enabled()) {
-                    icount_prepare_for_run(cpu);
-                }
-                r = tcg_cpu_exec(cpu);
-                if (icount_enabled()) {
-                    icount_process_data(cpu);
-                }
-                bql_lock();
+                int r = rr_cpu_exec(cpu);
 
                 if (r == EXCP_DEBUG) {
                     cpu_handle_guest_debug(cpu);
-- 
2.49.0


Re: [PATCH v3 60/68] accel/tcg: Factor rr_cpu_exec() out for re-use
Posted by Richard Henderson 4 months, 2 weeks ago
On 7/1/25 08:40, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   accel/tcg/tcg-accel-ops-rr.h |  2 ++
>   accel/tcg/tcg-accel-ops-rr.c | 31 ++++++++++++++++++++-----------
>   2 files changed, 22 insertions(+), 11 deletions(-)

I guess this is just completeness in matching mttcg, not that rr_cpu_exec will *ever* be 
called from outside tcg-accel-ops-rr.c.

Acked-by: Richard Henderson <richard.henderson@linaro.org>


r~

Re: [PATCH v3 60/68] accel/tcg: Factor rr_cpu_exec() out for re-use
Posted by Richard Henderson 4 months, 2 weeks ago
On 7/2/25 09:37, Richard Henderson wrote:
> On 7/1/25 08:40, Philippe Mathieu-Daudé wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   accel/tcg/tcg-accel-ops-rr.h |  2 ++
>>   accel/tcg/tcg-accel-ops-rr.c | 31 ++++++++++++++++++++-----------
>>   2 files changed, 22 insertions(+), 11 deletions(-)
> 
> I guess this is just completeness in matching mttcg, not that rr_cpu_exec will *ever* be 
> called from outside tcg-accel-ops-rr.c.
> 
> Acked-by: Richard Henderson <richard.henderson@linaro.org>

Alternately, split out the function but make it static; do *not* register it in patch 64.


r~