On Thu, Aug 03, 2017 at 03:17:59PM +0000, Wang, Wei W wrote:
> On Thursday, August 3, 2017 10:23 PM, Michael S. Tsirkin wrote:
> > On Thu, Aug 03, 2017 at 02:38:17PM +0800, Wei Wang wrote:
> > > +static void send_one_sg(struct virtio_balloon *vb, struct virtqueue *vq,
> > > +                 void *addr, uint32_t size)
> > > +{
> > > + struct scatterlist sg;
> > > + unsigned int len;
> > > +
> > > + sg_init_one(&sg, addr, size);
> > > + while (unlikely(virtqueue_add_inbuf(vq, &sg, 1, vb, GFP_KERNEL)
> > > +                 == -ENOSPC)) {
> > > +         /*
> > > +          * It is uncommon to see the vq is full, because the sg is sent
> > > +          * one by one and the device is able to handle it in time. But
> > > +          * if that happens, we kick and wait for an entry is released.
> > 
> > is released -> to get used.
> > 
> > > +          */
> > > +         virtqueue_kick(vq);
> > > +         while (!virtqueue_get_buf(vq, &len) &&
> > > +                !virtqueue_is_broken(vq))
> > > +                 cpu_relax();
> > 
> > Please rework to use wait_event in that case too.
> 
> For the balloon page case here, it is fine to use wait_event. But for the 
> free page
> case, I think it might not be suitable because the mm lock is being held.
> 
> Best,
> Wei

You will have to find a way to drop the lock and restart from where you
stopped then.

-- 
MST

Reply via email to