public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Adam Litke <agl@us.ibm.com>
Cc: Anthony Liguori <aliguori@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] virtio: Fix scheduling while atomic in virtio_balloon stats
Date: Mon, 14 Dec 2009 14:56:02 +1030	[thread overview]
Message-ID: <200912141456.03033.rusty@rustcorp.com.au> (raw)
In-Reply-To: <1260484515.4860.2.camel@aglitke>

On Fri, 11 Dec 2009 09:05:15 am Adam Litke wrote:
> [PATCH] virtio: Fix scheduling while atomic in virtio_balloon stats
> 
> This is a fix for my earlier patch: "virtio: Add memory statistics reporting to
> the balloon driver (V4)".
> 
> I discovered that all_vm_events() can sleep and therefore stats collection
> cannot be done in interrupt context.  One solution is to handle the interrupt
> by noting that stats need to be collected and waking the existing vballoon
> kthread which will complete the work via stats_handle_request().  Rusty, is
> this a saner way of doing business?

I think so.

> There is one issue that I would like a broader opinion on.  In stats_request, I
> update vb->need_stats_update and then wake up the kthread.  The kthread uses
> vb->need_stats_update as a condition variable.  Do I need a memory barrier
> between the update and wake_up to ensure that my kthread sees the correct
> value?  My testing suggests that it is not needed but I would like some
> confirmation from the experts.

Yep:

 * It may be assumed that this function implies a write memory barrier before
 * changing the task state if and only if any tasks are woken up.

> +static void stats_handle_request(struct virtio_balloon *vb)
> +{
> +	struct virtqueue *vq;
> +	struct scatterlist sg;
>  
> +	vb->need_stats_update = 0;
>  	update_balloon_stats(vb);

And this works without a barrier because they can't make another request
before we finish with this one.

Applied,
Rusty.


      reply	other threads:[~2009-12-14  4:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-10 22:35 [PATCH] virtio: Fix scheduling while atomic in virtio_balloon stats Adam Litke
2009-12-14  4:26 ` Rusty Russell [this message]

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=200912141456.03033.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=agl@us.ibm.com \
    --cc=aliguori@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.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