[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 1/8] migration: Take migration object refcount earlier for
From: |
Fabiano Rosas |
Subject: |
Re: [PATCH v3 1/8] migration: Take migration object refcount earlier for threads |
Date: |
Tue, 29 Oct 2024 15:48:05 -0300 |
Peter Xu <peterx@redhat.com> writes:
> Both migration thread or background snapshot thread will take a refcount of
> the migration object at the entrace of the thread function.
>
> That makes sense, because it protects the object from being freed by the
> main thread in migration_shutdown() later, but it might still race with it
> if the thread is scheduled too late. Consider the case right after
> pthread_create() happened, VM shuts down with the object released, but
> right after that the migration thread finally got created, referencing
> MigrationState* in the opaque pointer which is already freed.
>
> The only 100% safe way to make sure it won't get freed is taking the
> refcount right before the thread is created, meanwhile when BQL is held.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
- [PATCH v3 3/8] migration: Unexport ram_mig_init(), (continued)
- [PATCH v3 3/8] migration: Unexport ram_mig_init(), Peter Xu, 2024/10/24
- [PATCH v3 2/8] migration: Unexport dirty_bitmap_mig_init(), Peter Xu, 2024/10/24
- [PATCH v3 5/8] migration: Drop migration_is_idle(), Peter Xu, 2024/10/24
- [PATCH v3 1/8] migration: Take migration object refcount earlier for threads, Peter Xu, 2024/10/24
- [PATCH v3 4/8] migration: Drop migration_is_setup_or_active(), Peter Xu, 2024/10/24
- [PATCH v3 7/8] migration: Unexport migration_is_active(), Peter Xu, 2024/10/24
- Re: [PATCH v3 7/8] migration: Unexport migration_is_active(), Avihai Horon, 2024/10/28
- Re: [PATCH v3 7/8] migration: Unexport migration_is_active(), Peter Xu, 2024/10/28
- Re: [PATCH v3 7/8] migration: Unexport migration_is_active(), Avihai Horon, 2024/10/28
- Re: [PATCH v3 7/8] migration: Unexport migration_is_active(), Peter Xu, 2024/10/28
- Re: [PATCH v3 7/8] migration: Unexport migration_is_active(), Avihai Horon, 2024/10/28
- Re: [PATCH v3 7/8] migration: Unexport migration_is_active(), Peter Xu, 2024/10/28