public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <marcelo-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org>
To: Akio Takebe <takebe_akio-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
Cc: Marcelo Tosatti <marcelo-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org>,
	kvm-devel
	<kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: [PATCH] kvm balloon guest driver (v2)
Date: Thu, 10 Jan 2008 09:29:02 -0200	[thread overview]
Message-ID: <20080110112902.GA6729@dmt> (raw)
In-Reply-To: <F1C85358126773takebe_akio-+CUm20s59erQFUHtdCDX3A@public.gmane.org>

On Thu, Jan 10, 2008 at 04:11:51PM +0900, Akio Takebe wrote:
> Hi, Marcelo
> 
> >+struct balloon_buf *alloc_balloon_buf(struct virtio_device *vdev, gfp_t 
> >flags)
> >+{
> >+	struct balloon_buf *buf;
> >+
> >+	buf = kzalloc(sizeof(struct balloon_buf), flags);
> >+	if (!buf)
> >+		dev_printk(KERN_ERR, &vdev->dev, "%s: alloc fail\n", __func__);
> >+
> >+	return buf;
> >+}
> >+
> [snip..]
> >+static int kvm_balloon_inflate(struct virtballoon *v, int32_t npages)
> >+{
> >+	LIST_HEAD(tmp_list);
> >+	struct page *page, *tmp;
> >+	struct balloon_buf *buf;
> >+	u32 *pfn;
> >+	int allocated = 0;
> >+	int i, r = -ENOMEM;
> >+
> >+	buf = alloc_balloon_buf(v->vdev, GFP_KERNEL);
> When does balloon driver free the buf?

Hi Akio,

The buffers are passed from the virtio handling routine to the balloon_thread
through the balloon_work list, and then freed here:

+               spin_lock_irq(&v->queue_lock);
+               while (!list_empty(&v->balloon_work)) {
+                       struct balloon_work *work;
+                       struct balloon_buf *buf;
+
+                       work = list_entry(v->balloon_work.next,
+                                        struct balloon_work, list);
+                       list_del(&work->list);
+                       spin_unlock_irq(&v->queue_lock);
+                       buf = work->buf;
+                       kfree(work);
+
+                       switch(buf->hdr.cmd) {
+                       case CMD_BALLOON_DEFLATE:
+                               deflate_done(v, buf);
+                               break;
+                       case CMD_BALLOON_INFLATE:
+                               inflate_done(v, buf);
+                               break;
+                       default:
+                               printk("%s: unknown cmd 0x%x\n", __func__,
+                                       buf->hdr.cmd);
+                       }
+                       kfree(buf);


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

  parent reply	other threads:[~2008-01-10 11:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-09 18:14 [PATCH] kvm balloon guest driver (v2) Marcelo Tosatti
2008-01-10  7:11 ` Akio Takebe
     [not found]   ` <F1C85358126773takebe_akio-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-01-10 11:29     ` Marcelo Tosatti [this message]
2008-01-10 12:27       ` Akio Takebe
     [not found]         ` <F7C853842F97FDtakebe_akio-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-01-10 13:11           ` Dor Laor

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=20080110112902.GA6729@dmt \
    --to=marcelo-bw31mazkks3ytjvyw6ydsg@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=takebe_akio-+CUm20s59erQFUHtdCDX3A@public.gmane.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