[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <200912141456.03033.rusty@rustcorp.com.au>
Date: Mon, 14 Dec 2009 14:56:02 +1030
From: Rusty Russell <rusty@...tcorp.com.au>
To: Adam Litke <agl@...ibm.com>
Cc: Anthony Liguori <aliguori@...ux.vnet.ibm.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] virtio: Fix scheduling while atomic in virtio_balloon stats
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists