From: Richard Henderson <richard.henderson@linaro.org>
To: quintela@redhat.com
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PULL 00/20] Migration 20230420 patches
Date: Sat, 22 Apr 2023 10:57:47 +0100 [thread overview]
Message-ID: <cf72042a-ecb2-bdb6-d4a4-3b45ab9b3cd8@linaro.org> (raw)
In-Reply-To: <87y1mke0hb.fsf@secure.mitica>
On 4/22/23 10:21, Juan Quintela wrote:
> Richard Henderson <richard.henderson@linaro.org> wrote:
>> On 4/20/23 14:17, Juan Quintela wrote:
>>> The following changes since commit 2d82c32b2ceaca3dc3da5e36e10976f34bfcb598:
>>> Open 8.1 development tree (2023-04-20 10:05:25 +0100)
>>> are available in the Git repository at:
>>> https://gitlab.com/juan.quintela/qemu.git
>>> tags/migration-20230420-pull-request
>>> for you to fetch changes up to
>>> cdf07846e6fe07a2e20c93eed5902114dc1d3dcf:
>>> migration: Pass migrate_caps_check() the old and new caps
>>> (2023-04-20 15:10:58 +0200)
>>> ----------------------------------------------------------------
>>> Migration Pull request
>>> This series include everything reviewed for migration:
>>> - fix for disk stop/start (eric)
>>> - detect filesystem of hostmem (peter)
>>> - rename qatomic_mb_read (paolo)
>>> - whitespace cleanup (李皆俊)
>>> I hope copy and paste work for the name O:-)
>>> - atomic_counters series (juan)
>>> - two first patches of capabilities (juan)
>>> Please apply,
>>
>> Fails CI:
>> https://gitlab.com/qemu-project/qemu/-/jobs/4159279870#L2896
>>
>> /usr/lib/gcc-cross/mipsel-linux-gnu/10/../../../../mipsel-linux-gnu/bin/ld:
>> libcommon.fa.p/migration_migration.c.o: undefined reference to symbol
>> '__atomic_load_8@@LIBATOMIC_1.0'
>
> Hi Richard
>
> First of all, I have no doubt that you know better that me in this
> regard (*).
>
> Once told that, it looks like one case of "my toolchain is better than
> yours":
>
> $ ls qemu-system-mips
> qemu-system-mips qemu-system-mips64el.p/ qemu-system-mipsel.p/
> qemu-system-mips64 qemu-system-mips64.p/ qemu-system-mips.p/
> qemu-system-mips64el qemu-system-mipsel
>
> This is Fedora37 with updates.
I'm sure it's not true that "my toolchain is better", because mips32 simply does not have
the ability. (And of course mips64 does, but that's a different test.)
I'll note that mips32 and armv6 (that is, *not* debian's armv7 based armhf distro) are the
only hosts we have that don't have an atomic 8-byte operation.
> There are two posibilities here that came to mind, in order of
> probability;
> - myself with:
>
> - if (ram_counters.dirty_pages_rate && transferred > 10000) {
> + if (qatomic_read__nocheck(&ram_counters.dirty_pages_rate) &&
> + transferred > 10000) {
I think it's this one...
> - paolo:
>
> PostcopyState postcopy_state_get(void)
> {
> - return qatomic_mb_read(&incoming_postcopy_state);
> + return qatomic_load_acquire(&incoming_postcopy_state);
... because this one was already atomic, with different barriers.
> and why I used qatomic_*__nocheck() instead of the proper operations?
> Because reading this:
>
> #define qatomic_read__nocheck(ptr) \
> __atomic_load_n(ptr, __ATOMIC_RELAXED)
>
> #define qatomic_read(ptr) \
> ({ \
> qemu_build_assert(sizeof(*ptr) <= ATOMIC_REG_SIZE); \
> qatomic_read__nocheck(ptr); \
> })
>
> #define qatomic_set__nocheck(ptr, i) \
> __atomic_store_n(ptr, i, __ATOMIC_RELAXED)
>
> #define qatomic_set(ptr, i) do { \
> qemu_build_assert(sizeof(*ptr) <= ATOMIC_REG_SIZE); \
> qatomic_set__nocheck(ptr, i); \
> } while(0)
>
> I was complely sure that we will never get the qemu_build_assert().
>
> I know, I know.
:-)
> And now that I have explained myself, what is the correct way of doing
> this?
>
> I declared the value as:
>
> + aligned_uint64_t dirty_bytes_last_sync;
> - int64_t remaining;
>
> I just want to make sure that *all* ram_counters are atomic and then I
> can use them from any thread. All the counters that use stat64 already
> are. But for this two to work, I would need to have a way to set and
> old value.
>
> And once that we are here, I would like ta have:
>
> stat64_inc(): just add 1, I know, I can create a macro.
>
> and
>
> stat64_reset(): as its name says, it returns the value to zero.
>
> I still miss a couple of stats in migration, where I need to reset them
> to zero from time to time:
How critical are the statistics? Are they integral to the algorithm or are they merely
for diagnostics and user display? What happens they're not atomic and we do race?
If we really need atomicity, then the only answer is a mutex or spinlock.
> ./ram.c:380: uint64_t bytes_xfer_prev;
> ./ram.c:747: rs->bytes_xfer_prev = stat64_get(&ram_counters.transferred);
> ./ram.c:1183: stat64_get(&ram_counters.transferred) - rs->bytes_xfer_prev;
> ./ram.c:1247: rs->bytes_xfer_prev = stat64_get(&ram_counters.transferred);
>
> You can clame that this operation happens always on the migration
> thread, but I have found that it is more difficult to document which
> ones are atomic and which not, that make all of them atomic. This
> variable are get/set once a second, so performance is not one of the
> issues.
For access once per second, it sounds like a spinlock would be fine.
r~
next prev parent reply other threads:[~2023-04-22 9:58 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 13:17 [PULL 00/20] Migration 20230420 patches Juan Quintela
2023-04-20 13:17 ` [PULL 01/20] migration: remove extra whitespace character for code style Juan Quintela
2023-04-20 13:17 ` [PULL 02/20] postcopy-ram: do not use qatomic_mb_read Juan Quintela
2023-04-20 13:17 ` [PULL 03/20] migration: Merge ram_counters and ram_atomic_counters Juan Quintela
2023-04-20 13:17 ` [PULL 04/20] migration: Update atomic stats out of the mutex Juan Quintela
2023-04-20 13:17 ` [PULL 05/20] migration: Make multifd_bytes atomic Juan Quintela
2023-04-20 13:17 ` [PULL 06/20] migration: Make dirty_sync_missed_zero_copy atomic Juan Quintela
2023-04-20 13:17 ` [PULL 07/20] migration: Make precopy_bytes atomic Juan Quintela
2023-04-20 13:17 ` [PULL 08/20] migration: Make downtime_bytes atomic Juan Quintela
2023-04-20 13:17 ` [PULL 09/20] migration: Make dirty_sync_count atomic Juan Quintela
2023-04-20 13:17 ` [PULL 10/20] migration: Make postcopy_requests atomic Juan Quintela
2023-04-20 13:17 ` [PULL 11/20] migration: Make dirty_pages_rate atomic Juan Quintela
2023-04-20 13:17 ` [PULL 12/20] migration: Make dirty_bytes_last_sync atomic Juan Quintela
2023-04-20 13:17 ` [PULL 13/20] migration: Rename duplicate to zero_pages Juan Quintela
2023-04-20 13:17 ` [PULL 14/20] migration: Rename normal to normal_pages Juan Quintela
2023-04-20 13:17 ` [PULL 15/20] migration: Handle block device inactivation failures better Juan Quintela
2023-04-20 13:17 ` [PULL 16/20] util/mmap-alloc: qemu_fd_getfs() Juan Quintela
2023-04-20 13:17 ` [PULL 17/20] vl.c: Create late backends before migration object Juan Quintela
2023-04-20 13:17 ` [PULL 18/20] migration/postcopy: Detect file system on dest host Juan Quintela
2023-04-20 13:17 ` [PULL 19/20] migration: rename enabled_capabilities to capabilities Juan Quintela
2023-04-20 13:17 ` [PULL 20/20] migration: Pass migrate_caps_check() the old and new caps Juan Quintela
2023-04-22 5:09 ` [PULL 00/20] Migration 20230420 patches Richard Henderson
2023-04-22 9:21 ` Juan Quintela
2023-04-22 9:57 ` Richard Henderson [this message]
2023-04-23 9:45 ` Juan Quintela
2023-04-23 15:00 ` Richard Henderson
2023-04-24 9:57 ` Juan Quintela
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=cf72042a-ecb2-bdb6-d4a4-3b45ab9b3cd8@linaro.org \
--to=richard.henderson@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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).