From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: virtio-dev-return-2657-cohuck=redhat.com@lists.oasis-open.org Sender: List-Post: List-Help: List-Unsubscribe: List-Subscribe: Received: from lists.oasis-open.org (oasis-open.org [66.179.20.138]) by lists.oasis-open.org (Postfix) with ESMTP id BA0B85818CA4 for ; Sat, 4 Nov 2017 04:07:14 -0700 (PDT) Message-ID: <59FD9FE3.5090409@intel.com> Date: Sat, 04 Nov 2017 19:09:23 +0800 From: Wei Wang MIME-Version: 1.0 References: <1509696786-1597-1-git-send-email-wei.w.wang@intel.com> <1509696786-1597-5-git-send-email-wei.w.wang@intel.com> <201711032025.HJC78622.SFFOMLOtFQHVJO@I-love.SAKURA.ne.jp> In-Reply-To: <201711032025.HJC78622.SFFOMLOtFQHVJO@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: [virtio-dev] Re: [PATCH v17 4/6] virtio-balloon: VIRTIO_BALLOON_F_SG To: Tetsuo Handa , virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com, mhocko@kernel.org, akpm@linux-foundation.org, mawilcox@microsoft.com Cc: david@redhat.com, cornelia.huck@de.ibm.com, mgorman@techsingularity.net, aarcange@redhat.com, amit.shah@redhat.com, pbonzini@redhat.com, willy@infradead.org, liliang.opensource@gmail.com, yang.zhang.wz@gmail.com, quan.xu@aliyun.com List-ID: On 11/03/2017 07:25 PM, Tetsuo Handa wrote: > Wei Wang wrote: >> @@ -164,6 +284,8 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) >> break; >> } >> >> + if (use_sg && xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) > Isn't this leaking "page" ? Right, thanks, will add __free_page(page) here. >> @@ -184,8 +307,12 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) >> >> num_allocated_pages = vb->num_pfns; >> /* Did we get any? */ >> - if (vb->num_pfns != 0) >> - tell_host(vb, vb->inflate_vq); >> + if (vb->num_pfns) { >> + if (use_sg) >> + tell_host_sgs(vb, vb->inflate_vq, pfn_min, pfn_max); > Please describe why tell_host_sgs() can work without __GFP_DIRECT_RECLAIM allocation, > for tell_host_sgs() is called with vb->balloon_lock mutex held. Essentially, tell_host_sgs()-->send_balloon_page_sg()-->add_one_sg()-->virtqueue_add_inbuf( , , num=1 ,,GFP_KERNEL) won't need any memory allocation, because we always add one sg (i.e. num=1) each time. That memory allocation option is only used when multiple sgs are added (i.e. num > 1) and the implementation inside virtqueue_add_inbuf need allocation of indirect descriptor table. We could also add some comments above the function to explain a little about this if necessary. > > >> @@ -223,7 +353,13 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num) >> page = balloon_page_dequeue(vb_dev_info); >> if (!page) >> break; >> - set_page_pfns(vb, vb->pfns + vb->num_pfns, page); >> + if (use_sg) { >> + if (xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) > Isn't this leaking "page" ? Yes, will make it: if (xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) { balloon_page_enqueue(..., page); break; } > > If this is inside vb->balloon_lock mutex (isn't this?), xb_set_page() must not > use __GFP_DIRECT_RECLAIM allocation, for leak_balloon_sg_oom() will be blocked > on vb->balloon_lock mutex. OK. Since the preload() doesn't need too much memory (< 4K in total), how about GFP_NOWAIT here? Best, Wei --------------------------------------------------------------------- To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang Subject: Re: [PATCH v17 4/6] virtio-balloon: VIRTIO_BALLOON_F_SG Date: Sat, 04 Nov 2017 19:09:23 +0800 Message-ID: <59FD9FE3.5090409@intel.com> References: <1509696786-1597-1-git-send-email-wei.w.wang@intel.com> <1509696786-1597-5-git-send-email-wei.w.wang@intel.com> <201711032025.HJC78622.SFFOMLOtFQHVJO@I-love.SAKURA.ne.jp> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <201711032025.HJC78622.SFFOMLOtFQHVJO@I-love.SAKURA.ne.jp> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: Tetsuo Handa , virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com, mhocko@kernel.org, akpm@linux-foundation.org, mawilcox@microsoft.com Cc: aarcange@redhat.com, yang.zhang.wz@gmail.com, liliang.opensource@gmail.com, willy@infradead.org, amit.shah@redhat.com, quan.xu@aliyun.com, cornelia.huck@de.ibm.com, pbonzini@redhat.com, mgorman@techsingularity.net List-Id: virtualization@lists.linuxfoundation.org On 11/03/2017 07:25 PM, Tetsuo Handa wrote: > Wei Wang wrote: >> @@ -164,6 +284,8 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) >> break; >> } >> >> + if (use_sg && xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) > Isn't this leaking "page" ? Right, thanks, will add __free_page(page) here. >> @@ -184,8 +307,12 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) >> >> num_allocated_pages = vb->num_pfns; >> /* Did we get any? */ >> - if (vb->num_pfns != 0) >> - tell_host(vb, vb->inflate_vq); >> + if (vb->num_pfns) { >> + if (use_sg) >> + tell_host_sgs(vb, vb->inflate_vq, pfn_min, pfn_max); > Please describe why tell_host_sgs() can work without __GFP_DIRECT_RECLAIM allocation, > for tell_host_sgs() is called with vb->balloon_lock mutex held. Essentially, tell_host_sgs()-->send_balloon_page_sg()-->add_one_sg()-->virtqueue_add_inbuf( , , num=1 ,,GFP_KERNEL) won't need any memory allocation, because we always add one sg (i.e. num=1) each time. That memory allocation option is only used when multiple sgs are added (i.e. num > 1) and the implementation inside virtqueue_add_inbuf need allocation of indirect descriptor table. We could also add some comments above the function to explain a little about this if necessary. > > >> @@ -223,7 +353,13 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num) >> page = balloon_page_dequeue(vb_dev_info); >> if (!page) >> break; >> - set_page_pfns(vb, vb->pfns + vb->num_pfns, page); >> + if (use_sg) { >> + if (xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) > Isn't this leaking "page" ? Yes, will make it: if (xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) { balloon_page_enqueue(..., page); break; } > > If this is inside vb->balloon_lock mutex (isn't this?), xb_set_page() must not > use __GFP_DIRECT_RECLAIM allocation, for leak_balloon_sg_oom() will be blocked > on vb->balloon_lock mutex. OK. Since the preload() doesn't need too much memory (< 4K in total), how about GFP_NOWAIT here? Best, Wei From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id E00B46B0033 for ; Sat, 4 Nov 2017 07:07:16 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id x7so5388539pfa.19 for ; Sat, 04 Nov 2017 04:07:16 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com. [134.134.136.31]) by mx.google.com with ESMTPS id r17si8244616pgd.673.2017.11.04.04.07.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Nov 2017 04:07:13 -0700 (PDT) Message-ID: <59FD9FE3.5090409@intel.com> Date: Sat, 04 Nov 2017 19:09:23 +0800 From: Wei Wang MIME-Version: 1.0 Subject: Re: [PATCH v17 4/6] virtio-balloon: VIRTIO_BALLOON_F_SG References: <1509696786-1597-1-git-send-email-wei.w.wang@intel.com> <1509696786-1597-5-git-send-email-wei.w.wang@intel.com> <201711032025.HJC78622.SFFOMLOtFQHVJO@I-love.SAKURA.ne.jp> In-Reply-To: <201711032025.HJC78622.SFFOMLOtFQHVJO@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Tetsuo Handa , virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com, mhocko@kernel.org, akpm@linux-foundation.org, mawilcox@microsoft.com Cc: david@redhat.com, cornelia.huck@de.ibm.com, mgorman@techsingularity.net, aarcange@redhat.com, amit.shah@redhat.com, pbonzini@redhat.com, willy@infradead.org, liliang.opensource@gmail.com, yang.zhang.wz@gmail.com, quan.xu@aliyun.com On 11/03/2017 07:25 PM, Tetsuo Handa wrote: > Wei Wang wrote: >> @@ -164,6 +284,8 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) >> break; >> } >> >> + if (use_sg && xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) > Isn't this leaking "page" ? Right, thanks, will add __free_page(page) here. >> @@ -184,8 +307,12 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) >> >> num_allocated_pages = vb->num_pfns; >> /* Did we get any? */ >> - if (vb->num_pfns != 0) >> - tell_host(vb, vb->inflate_vq); >> + if (vb->num_pfns) { >> + if (use_sg) >> + tell_host_sgs(vb, vb->inflate_vq, pfn_min, pfn_max); > Please describe why tell_host_sgs() can work without __GFP_DIRECT_RECLAIM allocation, > for tell_host_sgs() is called with vb->balloon_lock mutex held. Essentially, tell_host_sgs()-->send_balloon_page_sg()-->add_one_sg()-->virtqueue_add_inbuf( , , num=1 ,,GFP_KERNEL) won't need any memory allocation, because we always add one sg (i.e. num=1) each time. That memory allocation option is only used when multiple sgs are added (i.e. num > 1) and the implementation inside virtqueue_add_inbuf need allocation of indirect descriptor table. We could also add some comments above the function to explain a little about this if necessary. > > >> @@ -223,7 +353,13 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num) >> page = balloon_page_dequeue(vb_dev_info); >> if (!page) >> break; >> - set_page_pfns(vb, vb->pfns + vb->num_pfns, page); >> + if (use_sg) { >> + if (xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) > Isn't this leaking "page" ? Yes, will make it: if (xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) { balloon_page_enqueue(..., page); break; } > > If this is inside vb->balloon_lock mutex (isn't this?), xb_set_page() must not > use __GFP_DIRECT_RECLAIM allocation, for leak_balloon_sg_oom() will be blocked > on vb->balloon_lock mutex. OK. Since the preload() doesn't need too much memory (< 4K in total), how about GFP_NOWAIT here? Best, Wei -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756660AbdKDLHP (ORCPT ); Sat, 4 Nov 2017 07:07:15 -0400 Received: from mga02.intel.com ([134.134.136.20]:26718 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751400AbdKDLHN (ORCPT ); Sat, 4 Nov 2017 07:07:13 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,341,1505804400"; d="scan'208";a="1033432908" Message-ID: <59FD9FE3.5090409@intel.com> Date: Sat, 04 Nov 2017 19:09:23 +0800 From: Wei Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Tetsuo Handa , virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com, mhocko@kernel.org, akpm@linux-foundation.org, mawilcox@microsoft.com CC: david@redhat.com, cornelia.huck@de.ibm.com, mgorman@techsingularity.net, aarcange@redhat.com, amit.shah@redhat.com, pbonzini@redhat.com, willy@infradead.org, liliang.opensource@gmail.com, yang.zhang.wz@gmail.com, quan.xu@aliyun.com Subject: Re: [PATCH v17 4/6] virtio-balloon: VIRTIO_BALLOON_F_SG References: <1509696786-1597-1-git-send-email-wei.w.wang@intel.com> <1509696786-1597-5-git-send-email-wei.w.wang@intel.com> <201711032025.HJC78622.SFFOMLOtFQHVJO@I-love.SAKURA.ne.jp> In-Reply-To: <201711032025.HJC78622.SFFOMLOtFQHVJO@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/03/2017 07:25 PM, Tetsuo Handa wrote: > Wei Wang wrote: >> @@ -164,6 +284,8 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) >> break; >> } >> >> + if (use_sg && xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) > Isn't this leaking "page" ? Right, thanks, will add __free_page(page) here. >> @@ -184,8 +307,12 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) >> >> num_allocated_pages = vb->num_pfns; >> /* Did we get any? */ >> - if (vb->num_pfns != 0) >> - tell_host(vb, vb->inflate_vq); >> + if (vb->num_pfns) { >> + if (use_sg) >> + tell_host_sgs(vb, vb->inflate_vq, pfn_min, pfn_max); > Please describe why tell_host_sgs() can work without __GFP_DIRECT_RECLAIM allocation, > for tell_host_sgs() is called with vb->balloon_lock mutex held. Essentially, tell_host_sgs()-->send_balloon_page_sg()-->add_one_sg()-->virtqueue_add_inbuf( , , num=1 ,,GFP_KERNEL) won't need any memory allocation, because we always add one sg (i.e. num=1) each time. That memory allocation option is only used when multiple sgs are added (i.e. num > 1) and the implementation inside virtqueue_add_inbuf need allocation of indirect descriptor table. We could also add some comments above the function to explain a little about this if necessary. > > >> @@ -223,7 +353,13 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num) >> page = balloon_page_dequeue(vb_dev_info); >> if (!page) >> break; >> - set_page_pfns(vb, vb->pfns + vb->num_pfns, page); >> + if (use_sg) { >> + if (xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) > Isn't this leaking "page" ? Yes, will make it: if (xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) { balloon_page_enqueue(..., page); break; } > > If this is inside vb->balloon_lock mutex (isn't this?), xb_set_page() must not > use __GFP_DIRECT_RECLAIM allocation, for leak_balloon_sg_oom() will be blocked > on vb->balloon_lock mutex. OK. Since the preload() doesn't need too much memory (< 4K in total), how about GFP_NOWAIT here? Best, Wei From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAwII-0004n7-Vq for qemu-devel@nongnu.org; Sat, 04 Nov 2017 07:07:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eAwIF-0006RL-Qw for qemu-devel@nongnu.org; Sat, 04 Nov 2017 07:07:18 -0400 Received: from mga04.intel.com ([192.55.52.120]:7404) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eAwIF-0006Ql-HB for qemu-devel@nongnu.org; Sat, 04 Nov 2017 07:07:15 -0400 Message-ID: <59FD9FE3.5090409@intel.com> Date: Sat, 04 Nov 2017 19:09:23 +0800 From: Wei Wang MIME-Version: 1.0 References: <1509696786-1597-1-git-send-email-wei.w.wang@intel.com> <1509696786-1597-5-git-send-email-wei.w.wang@intel.com> <201711032025.HJC78622.SFFOMLOtFQHVJO@I-love.SAKURA.ne.jp> In-Reply-To: <201711032025.HJC78622.SFFOMLOtFQHVJO@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v17 4/6] virtio-balloon: VIRTIO_BALLOON_F_SG List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tetsuo Handa , virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com, mhocko@kernel.org, akpm@linux-foundation.org, mawilcox@microsoft.com Cc: david@redhat.com, cornelia.huck@de.ibm.com, mgorman@techsingularity.net, aarcange@redhat.com, amit.shah@redhat.com, pbonzini@redhat.com, willy@infradead.org, liliang.opensource@gmail.com, yang.zhang.wz@gmail.com, quan.xu@aliyun.com On 11/03/2017 07:25 PM, Tetsuo Handa wrote: > Wei Wang wrote: >> @@ -164,6 +284,8 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) >> break; >> } >> >> + if (use_sg && xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) > Isn't this leaking "page" ? Right, thanks, will add __free_page(page) here. >> @@ -184,8 +307,12 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) >> >> num_allocated_pages = vb->num_pfns; >> /* Did we get any? */ >> - if (vb->num_pfns != 0) >> - tell_host(vb, vb->inflate_vq); >> + if (vb->num_pfns) { >> + if (use_sg) >> + tell_host_sgs(vb, vb->inflate_vq, pfn_min, pfn_max); > Please describe why tell_host_sgs() can work without __GFP_DIRECT_RECLAIM allocation, > for tell_host_sgs() is called with vb->balloon_lock mutex held. Essentially, tell_host_sgs()-->send_balloon_page_sg()-->add_one_sg()-->virtqueue_add_inbuf( , , num=1 ,,GFP_KERNEL) won't need any memory allocation, because we always add one sg (i.e. num=1) each time. That memory allocation option is only used when multiple sgs are added (i.e. num > 1) and the implementation inside virtqueue_add_inbuf need allocation of indirect descriptor table. We could also add some comments above the function to explain a little about this if necessary. > > >> @@ -223,7 +353,13 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num) >> page = balloon_page_dequeue(vb_dev_info); >> if (!page) >> break; >> - set_page_pfns(vb, vb->pfns + vb->num_pfns, page); >> + if (use_sg) { >> + if (xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) > Isn't this leaking "page" ? Yes, will make it: if (xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) { balloon_page_enqueue(..., page); break; } > > If this is inside vb->balloon_lock mutex (isn't this?), xb_set_page() must not > use __GFP_DIRECT_RECLAIM allocation, for leak_balloon_sg_oom() will be blocked > on vb->balloon_lock mutex. OK. Since the preload() doesn't need too much memory (< 4K in total), how about GFP_NOWAIT here? Best, Wei