Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751719AbdHCPSG convert rfc822-to-8bit (ORCPT ); Thu, 3 Aug 2017 11:18:06 -0400 Received: from mga02.intel.com ([134.134.136.20]:56817 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751010AbdHCPSE (ORCPT ); Thu, 3 Aug 2017 11:18:04 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,316,1498546800"; d="scan'208";a="1158720880" From: "Wang, Wei W" To: "Michael S. Tsirkin" 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 Thread-Topic: [PATCH v13 3/5] virtio-balloon: VIRTIO_BALLOON_F_SG Thread-Index: AQHTDGP/cC69sR2F6UKGvsT//abpQKJyvY5g Date: Thu, 3 Aug 2017 15:17:59 +0000 Message-ID: <286AC319A985734F985F78AFA26841F73928C952@shsmsx102.ccr.corp.intel.com> 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> In-Reply-To: <20170803151212-mutt-send-email-mst@kernel.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTY4NWRiNjgtNTYxNC00NDE4LThmZWItMzY2NDY2MDcwZTBkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Im9YVEdGVloyWG9BNitCd294b25PWjg0KzN2RHFQS3FUYVc1OGpIUG9sZlU9In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1059 Lines: 31 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