mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: David Stevens <stevensd@chromium.org>,
	"Michael S . Tsirkin" <mst@redhat.com>
Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] virtio_balloon: stay awake while adjusting balloon
Date: Mon, 18 Dec 2023 18:32:57 +0100	[thread overview]
Message-ID: <aae229d7-0675-47c5-9a02-5ba0b6a64906@redhat.com> (raw)
In-Reply-To: <20231218151842.2756673-1-stevensd@google.com>

On 18.12.23 16:18, David Stevens wrote:
> From: David Stevens <stevensd@chromium.org>
> 
> A virtio_balloon's parent device may be configured so that a
> configuration change interrupt is a wakeup event. Extend the processing
> of such a wakeup event until the balloon finishes inflating or deflating
> by calling pm_stay_awake/pm_relax in the virtio_balloon driver. Note
> that these calls are no-ops if the parent device doesn't support wakeup
> events or if the wakeup events are not enabled.
> 
> This change allows the guest to use system power states such as s2idle
> without running the risk the virtio_balloon's cooperative memory
> management becoming unresponsive to the host's requests.
> 
> Signed-off-by: David Stevens <stevensd@chromium.org>
> ---
> v1 -> v2:
>   - Use adjustment_signal_pending flag instead of a sequence number
>   - Call pm_stay_awake/pm_relax on parent device instead of adding a wake
>     event to the virtio balloon device
> 
>   drivers/virtio/virtio_balloon.c | 57 +++++++++++++++++++++++++++------
>   1 file changed, 47 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index 1fe93e93f5bc..a3c11159cbe0 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -119,6 +119,11 @@ struct virtio_balloon {
>   	/* Free page reporting device */
>   	struct virtqueue *reporting_vq;
>   	struct page_reporting_dev_info pr_dev_info;
> +
> +	/* State for keeping the wakeup_source active while adjusting the balloon */
> +	spinlock_t adjustment_lock;
> +	bool adjustment_signal_pending;
> +	bool adjustment_in_progress;
>   };
>   
>   static const struct virtio_device_id id_table[] = {
> @@ -437,6 +442,31 @@ static void virtio_balloon_queue_free_page_work(struct virtio_balloon *vb)
>   	queue_work(vb->balloon_wq, &vb->report_free_page_work);
>   }
>   
> +static void start_update_balloon_size(struct virtio_balloon *vb)
> +{
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&vb->adjustment_lock, flags);
> +	vb->adjustment_signal_pending = true;
> +	if (!vb->adjustment_in_progress) {
> +		vb->adjustment_in_progress = true;
> +		pm_stay_awake(vb->vdev->dev.parent);
> +	}
> +	spin_unlock_irqrestore(&vb->adjustment_lock, flags);
> +
> +	queue_work(system_freezable_wq, &vb->update_balloon_size_work);
> +}
> +
> +static void end_update_balloon_size(struct virtio_balloon *vb)
> +{
> +	spin_lock(&vb->adjustment_lock);
> +	if (!vb->adjustment_signal_pending && vb->adjustment_in_progress) {

How could vb->adjustment_in_progress ever not be set at this point?

> +		vb->adjustment_in_progress = false;
> +		pm_relax(vb->vdev->dev.parent);
> +	}
> +	spin_unlock(&vb->adjustment_lock);
> +}
> +

LGTM, although I wonder what happens when calling pm_stay_awake() etc. 
on a parent device that is not wakeup-even-capable?

-- 
Cheers,

David / dhildenb


  reply	other threads:[~2023-12-18 17:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-18 15:18 David Stevens
2023-12-18 17:32 ` David Hildenbrand [this message]
2023-12-19 14:37   ` David Stevens
2023-12-19 15:39     ` David Hildenbrand

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=aae229d7-0675-47c5-9a02-5ba0b6a64906@redhat.com \
    --to=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=stevensd@chromium.org \
    --cc=virtualization@lists.linux-foundation.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

all inboxes | Powered by JetHome®