From: David Hildenbrand <david@redhat.com>
To: Alexander Duyck <alexander.duyck@gmail.com>, mst@redhat.com
Cc: virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v2 2/3] virtio-balloon: Add locking to prevent possible race when starting hinting
Date: Fri, 10 Jul 2020 14:14:53 +0200 [thread overview]
Message-ID: <62c0ab76-cdef-27fd-e4db-a835e3dd7617@redhat.com> (raw)
In-Reply-To: <20200706211407.20018.51061.stgit@localhost.localdomain>
On 06.07.20 23:14, Alexander Duyck wrote:
> From: Alexander Duyck <alexander.h.duyck@linux.intel.com>
>
> There is already locking in place when we are stopping free page hinting
> but there is not similar protections in place when we start. I can only
> assume this was overlooked as in most cases the page hinting should not be
> occurring when we are starting the hinting, however there is still a chance
> we could be processing hints by the time we get back around to restarting
> the hinting so we are better off making sure to protect the state with the
> mutex lock rather than just updating the value with no protections.
>
> Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
> ---
> hw/virtio/virtio-balloon.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
> index 0c0fd7114799..b3e96a822b4d 100644
> --- a/hw/virtio/virtio-balloon.c
> +++ b/hw/virtio/virtio-balloon.c
> @@ -593,6 +593,8 @@ static void virtio_balloon_free_page_start(VirtIOBalloon *s)
> return;
> }
>
> + qemu_mutex_lock(&s->free_page_lock);
> +
> if (s->free_page_report_cmd_id == UINT_MAX) {
> s->free_page_report_cmd_id =
> VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN;
> @@ -601,6 +603,8 @@ static void virtio_balloon_free_page_start(VirtIOBalloon *s)
> }
>
> s->free_page_report_status = FREE_PAGE_REPORT_S_REQUESTED;
> + qemu_mutex_unlock(&s->free_page_lock);
> +
> virtio_notify_config(vdev);
> }
>
>
Yes, makes sense, thanks
Acked-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2020-07-10 12:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-06 21:13 [PATCH v2 0/3] virtio-balloon: Free page hinting clean-ups Alexander Duyck
2020-07-06 21:14 ` [PATCH v2 1/3] virtio-balloon: Prevent guest from starting a report when we didn't request one Alexander Duyck
2020-07-06 21:14 ` [PATCH v2 2/3] virtio-balloon: Add locking to prevent possible race when starting hinting Alexander Duyck
2020-07-09 15:23 ` Peter Maydell
2020-07-09 15:28 ` Peter Maydell
2020-07-10 12:14 ` David Hildenbrand [this message]
2020-07-06 21:14 ` [PATCH v2 3/3] virtio-balloon: Replace free page hinting references to 'report' with 'hint' Alexander Duyck
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=62c0ab76-cdef-27fd-e4db-a835e3dd7617@redhat.com \
--to=david@redhat.com \
--cc=alexander.duyck@gmail.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=virtio-dev@lists.oasis-open.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).