From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754148AbbFSH4L (ORCPT ); Fri, 19 Jun 2015 03:56:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53084 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751507AbbFSH4G (ORCPT ); Fri, 19 Jun 2015 03:56:06 -0400 Date: Fri, 19 Jun 2015 09:56:02 +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: <20150619095515-mutt-send-email-mst@redhat.com> References: <20150617182917-mutt-send-email-mst@redhat.com> <20150618111224.0aa6dff7@nial.brq.redhat.com> <20150618112004-mutt-send-email-mst@redhat.com> <20150618133912.63636a47@nial.brq.redhat.com> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5582EBA6.1080607@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 18, 2015 at 06:02:46PM +0200, Paolo Bonzini wrote: > > > On 18/06/2015 16:47, Michael S. Tsirkin wrote: > >> However, with Igor's patches a memory_region_del_subregion will cause a > >> mmap(MAP_NORESERVE), which _does_ have the effect of making the hva go away. > >> > >> I guess one way to do it would be to alias the same page in two places, > >> one for use by vhost and one for use by everything else. However, the > >> kernel does not provide the means to do this kind of aliasing for > >> anonymous mmaps. > > > > Basically pages go away on munmap, so won't simple > > lock > > munmap > > mmap(MAP_NORESERVE) > > unlock > > do the trick? > > Not sure I follow. Here we have this: > > VCPU 1 VCPU 2 I/O worker > ---------------------------------------------------------------------------------------- > take big QEMU lock > p = address_space_map(hva, len) > pass I/O request to worker thread > read(fd, p, len) > release big QEMU lock > > memory_region_del_subregion > mmap(MAP_NORESERVE) > > read returns EFAULT Why doesn't it EFAULT without mmap(MAP_NORESERVE)? Doesn't memory_region_del_subregion free the memory? > wake up VCPU 1 > take big QEMU lock > EFAULT? What's that? > > In another scenario you are less lucky: the memory accesses > between address_space_map/unmap aren't done in the kernel and > you get a plain old SIGSEGV. > > This is not something that you can fix with a lock. The very > purpose of the map/unmap API is to do stuff asynchronously while > the lock is released. > > Thanks, > > Paolo