Re: [PATCH v3] x86/e820: put !E820_TYPE_RAM regions into memblock.reserved

From: Pavel Tatashin
Date: Fri Jun 15 2018 - 12:03:01 EST


> Hi Pavel,
>
> I think this makes a lot of sense.
> Since Naoya is out until Wednesday, maybe I give it a shot next week and see if I can gather some numbers.

Hi Oscar,

Thank you for the offer to do this. Since, sched_clock() is not yet
initialized at the time zero_resv_unavail() is called, it is difficult
to measure it during boot. But, I had x86 early boot timestamps
patches handy, so I could measure, thus decided to submit the patch.
http://lkml.kernel.org/r/20180615155733.1175-1-pasha.tatashin@xxxxxxxxxx

Thank you,
Pavel

>
> >
> > Thank you,
> > Pasha
> >
> > >
> > > > ---
> > > > arch/x86/kernel/e820.c | 15 ++++++++++++---
> > > > 1 file changed, 12 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
> > > > index d1f25c831447..c88c23c658c1 100644
> > > > --- a/arch/x86/kernel/e820.c
> > > > +++ b/arch/x86/kernel/e820.c
> > > > @@ -1248,6 +1248,7 @@ void __init e820__memblock_setup(void)
> > > > {
> > > > int i;
> > > > u64 end;
> > > > + u64 addr = 0;
> > > >
> > > > /*
> > > > * The bootstrap memblock region count maximum is 128 entries
> > > > @@ -1264,13 +1265,21 @@ void __init e820__memblock_setup(void)
> > > > struct e820_entry *entry = &e820_table->entries[i];
> > > >
> > > > end = entry->addr + entry->size;
> > > > + if (addr < entry->addr)
> > > > + memblock_reserve(addr, entry->addr - addr);
> > > > + addr = end;
> > > > if (end != (resource_size_t)end)
> > > > continue;
> > > >
> > > > + /*
> > > > + * all !E820_TYPE_RAM ranges (including gap ranges) are put
> > > > + * into memblock.reserved to make sure that struct pages in
> > > > + * such regions are not left uninitialized after bootup.
> > > > + */
> > > > if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN)
> > > > - continue;
> > > > -
> > > > - memblock_add(entry->addr, entry->size);
> > > > + memblock_reserve(entry->addr, entry->size);
> > > > + else
> > > > + memblock_add(entry->addr, entry->size);
> > > > }
> > > >
> > > > /* Throw away partial pages: */
> > > > --
> > > > 2.7.4
> > >
> > > --
> > > Michal Hocko
> > > SUSE Labs
> > >
> >
>
> Best Regards
> Oscar Salvador
>