From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:49516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qxfqn-000580-K1 for qemu-devel@nongnu.org; Sun, 28 Aug 2011 09:56:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qxfqm-0007bN-ON for qemu-devel@nongnu.org; Sun, 28 Aug 2011 09:56:37 -0400 Received: from 8bytes.org ([88.198.83.132]:53993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qxfqm-0007aj-FK for qemu-devel@nongnu.org; Sun, 28 Aug 2011 09:56:36 -0400 Date: Sun, 28 Aug 2011 15:56:33 +0200 From: Joerg Roedel Message-ID: <20110828135632.GG8978@8bytes.org> References: <1314040622.6866.268.camel@x201.home> <20110823131441.GN2079@amd.com> <1314119311.2859.59.camel@bling.home> <20110824085213.GB2079@amd.com> <1314198467.2859.192.camel@bling.home> <20110825123146.GD1923@amd.com> <20110826042423.GF2308@yookeroo.fritz.box> <20110826092440.GO1923@amd.com> <4E5A3F18.7050903@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4E5A3F18.7050903@redhat.com> Subject: Re: [Qemu-devel] kvm PCI assignment & VFIO ramblings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Alex Williamson , Alexey Kardashevskiy , "kvm@vger.kernel.org" , Paul Mackerras , "Roedel, Joerg" , qemu-devel , Alexander Graf , chrisw , iommu , "linux-pci@vger.kernel.org" , linuxppc-dev , "benve@cisco.com" On Sun, Aug 28, 2011 at 04:14:00PM +0300, Avi Kivity wrote: > On 08/26/2011 12:24 PM, Roedel, Joerg wrote: >> The biggest problem with this approach is that it has to happen in the >> context of the given process. Linux can't really modify an mm which >> which belong to another context in a safe way. >> > > Is use_mm() insufficient? Yes, it introduces a set of race conditions when a process that already has an mm wants to take over another processes mm temporarily (and when use_mm is modified to actually provide this functionality). It is only save when used from kernel-thread context. One example: Process A Process B Process C . . . . <-- takes A->mm . . and assignes as B->mm . . . --> Wants to take . . B->mm, but gets A->mm now This can't be secured by a lock, because it introduces potential A->B<-->B->A lock problem when two processes try to take each others mm. It could probably be solved by a task->real_mm pointer, havn't thought about this yet... Joerg