From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754576AbbFSQpK (ORCPT ); Fri, 19 Jun 2015 12:45:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50377 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754115AbbFSQpD (ORCPT ); Fri, 19 Jun 2015 12:45:03 -0400 Date: Fri, 19 Jun 2015 18:45:00 +0200 From: "Michael S. Tsirkin" To: Paolo Bonzini Cc: Igor Mammedov , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, andrey@xdel.ru Subject: Re: [PATCH 3/5] vhost: support upto 509 memory regions Message-ID: <20150619184220-mutt-send-email-mst@redhat.com> References: <20150618134040-mutt-send-email-mst@redhat.com> <5582B088.1090207@redhat.com> <20150618142455-mutt-send-email-mst@redhat.com> <5582CBA6.5070105@redhat.com> <20150618164559-mutt-send-email-mst@redhat.com> <5582EBA6.1080607@redhat.com> <20150619095515-mutt-send-email-mst@redhat.com> <5583CB62.6030405@redhat.com> <20150619100409-mutt-send-email-mst@redhat.com> <5583D85F.7090200@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5583D85F.7090200@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 19, 2015 at 10:52:47AM +0200, Paolo Bonzini wrote: > > > On 19/06/2015 10:05, Michael S. Tsirkin wrote: > > > No, only destruction of the memory region frees it. address_space_map > > > takes a reference to the memory region and address_space_unmap releases it. > > > > > > Paolo > > > > Confused. So can we call mmap(MAP_NORESERVE) in address_space_unmap > > after we detect refcount is 0? > > No, because in the meanwhile another DIMM could have been hotplugged > at the same place where the old one was. This is legal: > > user guest QEMU > ---------------------------------------------------------------------------------------- > start I/O > '---------------> address_space_map > device_del > '-------------------> receives SCI > executes _EJ0 > '---------------> memory_region_del_subregion > object_unparent > device_add > '-----------------------------------------> device_set_realized > hotplug_handler_plug > pc_machine_device_plug_cb > pc_dimm_plug > memory_region_add_subregion > > I/O finishes > address_space_unmap > > Surprise removal similarly could be done in QEMU, but it will hold to > some resources for as long as the device backends need them. > > Paolo OK so what's the problem with checking for this condition, after address_space_unmap detects that ref count is 0 and before calling mmap(MAP_NORESERVE)? At that point we are off the data path so we can take locks. -- MST -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/ From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH 3/5] vhost: support upto 509 memory regions Date: Fri, 19 Jun 2015 18:45:00 +0200 Message-ID: <20150619184220-mutt-send-email-mst@redhat.com> References: <20150618134040-mutt-send-email-mst@redhat.com> <5582B088.1090207@redhat.com> <20150618142455-mutt-send-email-mst@redhat.com> <5582CBA6.5070105@redhat.com> <20150618164559-mutt-send-email-mst@redhat.com> <5582EBA6.1080607@redhat.com> <20150619095515-mutt-send-email-mst@redhat.com> <5583CB62.6030405@redhat.com> <20150619100409-mutt-send-email-mst@redhat.com> <5583D85F.7090200@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Igor Mammedov , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, andrey@xdel.ru To: Paolo Bonzini Return-path: Content-Disposition: inline In-Reply-To: <5583D85F.7090200@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Fri, Jun 19, 2015 at 10:52:47AM +0200, Paolo Bonzini wrote: > > > On 19/06/2015 10:05, Michael S. Tsirkin wrote: > > > No, only destruction of the memory region frees it. address_space_map > > > takes a reference to the memory region and address_space_unmap releases it. > > > > > > Paolo > > > > Confused. So can we call mmap(MAP_NORESERVE) in address_space_unmap > > after we detect refcount is 0? > > No, because in the meanwhile another DIMM could have been hotplugged > at the same place where the old one was. This is legal: > > user guest QEMU > ---------------------------------------------------------------------------------------- > start I/O > '---------------> address_space_map > device_del > '-------------------> receives SCI > executes _EJ0 > '---------------> memory_region_del_subregion > object_unparent > device_add > '-----------------------------------------> device_set_realized > hotplug_handler_plug > pc_machine_device_plug_cb > pc_dimm_plug > memory_region_add_subregion > > I/O finishes > address_space_unmap > > Surprise removal similarly could be done in QEMU, but it will hold to > some resources for as long as the device backends need them. > > Paolo OK so what's the problem with checking for this condition, after address_space_unmap detects that ref count is 0 and before calling mmap(MAP_NORESERVE)? At that point we are off the data path so we can take locks. -- MST