[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Xen-devel] [PATCH 1 of 3] x86/mm: Relieve contention for p2m lock in gva_to_gfn
- To: "Tim Deegan" <tim@xxxxxxx>
- From: "Andres Lagar-Cavilla" <andres@xxxxxxxxxxxxxxxx>
- Date: Wed, 25 Apr 2012 08:33:31 -0700
- Cc: "Zhang, Yang Z" <yang.z.zhang@xxxxxxxxx>, andres@xxxxxxxxxxxxxx, keir@xxxxxxx, xen-devel@xxxxxxxxxxxxx
- Delivery-date: Wed, 25 Apr 2012 15:33:54 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=lagarcavilla.org; h= message-id:in-reply-to:references:date:subject:from:to:cc :reply-to:mime-version:content-type:content-transfer-encoding; s=lagarcavilla.org; bh=jomk5MDNK8vY3Fgun8ZSXnq+SuA=; b=MDVeaehS +fZN9uzZq8YLxjZ7p+SRVvnQCJx4BVqFrZEBkmsGa6Ai61T2/Hz8cv5UObMLdEtU +SsP6ClT/O1jRRhxUDYMUwg6VNck0AI2jmR6laEapvNTwoN4YFixu8yn9LFDXrd4 OjSVJKuXeqXI498FmC2J7nDIFQRYJ/o5mYE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=lagarcavilla.org; h=message-id :in-reply-to:references:date:subject:from:to:cc:reply-to :mime-version:content-type:content-transfer-encoding; q=dns; s= lagarcavilla.org; b=dBECX+ndYjkTDe4EinMG6fbwFCUNimFMGzAleDqIBHrW i4nPSvZq9jYC+a4BIOzf2w8WN6Tfb1kTmxog40viH/YfJ3iPzwgXDKngchE1nHzr QF9rW1cUuWHEd17I8o50t+IHlGOKcq0I4c2xuFwAScBFfBDOxsbk1nGXhG1p4/Y=
- List-id: Xen developer discussion <xen-devel.lists.xen.org>
> At 15:34 -0400 on 24 Apr (1335281651), Andres Lagar-Cavilla wrote:
>> xen/arch/x86/mm/hap/guest_walk.c | 6 +++++-
>> 1 files changed, 5 insertions(+), 1 deletions(-)
>> We don't need to hold the p2m lock for the duration of the guest walk.
>> We need
>> to ensure livenes of the top level page.
> I'm not sure I want to start taking these s/gfn-lock/get-page/ changes
> piecemeal without a clear understanding of why the gfn-locking is not
> needed. My understanding was that
> - get_page protects against the page being freed and reused.
> - gfn-lock protects against the GFN being reused, or the page
> being reused within the VM.
Most cases gfn_lock protects against are already taken care of by the end
of a query. From there on, get_page will protect you against paging out.
gfn_lock will further protect the caller from the gfn being replaced. That
is the risk we are taking in these code paths, and the assumption is that
the VM would not try that on its own pagetables, GDTs, or mmio targets. If
so, Xen won't misbehave, yet the VM will shoot itself in the foot.
gfn/p2m lock will also prevent modifications elsewhere in the p2m, and
that is good motivation for a fine-grained lock. These code paths don't
care about modifications elsewhere in the p2m.
I agree it's rather ad hoc, and I'm not happy about it. I would prefer a
proper construct that buries all details, or finding out if rwlocks are
feasible. I'm trying to find ways to relieve contention and address Yang's
problem before the window closes. It hasn't seem that successful anyways.
> Are there some cases where we only care about the first of these and
> some where we care about both? In other words, can we replace the
> gfn-locking everywhere with get_page/put_page (i.e. get rid of put_gfn)?
>> @@ -85,13 +86,16 @@ unsigned long hap_p2m_ga_to_gfn(GUEST_PA
>> /* Map the top-level table and call the tree-walker */
>> + top_page = mfn_to_page(mfn_x(top_mfn));
>> + ASSERT(get_page(top_page, p2m->domain));
> ASSERT(foo) is compiled out on non-debug builds, so that's definitely
> not what you want.
> I personally dislike this idiom with BUG_ON() as well, because even
> though BUG_ON(some side-effecting statement) may be correct, my eye
> tends to skip over it when skimming code.
Xen-devel mailing list