From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Andrew Jones <drjones@redhat.com>,
Sean Christopherson <seanjc@google.com>
Subject: Re: [PATCH v3 1/2] KVM: selftests: Sync data verify of dirty logging with guest sync
Date: Tue, 20 Apr 2021 16:07:51 +0200 [thread overview]
Message-ID: <e110673a-8422-bdff-4336-bdb486842d39@redhat.com> (raw)
In-Reply-To: <20210420131041.GZ4440@xz-x1>
On 20/04/21 15:10, Peter Xu wrote:
> On Tue, Apr 20, 2021 at 10:07:16AM +0200, Paolo Bonzini wrote:
>> On 18/04/21 14:43, Peter Xu wrote:
>>> ----8<-----
>>> diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
>>> index 25230e799bc4..d3050d1c2cd0 100644
>>> --- a/tools/testing/selftests/kvm/dirty_log_test.c
>>> +++ b/tools/testing/selftests/kvm/dirty_log_test.c
>>> @@ -377,7 +377,7 @@ static void dirty_ring_after_vcpu_run(struct kvm_vm *vm, int ret, int err)
>>> /* A ucall-sync or ring-full event is allowed */
>>> if (get_ucall(vm, VCPU_ID, NULL) == UCALL_SYNC) {
>>> /* We should allow this to continue */
>>> - ;
>>> + vcpu_handle_sync_stop();
>>> } else if (run->exit_reason == KVM_EXIT_DIRTY_RING_FULL ||
>>> (ret == -1 && err == EINTR)) {
>>> /* Update the flag first before pause */
>>> ----8<-----
>>>
>>> That's my intention when I introduce vcpu_handle_sync_stop(), but forgot to
>>> add...
>>
>> And possibly even this (untested though):
>>
>> diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
>> index ffa4e2791926..918954f01cef 100644
>> --- a/tools/testing/selftests/kvm/dirty_log_test.c
>> +++ b/tools/testing/selftests/kvm/dirty_log_test.c
>> @@ -383,6 +383,7 @@ static void dirty_ring_after_vcpu_run(struct kvm_vm *vm, int ret, int err)
>> /* Update the flag first before pause */
>> WRITE_ONCE(dirty_ring_vcpu_ring_full,
>> run->exit_reason == KVM_EXIT_DIRTY_RING_FULL);
>> + atomic_set(&vcpu_sync_stop_requested, false);
>> sem_post(&sem_vcpu_stop);
>> pr_info("vcpu stops because %s...\n",
>> dirty_ring_vcpu_ring_full ?
>> @@ -804,8 +805,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
>> * the flush of the last page, and since we handle the last
>> * page specially verification will succeed anyway.
>> */
>> - assert(host_log_mode == LOG_MODE_DIRTY_RING ||
>> - atomic_read(&vcpu_sync_stop_requested) == false);
>> + assert(atomic_read(&vcpu_sync_stop_requested) == false);
>> vm_dirty_log_verify(mode, bmap);
>> sem_post(&sem_vcpu_cont);
>>
>> You can submit all these as a separate patch.
>
> But it could race, then?
>
> main thread vcpu thread
> ----------- -----------
> ring full
> vcpu_sync_stop_requested=0
> sem_post(&sem_vcpu_stop)
> vcpu_sync_stop_requested=1
> sem_wait(&sem_vcpu_stop)
> assert(vcpu_sync_stop_requested==0) <----
Yes, it could indeed.
Thanks,
Paolo
next prev parent reply other threads:[~2021-04-20 14:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-17 14:36 [PATCH v3 0/2] KVM: selftests: fix races in dirty log test Peter Xu
2021-04-17 14:36 ` [PATCH v3 1/2] KVM: selftests: Sync data verify of dirty logging with guest sync Peter Xu
2021-04-18 12:43 ` Peter Xu
2021-04-20 8:07 ` Paolo Bonzini
2021-04-20 13:10 ` Peter Xu
2021-04-20 14:07 ` Paolo Bonzini [this message]
2021-04-17 14:36 ` [PATCH v3 2/2] KVM: selftests: Wait for vcpu thread before signal setup Peter Xu
2021-04-20 8:14 ` Paolo Bonzini
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=e110673a-8422-bdff-4336-bdb486842d39@redhat.com \
--to=pbonzini@redhat.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterx@redhat.com \
--cc=seanjc@google.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).