From: Fabiano Rosas <farosas@suse.de>
To: Peter Xu <peterx@redhat.com>, "Denis V. Lunev" <den@openvz.org>
Cc: qemu-devel@nongnu.org,
"Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>,
Mark Kanda <mark.kanda@oracle.com>,
Ben Chaney <bchaney@akamai.com>,
Steve Sistare <steven.sistare@oracle.com>
Subject: Re: [PATCH 1/1] migration/cpr: lock the cpr state
Date: Wed, 16 Sep 2026 15:57:06 -0300 [thread overview]
Message-ID: <87v785rpml.fsf@suse.de> (raw)
In-Reply-To: <aqrhPxFO7zHvZgs5@zhexu-thinkpadt14gen5.rmtcaon.csb>
Peter Xu <peterx@redhat.com> writes:
> On Wed, Sep 16, 2026 at 03:24:28PM +0200, Denis V. Lunev wrote:
>> From: Denis V. Lunev <den@openvz.org>
>>
>> The cpr state is a process wide registry of the resources that have to
>> survive an exec. Entries are added and dropped from realize and teardown
>> paths all over the tree, and a caller has no way to tell which thread the
>> next caller will run in.
>>
>> The state carries no serialization of its own. It is safe today only
>> because its callers happen to hold the BQL, and that is a property of
>> where those callers live rather than anything the interface promises or
>> checks. A caller that is correct within its own subsystem can therefore
>> break this one from a distance: two that overlap corrupt the registry,
>> and the next lookup walks an entry that has already been freed.
>>
>> Give the state a lock of its own instead of relying on that. Entries
>> move when a device is realized, when a resource is handed over, and when
>> a migration starts, so none of this is on a hot path and an uncontended
>> mutex costs nothing.
>>
>> Take the lock in every accessor and across the save and load walks.
>> Holding it over the walk callbacks is safe because none of them comes
>> back through this interface. State that is not reached through these
>> accessors, such as the VFIO device list that hw/vfio manipulates
>> directly, stays outside it.
>>
>> Signed-off-by: Denis V. Lunev <den@openvz.org>
>> Cc: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
>> Cc: Peter Xu <peterx@redhat.com>
>> Cc: Fabiano Rosas <farosas@suse.de>
>> Cc: Mark Kanda <mark.kanda@oracle.com>
>> Cc: Ben Chaney <bchaney@akamai.com>
>> Cc: Steve Sistare <steven.sistare@oracle.com>
>
> Is there a real problem anywhere?
>
> My gut feeling is we shouldn't be randomly adding fds into cpr unless we're
> creating a new device or so, which should normally need bql already.
>
> To ask in another way, shall we simply assert bql_locked()?
>
> Thanks,
Fair questions, let's see what Denis says.
From my point of view, if the work is already done to use a lock, I'd
take it; one less place for us to bother when dealing with BQL issues.
(on the other hand, I'm not doing any active use or testing of cpr aside
from migration-test, so my opinion is the least important here)
next prev parent reply other threads:[~2026-09-16 18:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 13:24 [PATCH 1/1] migration/cpr: lock the cpr state Denis V. Lunev
2026-09-16 18:25 ` Fabiano Rosas
2026-09-16 18:34 ` Peter Xu
2026-09-16 18:57 ` Fabiano Rosas [this message]
2026-09-16 19:37 ` Peter Xu
2026-09-17 12:24 ` Maciej S. Szmigiero
2026-09-17 12:36 ` Peter Xu
2026-09-17 12:44 ` Peter Xu
2026-09-17 14:17 ` Maciej S. Szmigiero
2026-09-17 14:37 ` Peter Xu
2026-09-17 14:45 ` Denis V. Lunev
2026-09-16 19:45 ` Denis V. Lunev
2026-09-16 20:43 ` Peter Xu
2026-09-17 9:48 ` Denis V. Lunev
2026-09-17 12:29 ` 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=87v785rpml.fsf@suse.de \
--to=farosas@suse.de \
--cc=bchaney@akamai.com \
--cc=den@openvz.org \
--cc=maciej.szmigiero@oracle.com \
--cc=mark.kanda@oracle.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=steven.sistare@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.