From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N6BvC-0002qq-HZ for qemu-devel@nongnu.org; Thu, 05 Nov 2009 18:39:18 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N6Bv8-0002lJ-MV for qemu-devel@nongnu.org; Thu, 05 Nov 2009 18:39:18 -0500 Received: from [199.232.76.173] (port=40412 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N6Bv8-0002kl-C1 for qemu-devel@nongnu.org; Thu, 05 Nov 2009 18:39:14 -0500 Received: from e35.co.us.ibm.com ([32.97.110.153]:40699) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N6Bv7-0002vT-Kx for qemu-devel@nongnu.org; Thu, 05 Nov 2009 18:39:13 -0500 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by e35.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id nA5NRkU7012261 for ; Thu, 5 Nov 2009 16:27:46 -0700 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id nA5NdBAB141788 for ; Thu, 5 Nov 2009 16:39:11 -0700 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id nA5NdAbs010393 for ; Thu, 5 Nov 2009 16:39:11 -0700 Message-ID: <4AF3621D.1080401@us.ibm.com> Date: Thu, 05 Nov 2009 17:39:09 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1257461425.3121.22.camel@aglitke> <1257462155.3121.25.camel@aglitke> In-Reply-To: <1257462155.3121.25.camel@aglitke> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: virtio: Add memory statistics reporting to the balloon driver List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: agl@linux.vnet.ibm.com Cc: Rusty Russell , qemu-devel@nongnu.org, virtualization agl@linux.vnet.ibm.com wrote: > Here are the corresponding changes to the Linux virtio driver... > > virtio: Add memory statistics reporting to the balloon driver > > When using ballooning to manage overcommitted memory on a host, a system for > guests to communicate their memory usage to the host can provide information > that will minimize the impact of ballooning on the guests. The current method > employs a daemon running in each guest that communicates memory statistics to a > host daemon at a specified time interval. The host daemon aggregates this > information and inflates and/or deflates balloons according to the level of > host memory pressure. This approach is effective but overly complex since a > daemon must be installed inside each guest and coordinated to communicate with > the host. A simpler approach is to collect memory statistics in the virtio > balloon driver and communicate them to the host via the device config space. > > This patch enables the guest-side support by adding stats collection and > reporting to the virtio balloon driver. > > Signed-off-by: Adam Litke > > diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c > index 3a43ebf..1029363 100644 > --- a/drivers/virtio/virtio.c > +++ b/drivers/virtio/virtio.c > @@ -135,6 +135,7 @@ static int virtio_dev_probe(struct device *_d) > set_bit(i, dev->features); > > dev->config->finalize_features(dev); > + printk("virtio_dev_probe: final features = %lx\n", dev->features[0]); > Looks like leftover debugging. > err = drv->probe(dev); > if (err) > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c > index 200c22f..77cb953 100644 > --- a/drivers/virtio/virtio_balloon.c > +++ b/drivers/virtio/virtio_balloon.c > @@ -180,6 +180,45 @@ static void update_balloon_size(struct virtio_balloon *vb) > &actual, sizeof(actual)); > } > > +static inline void update_stat(struct virtio_device *vdev, int feature, > + unsigned long value, unsigned offset) > +{ > + if (virtio_has_feature(vdev, feature)) { > + vdev->config->set(vdev, offset, &value, sizeof(value)); > I think this bit assumes a little endian guest. We shouldn't make that assumption. For virtio kernel patches, please CC the virtualization list and Rusty as he's the maintainer. It wouldn't hurt to CC lkml either. -- Regards, Anthony Liguori