Re: [Xen-devel] [PATCH 1/2] xen/p2m: Fix for 32-bit builds the"Reserve 8MB of _brk space for P2M"

From: Konrad Rzeszutek Wilk
Date: Fri Aug 17 2012 - 13:46:27 EST


On Fri, Aug 17, 2012 at 02:28:51PM +0100, David Vrabel wrote:
> On 17/08/12 14:06, Konrad Rzeszutek Wilk wrote:
> > On Fri, Aug 17, 2012 at 12:14:12PM +0100, David Vrabel wrote:
> >> On 16/08/12 22:02, Konrad Rzeszutek Wilk wrote:
> >>>
> >>> So I thought about this some more and came up with this patch. Its
> >>> RFC and going to run it through some overnight tests to see how they fare.
> >>>
> >>>
> >>> commit da858a92dbeb52fb3246e3d0f1dd57989b5b1734
> >>> Author: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> >>> Date: Fri Jul 27 16:05:47 2012 -0400
> >>>
> >>> xen/p2m: Reuse existing P2M leafs if they are filled with 1:1 PFNs or INVALID.
> >>>
> >>> If P2M leaf is completly packed with INVALID_P2M_ENTRY or with
> >>> 1:1 PFNs (so IDENTITY_FRAME type PFNs), we can swap the P2M leaf
> >>> with either a p2m_missing or p2m_identity respectively. The old
> >>> page (which was created via extend_brk or was grafted on from the
> >>> mfn_list) can be re-used for setting new PFNs.
> >>
> >> Does this actually find any p2m pages to reclaim?
> >
> > Very much so. When I run the kernel without dom0_mem, and end up returning
> > around 372300 pages back, and then populating them back - they (mostly)
> > all get to re-use the transplanted mfn_list.
> >
> > The ones in the 9a-100 obviously don't.
> >>
> >> xen_set_identity_and_release() is careful to set the largest possible
> >> range as 1:1 and the comments at the top of p2m.c suggest the mid
> >> entries will be made to point to p2m_identity already.
> >
> > Right, and that is still true - for cases where the are no mid entries
> > (so P2M[3][400] for example can point in the middle of the MMIO region).
> >
> > But if you boot without dom0_mem=max, that region (P2M[3][400]) would at
> > the start be backed by the &mfn_list, so when we call 1-1 on that region
> > it ends up sticking in the &mfn_list a whole bunch of IDENTITY_FRAME(pfn).
>
> Ah, I see. This makes sense now.
>
> > This patch harvests those chunks of &mfn_list that have that and re-uses them.
> >
> > And without any dom0_mem= I seem to at most call extend_bkr twice (to
> > allocate the top leafs P2M[4] and P2M[5]). Hm, to be on a safe side I should
> > probably do 'reserve_brk(p2m_popualated, 3 * PAGE_SIZE)' in case we
> > end up transplanting 3GB of PFNs in in the P2M[4], P2M[5] and P2M[6] nodes.
>
> That sounds sensible.

Here is an updated (just made so to scale the reserve_brk down)
one that I was thinking to send to Linus next week.