From: Tim Deegan Subject: Re: [PATCH 2 of 3] Make p2m lookups fully synchronized wrt modifications Date: Thu, 24 Nov 2011 11:35:07 +0000 Message-ID: <20111124113507.GA77868@ocelot.phlegethon.org> References: <6203a0549d8a1a21753b.1320788545@xdev.gridcentric.ca> <20111110125342.GG62117@ocelot.phlegethon.org> <4cb5acd8fa013dc40d5063d61296a319.squirrel@webmail.lagarcavilla.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <4cb5acd8fa013dc40d5063d61296a319.squirrel@webmail.lagarcavilla.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Andres Lagar-Cavilla Cc: olaf@aepfle.de, xen-devel@lists.xensource.com, george.dunlap@eu.citrix.com, andres@gridcentric.ca, keir.xen@gmail.com, adin@gridcentric.ca List-Id: xen-devel@lists.xenproject.org At 10:03 -0800 on 14 Nov (1321264988), Andres Lagar-Cavilla wrote: > Hi there, > > At 16:42 -0500 on 08 Nov (1320770545), Andres Lagar-Cavilla wrote: > >> xen/arch/x86/mm/mm-locks.h | 13 +++++++------ > >> xen/arch/x86/mm/p2m.c | 18 +++++++++++++++++- > >> xen/include/asm-x86/p2m.h | 39 > >> ++++++++++++++++++++++++--------------- > >> 3 files changed, 48 insertions(+), 22 deletions(-) > >> > >> > >> We achieve this by locking/unlocking the global p2m_lock in get/put_gfn. > >> This brings about a few consequences for the p2m_lock: > >> > >> - not ordered anymore in mm-locks.h: unshare does get_gfn -> shr_lock, > >> there are code paths that do paging_lock -> get_gfn. All of these > >> would cause mm-locks.h to panic. > > > > In that case there's a potential deadlock in the sharing code, and > > turning off the safety catches is not an acceptable response to that. :) > > > > ISTR you had a plan to get rid of the shr_lock entirely, or am > > I misremembering? > Sharing is actually fine, I can reorder those safely until I get rid of > the shr_lock. Except for sharing audits, which basically lock the whole > hypervisor, and _no one is using at all_. > > I have a more fundamental problem with the paging lock. sh_update_cr3 can > be called from a variety of situations. It will walk the four top level > PAE mappings, acquiring the p2m entry for each, with the paging lock held. > This is an inversion & deadlock, if I try to synchronize p2m lookups with > the p2m lock. Is sh_update_cr3() really called with p2m locks/refs held? Since it doesn't take a frame number as an argument it might be possible to shuffle things around at the callers. > Any suggestions here? Other than disabling ordering of the p2m lock? Disabling the ordering won't do, so we need to find something else. Tim.