Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751940AbdHCP4C (ORCPT ); Thu, 3 Aug 2017 11:56:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54126 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751963AbdHCPz6 (ORCPT ); Thu, 3 Aug 2017 11:55:58 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C0BC180F97 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=mst@redhat.com Date: Thu, 3 Aug 2017 18:55:50 +0300 From: "Michael S. Tsirkin" To: "Wang, Wei W" Cc: "linux-kernel@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "kvm@vger.kernel.org" , "linux-mm@kvack.org" , "mhocko@kernel.org" , "mawilcox@microsoft.com" , "akpm@linux-foundation.org" , "virtio-dev@lists.oasis-open.org" , "david@redhat.com" , "cornelia.huck@de.ibm.com" , "mgorman@techsingularity.net" , "aarcange@redhat.com" , "amit.shah@redhat.com" , "pbonzini@redhat.com" , "liliang.opensource@gmail.com" , "yang.zhang.wz@gmail.com" , "quan.xu@aliyun.com" Subject: Re: [PATCH v13 3/5] virtio-balloon: VIRTIO_BALLOON_F_SG Message-ID: <20170803185508-mutt-send-email-mst@kernel.org> References: <1501742299-4369-1-git-send-email-wei.w.wang@intel.com> <1501742299-4369-4-git-send-email-wei.w.wang@intel.com> <20170803151212-mutt-send-email-mst@kernel.org> <286AC319A985734F985F78AFA26841F73928C952@shsmsx102.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <286AC319A985734F985F78AFA26841F73928C952@shsmsx102.ccr.corp.intel.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 03 Aug 2017 15:55:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1278 Lines: 38 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