|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH RFC 2/2] xen: arm: Enable physical address space compression (PDX) on arm64
On Thu, 2014-08-07 at 17:03 +0100, Julien Grall wrote:
> Hi Ian,
>
> On 07/31/2014 12:01 PM, Ian Campbell wrote:
> > diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> > index 446b4dc..dbd92bb 100644
> > --- a/xen/arch/arm/setup.c
> > +++ b/xen/arch/arm/setup.c
> > @@ -423,6 +423,46 @@ static paddr_t __init get_xen_paddr(void)
> > return paddr;
> > }
> >
> > +/* Sets all bits from the most-significant 1-bit down to the LSB */
> > +static u64 __init fill_mask(u64 mask)
> > +{
> > + while (mask & (mask + 1))
>
> Coding style: Missing spaces
>
> > + mask |= mask + 1;
> > + return mask;
> > +}
> > +
> > +static void init_pdx(void)
> > +{
> > + u64 mask = fill_mask(bootinfo.mem.bank[0].start - 1);
> > + int bank;
> > +
> > + for ( bank = 0 ; bank < bootinfo.mem.nr_banks; bank++ )
> > + {
> > + paddr_t bank_start = bootinfo.mem.bank[bank].start;
> > + paddr_t bank_size = bootinfo.mem.bank[bank].size;
> > + paddr_t bank_end = bank_start + bank_size;
> > +
> > + set_pdx_range(paddr_to_pfn(bank_start),
> > + paddr_to_pfn(bank_end));
> > +
> > +
> > + mask |= bank_start | fill_mask(bank_start ^ (bank_end - 1));
> > + }
> > +
> > + for ( bank = 0 ; bank < bootinfo.mem.nr_banks; bank++ )
> > + {
> > + paddr_t bank_start = bootinfo.mem.bank[bank].start;
> > + paddr_t bank_size = bootinfo.mem.bank[bank].size;
> > + paddr_t bank_end = bank_start + bank_size;
> > +
> > + if (~mask &
> > + fill_mask(bank_start ^ (bank_end - 1)))
>
> Coding style.
>
> I don't really understand what the function is achieving. Could you
> explain a bit more?
This is largely derived from an x86 equivalent (see srat_parse_regions,
they are different because one walks the device tree RAM and the other
the SRAT), so I hope Jan will correct me if I'm wrong about the
following:
What it is doing is calculating a mask which corresponds to to the bits
that are active address bits across the valid memory addresses, i.e. a
bit which is necessary to unambiguously represent some valid address is
1 and a bit which is the same for all addresses is 0.
Using that mask we then find a large run of zeroes from he middle of the
mask which by construction do not actually get used for addressing. By
omitting those bits from the PFN we obtain a PDX which is the
(losslessly) compressed form.
I have a feeling I've not explained that so well...
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |