From: Peter Xu <peterx@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, Gavin Shan <gshan@redhat.com>,
Marc Zyngier <maz@kernel.org>
Subject: Re: [PATCH] KVM: use store-release to mark dirty pages as harvested
Date: Fri, 2 Sep 2022 10:10:27 -0400 [thread overview]
Message-ID: <YxIO07FuavXzXytJ@xz-m1.local> (raw)
In-Reply-To: <20220902001936.108645-1-pbonzini@redhat.com>
On Fri, Sep 02, 2022 at 02:19:36AM +0200, Paolo Bonzini wrote:
> The following scenario can happen if QEMU sets more RESET flags while
> the KVM_RESET_DIRTY_RINGS ioctl is ongoing on another host CPU:
>
> CPU0 CPU1 CPU2
> ------------------------ ------------------ ------------------------
> fill gfn0
> store-rel flags for gfn0
> fill gfn1
> store-rel flags for gfn1
> load-acq flags for gfn0
> set RESET for gfn0
> load-acq flags for gfn1
> set RESET for gfn1
> do ioctl! ----------->
> ioctl(RESET_RINGS)
> fill gfn2
> store-rel flags for gfn2
> load-acq flags for gfn2
> set RESET for gfn2
> process gfn0
> process gfn1
> process gfn2
> do ioctl!
> etc.
>
> The three load-acquire in CPU0 synchronize with the three store-release
> in CPU2, but CPU0 and CPU1 are only synchronized up to gfn1 and CPU1
> may miss gfn2's fields other than flags.
>
> The kernel must be able to cope with invalid values of the fields, and
> userspace *will* invoke the ioctl once more. However, once the RESET flag
> is cleared on gfn2, it is lost forever, therefore in the above scenario
> CPU1 must read the correct value of gfn2's fields.
>
> Therefore RESET must be set with a store-release, that will synchronize
> with KVM's load-acquire in CPU1.
>
> Cc: Gavin Shan <gshan@redhat.com>
> Cc: Peter Xu <peterx@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Thanks (again)!
--
Peter Xu
next prev parent reply other threads:[~2022-09-02 14:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-02 0:19 [PATCH] KVM: use store-release to mark dirty pages as harvested Paolo Bonzini
2022-09-02 14:10 ` Peter Xu [this message]
2022-09-04 13:43 ` Philippe Mathieu-Daudé via
2022-09-07 5:42 ` Gavin Shan
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=YxIO07FuavXzXytJ@xz-m1.local \
--to=peterx@redhat.com \
--cc=gshan@redhat.com \
--cc=maz@kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).