qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Mario Casquero <mcasquer@redhat.com>,
	Alexey Perevalov <a.perevalov@samsung.com>,
	"Dr . David Alan Gilbert" <dave@treblig.org>,
	peterx@redhat.com, Juraj Marcin <jmarcin@redhat.com>,
	Fabiano Rosas <farosas@suse.de>
Subject: [PATCH v3 03/14] migration/postcopy: Drop all atomic ops in blocktime feature
Date: Fri, 13 Jun 2025 10:12:06 -0400	[thread overview]
Message-ID: <20250613141217.474825-4-peterx@redhat.com> (raw)
In-Reply-To: <20250613141217.474825-1-peterx@redhat.com>

Now with the mutex protection it's not needed anymore.

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/postcopy-ram.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 32fa06dabd..81925532de 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -849,12 +849,12 @@ void mark_postcopy_blocktime_begin(uintptr_t addr, uint32_t ptid,
 
     low_time_offset = get_low_time_offset(dc);
     if (dc->vcpu_addr[cpu] == 0) {
-        qatomic_inc(&dc->smp_cpus_down);
+        dc->smp_cpus_down++;
     }
 
-    qatomic_xchg(&dc->last_begin, low_time_offset);
-    qatomic_xchg(&dc->page_fault_vcpu_time[cpu], low_time_offset);
-    qatomic_xchg(&dc->vcpu_addr[cpu], addr);
+    dc->last_begin = low_time_offset;
+    dc->page_fault_vcpu_time[cpu] = low_time_offset;
+    dc->vcpu_addr[cpu] = addr;
 
     /*
      * The caller should only inject a blocktime entry when the page is
@@ -915,29 +915,26 @@ static void mark_postcopy_blocktime_end(uintptr_t addr)
     for (i = 0; i < smp_cpus; i++) {
         uint32_t vcpu_blocktime = 0;
 
-        read_vcpu_time = qatomic_fetch_add(&dc->page_fault_vcpu_time[i], 0);
-        if (qatomic_fetch_add(&dc->vcpu_addr[i], 0) != addr ||
-            read_vcpu_time == 0) {
+        read_vcpu_time = dc->page_fault_vcpu_time[i];
+        if (dc->vcpu_addr[i] != addr || read_vcpu_time == 0) {
             continue;
         }
-        qatomic_xchg(&dc->vcpu_addr[i], 0);
+        dc->vcpu_addr[i] = 0;
         vcpu_blocktime = low_time_offset - read_vcpu_time;
         affected_cpu += 1;
         /* we need to know is that mark_postcopy_end was due to
          * faulted page, another possible case it's prefetched
          * page and in that case we shouldn't be here */
-        if (!vcpu_total_blocktime &&
-            qatomic_fetch_add(&dc->smp_cpus_down, 0) == smp_cpus) {
+        if (!vcpu_total_blocktime && dc->smp_cpus_down == smp_cpus) {
             vcpu_total_blocktime = true;
         }
         /* continue cycle, due to one page could affect several vCPUs */
         dc->vcpu_blocktime[i] += vcpu_blocktime;
     }
 
-    qatomic_sub(&dc->smp_cpus_down, affected_cpu);
+    dc->smp_cpus_down -= affected_cpu;
     if (vcpu_total_blocktime) {
-        dc->total_blocktime += low_time_offset - qatomic_fetch_add(
-                &dc->last_begin, 0);
+        dc->total_blocktime += low_time_offset - dc->last_begin;
     }
     trace_mark_postcopy_blocktime_end(addr, dc, dc->total_blocktime,
                                       affected_cpu);
-- 
2.49.0



  parent reply	other threads:[~2025-06-13 14:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-13 14:12 [PATCH v3 00/14] migration/postcopy: Blocktime tracking overhaul Peter Xu
2025-06-13 14:12 ` [PATCH v3 01/14] migration: Add option to set postcopy-blocktime Peter Xu
2025-06-13 14:12 ` [PATCH v3 02/14] migration/postcopy: Push blocktime start/end into page req mutex Peter Xu
2025-06-13 14:12 ` Peter Xu [this message]
2025-06-13 14:12 ` [PATCH v3 04/14] migration/postcopy: Make all blocktime vars 64bits Peter Xu
2025-06-13 14:12 ` [PATCH v3 05/14] migration/postcopy: Drop PostcopyBlocktimeContext.start_time Peter Xu
2025-06-13 14:12 ` [PATCH v3 06/14] migration/postcopy: Bring blocktime layer to ns level Peter Xu
2025-06-13 14:12 ` [PATCH v3 07/14] migration/postcopy: Add blocktime fault counts per-vcpu Peter Xu
2025-06-13 14:12 ` [PATCH v3 08/14] migration/postcopy: Report fault latencies in blocktime Peter Xu
2025-06-13 14:12 ` [PATCH v3 09/14] migration/postcopy: Initialize blocktime context only until listen Peter Xu
2025-06-13 14:12 ` [PATCH v3 10/14] migration/postcopy: Cache the tid->vcpu mapping for blocktime Peter Xu
2025-06-13 14:12 ` [PATCH v3 11/14] migration/postcopy: Cleanup the total blocktime accounting Peter Xu
2025-06-13 14:12 ` [PATCH v3 12/14] migration/postcopy: Optimize blocktime fault tracking with hashtable Peter Xu
2025-06-13 14:12 ` [PATCH v3 13/14] migration/postcopy: blocktime allows track / report non-vCPU faults Peter Xu
2025-06-13 14:12 ` [PATCH v3 14/14] migration/postcopy: Add latency distribution report for blocktime Peter Xu
2025-06-25 13:39 ` [PATCH v3 00/14] migration/postcopy: Blocktime tracking overhaul Peter Xu

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=20250613141217.474825-4-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=a.perevalov@samsung.com \
    --cc=dave@treblig.org \
    --cc=farosas@suse.de \
    --cc=jmarcin@redhat.com \
    --cc=mcasquer@redhat.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).