aboutsummaryrefslogtreecommitdiff
path: root/migration/postcopy-ram.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2020-09-23 11:56:46 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2020-09-23 16:07:44 +0100
commitd73415a315471ac0b127ed3fad45c8ec5d711de1 (patch)
treebae20b3a39968fdfb4340b1a39b533333a8e6fd0 /migration/postcopy-ram.c
parented7db34b5aedba4487fd949b2e545eef954f093e (diff)
downloadqemu-d73415a315471ac0b127ed3fad45c8ec5d711de1.zip
qemu-d73415a315471ac0b127ed3fad45c8ec5d711de1.tar.gz
qemu-d73415a315471ac0b127ed3fad45c8ec5d711de1.tar.bz2
qemu/atomic.h: rename atomic_ to qatomic_
clang's C11 atomic_fetch_*() functions only take a C11 atomic type pointer argument. QEMU uses direct types (int, etc) and this causes a compiler error when a QEMU code calls these functions in a source file that also included <stdatomic.h> via a system header file: $ CC=clang CXX=clang++ ./configure ... && make ../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid) Avoid using atomic_*() names in QEMU's atomic.h since that namespace is used by <stdatomic.h>. Prefix QEMU's APIs with 'q' so that atomic.h and <stdatomic.h> can co-exist. I checked /usr/include on my machine and searched GitHub for existing "qatomic_" users but there seem to be none. This patch was generated using: $ git grep -h -o '\<atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \ sort -u >/tmp/changed_identifiers $ for identifier in $(</tmp/changed_identifiers); do sed -i "s%\<$identifier\>%q$identifier%g" \ $(git grep -I -l "\<$identifier\>") done I manually fixed line-wrap issues and misaligned rST tables. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200923105646.47864-1-stefanha@redhat.com>
Diffstat (limited to 'migration/postcopy-ram.c')
-rw-r--r--migration/postcopy-ram.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index baf094b..1654ff1 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -530,7 +530,7 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
Error *local_err = NULL;
/* Let the fault thread quit */
- atomic_set(&mis->fault_thread_quit, 1);
+ qatomic_set(&mis->fault_thread_quit, 1);
postcopy_fault_thread_notify(mis);
trace_postcopy_ram_incoming_cleanup_join();
qemu_thread_join(&mis->fault_thread);
@@ -742,12 +742,12 @@ static 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) {
- atomic_inc(&dc->smp_cpus_down);
+ qatomic_inc(&dc->smp_cpus_down);
}
- atomic_xchg(&dc->last_begin, low_time_offset);
- atomic_xchg(&dc->page_fault_vcpu_time[cpu], low_time_offset);
- atomic_xchg(&dc->vcpu_addr[cpu], addr);
+ 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);
/*
* check it here, not at the beginning of the function,
@@ -756,9 +756,9 @@ static void mark_postcopy_blocktime_begin(uintptr_t addr, uint32_t ptid,
*/
already_received = ramblock_recv_bitmap_test(rb, (void *)addr);
if (already_received) {
- atomic_xchg(&dc->vcpu_addr[cpu], 0);
- atomic_xchg(&dc->page_fault_vcpu_time[cpu], 0);
- atomic_dec(&dc->smp_cpus_down);
+ qatomic_xchg(&dc->vcpu_addr[cpu], 0);
+ qatomic_xchg(&dc->page_fault_vcpu_time[cpu], 0);
+ qatomic_dec(&dc->smp_cpus_down);
}
trace_mark_postcopy_blocktime_begin(addr, dc, dc->page_fault_vcpu_time[cpu],
cpu, already_received);
@@ -813,28 +813,28 @@ static void mark_postcopy_blocktime_end(uintptr_t addr)
for (i = 0; i < smp_cpus; i++) {
uint32_t vcpu_blocktime = 0;
- read_vcpu_time = atomic_fetch_add(&dc->page_fault_vcpu_time[i], 0);
- if (atomic_fetch_add(&dc->vcpu_addr[i], 0) != addr ||
+ 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) {
continue;
}
- atomic_xchg(&dc->vcpu_addr[i], 0);
+ qatomic_xchg(&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 &&
- atomic_fetch_add(&dc->smp_cpus_down, 0) == smp_cpus) {
+ qatomic_fetch_add(&dc->smp_cpus_down, 0) == smp_cpus) {
vcpu_total_blocktime = true;
}
/* continue cycle, due to one page could affect several vCPUs */
dc->vcpu_blocktime[i] += vcpu_blocktime;
}
- atomic_sub(&dc->smp_cpus_down, affected_cpu);
+ qatomic_sub(&dc->smp_cpus_down, affected_cpu);
if (vcpu_total_blocktime) {
- dc->total_blocktime += low_time_offset - atomic_fetch_add(
+ dc->total_blocktime += low_time_offset - qatomic_fetch_add(
&dc->last_begin, 0);
}
trace_mark_postcopy_blocktime_end(addr, dc, dc->total_blocktime,
@@ -928,7 +928,7 @@ static void *postcopy_ram_fault_thread(void *opaque)
error_report("%s: read() failed", __func__);
}
- if (atomic_read(&mis->fault_thread_quit)) {
+ if (qatomic_read(&mis->fault_thread_quit)) {
trace_postcopy_ram_fault_thread_quit();
break;
}
@@ -1410,13 +1410,13 @@ static PostcopyState incoming_postcopy_state;
PostcopyState postcopy_state_get(void)
{
- return atomic_mb_read(&incoming_postcopy_state);
+ return qatomic_mb_read(&incoming_postcopy_state);
}
/* Set the state and return the old state */
PostcopyState postcopy_state_set(PostcopyState new_state)
{
- return atomic_xchg(&incoming_postcopy_state, new_state);
+ return qatomic_xchg(&incoming_postcopy_state, new_state);
}
/* Register a handler for external shared memory postcopy