virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Wang, Wei W" <wei.w.wang@intel.com>
Cc: "aarcange@redhat.com" <aarcange@redhat.com>,
	"virtio-dev@lists.oasis-open.org"
	<virtio-dev@lists.oasis-open.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"mawilcox@microsoft.com" <mawilcox@microsoft.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"amit.shah@redhat.com" <amit.shah@redhat.com>,
	"liliang.opensource@gmail.com" <liliang.opensource@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"willy@infradead.org" <willy@infradead.org>,
	"virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"yang.zhang.wz@gmail.com" <yang.zhang.wz@gmail.com>,
	"quan.xu@aliyun.com" <quan.xu@aliyun.com>,
	"cornelia.huck@de.ibm.com" <cornelia.huck@de.ibm.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	mhocko@kernel.or
Subject: Re: [PATCH v16 3/5] virtio-balloon: VIRTIO_BALLOON_F_SG
Date: Mon, 2 Oct 2017 16:44:52 +0300	[thread overview]
Message-ID: <20171002160757-mutt-send-email-mst__27995.7210565501$1506951925$gmane$org@kernel.org> (raw)
In-Reply-To: <286AC319A985734F985F78AFA26841F73931FDB5@shsmsx102.ccr.corp.intel.com>

On Mon, Oct 02, 2017 at 12:39:30PM +0000, Wang, Wei W wrote:
> On Monday, October 2, 2017 12:30 PM, Michael S. Tsirkin wrote:
> > On Sat, Sep 30, 2017 at 12:05:52PM +0800, Wei Wang wrote:
> > > +static int send_balloon_page_sg(struct virtio_balloon *vb,
> > > +				 struct virtqueue *vq,
> > > +				 void *addr,
> > > +				 uint32_t size,
> > > +				 bool batch)
> > > +{
> > > +	int err;
> > > +
> > > +	err = add_one_sg(vq, addr, size);
> > > +
> > > +	/* If batchng is requested, we batch till the vq is full */
> > 
> > typo
> > 
> > > +	if (!batch || !vq->num_free)
> > > +		kick_and_wait(vq, vb->acked);
> > > +
> > > +	return err;
> > > +}
> > 
> > If add_one_sg fails, kick_and_wait will hang forever.
> > 
> > The reason this might work in because
> > 1. with 1 sg there are no memory allocations 2. if adding fails on vq full, then
> > something
> >    is in queue and will wake up kick_and_wait.
> > 
> > So in short this is expected to never fail.
> > How about a BUG_ON here then?
> > And make it void, and add a comment with above explanation.
> > 
> 
> 
> Yes, agree that this wouldn't fail - the worker thread performing the ballooning operations has been put into sleep when the vq is full, so I think there shouldn't be anyone else to put more sgs onto the vq then.
> Btw, not sure if we need to mention memory allocation in the comment, I found virtqueue_add() doesn't return any error when allocation (for indirect desc-s) fails - it simply avoids the use of indirect desc.
> 
> What do you think of the following? 
> 
> err = add_one_sg(vq, addr, size);
> /* 
>   * This is expected to never fail: there is always at least 1 entry available on the vq,
>   * because when the vq is full the worker thread that adds the sg will be put into
>   * sleep until at least 1 entry is available to use.
>   */
> BUG_ON(err);
> 
> Best,
> Wei
> 
> 
> 
>  

Sounds good.

  parent reply	other threads:[~2017-10-02 13:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1506744354-20979-1-git-send-email-wei.w.wang@intel.com>
2017-09-30  4:05 ` [PATCH v16 1/5] lib/xbitmap: Introduce xbitmap Wei Wang
2017-09-30  4:05 ` [PATCH v16 2/5] radix tree test suite: add tests for xbitmap Wei Wang
2017-09-30  4:05 ` [PATCH v16 3/5] virtio-balloon: VIRTIO_BALLOON_F_SG Wei Wang
2017-09-30  4:05 ` [PATCH v16 4/5] mm: support reporting free page blocks Wei Wang
2017-09-30  4:05 ` [PATCH v16 5/5] virtio-balloon: VIRTIO_BALLOON_F_CTRL_VQ Wei Wang
     [not found] ` <1506744354-20979-6-git-send-email-wei.w.wang@intel.com>
2017-10-01  3:18   ` Michael S. Tsirkin
     [not found]   ` <20171001060305-mutt-send-email-mst@kernel.org>
2017-10-02 16:38     ` Wang, Wei W
     [not found]     ` <286AC319A985734F985F78AFA26841F73932025A@shsmsx102.ccr.corp.intel.com>
2017-10-10 15:15       ` Michael S. Tsirkin
     [not found]       ` <20171010180636-mutt-send-email-mst@kernel.org>
2017-10-11  6:03         ` Wei Wang
     [not found]         ` <59DDB428.4020208@intel.com>
2017-10-11 13:49           ` Michael S. Tsirkin
     [not found]           ` <20171011161912-mutt-send-email-mst@kernel.org>
2017-10-12  3:54             ` Wei Wang
     [not found]             ` <59DEE790.5040809@intel.com>
2017-10-13 13:38               ` Michael S. Tsirkin
     [not found]               ` <20171013163503-mutt-send-email-mst@kernel.org>
2017-10-19  8:07                 ` Wei Wang
2017-10-01 13:16 ` [PATCH v16 0/5] Virtio-balloon Enhancement Damian Tometzki
2017-10-01 13:25 ` Damian Tometzki
     [not found] ` <1506744354-20979-5-git-send-email-wei.w.wang@intel.com>
2017-10-03 14:50   ` [PATCH v16 4/5] mm: support reporting free page blocks Michal Hocko
     [not found] ` <1506864327.1916.3.camel@icloud.com>
2017-10-09  9:39   ` [PATCH v16 0/5] Virtio-balloon Enhancement Wei Wang
     [not found] ` <1506744354-20979-4-git-send-email-wei.w.wang@intel.com>
2017-10-02  4:30   ` [PATCH v16 3/5] virtio-balloon: VIRTIO_BALLOON_F_SG Michael S. Tsirkin
     [not found]   ` <20171002072106-mutt-send-email-mst@kernel.org>
2017-10-02 12:39     ` Wang, Wei W
     [not found]     ` <286AC319A985734F985F78AFA26841F73931FDB5@shsmsx102.ccr.corp.intel.com>
2017-10-02 13:44       ` Michael S. Tsirkin [this message]
2017-10-09 15:20   ` Michael S. Tsirkin
     [not found]   ` <20171009181612-mutt-send-email-mst@kernel.org>
2017-10-10  7:28     ` Wei Wang
     [not found]     ` <59DC76BA.7070202@intel.com>
     [not found]       ` <201710102008.FIG57851.QFJLMtVOFOHFOS@I-love.SAKURA.ne.jp>
2017-10-10 12:32         ` Wei Wang
     [not found]         ` <59DCBDE9.4050404@intel.com>
     [not found]           ` <201710102209.DBE39528.MtFLOJQSFOFVOH@I-love.SAKURA.ne.jp>
2017-10-11  1:51             ` Wei Wang
     [not found]             ` <59DD7932.3070106@intel.com>
     [not found]               ` <201710110226.v9B2QGdx019779@www262.sakura.ne.jp>
2017-10-11  3:16                 ` Wei Wang

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='20171002160757-mutt-send-email-mst__27995.7210565501$1506951925$gmane$org@kernel.org' \
    --to=mst@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=amit.shah@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=liliang.opensource@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mawilcox@microsoft.com \
    --cc=mhocko@kernel.or \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quan.xu@aliyun.com \
    --cc=virtio-dev@lists.oasis-open.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=wei.w.wang@intel.com \
    --cc=willy@infradead.org \
    --cc=yang.zhang.wz@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).