lguest: restore boot speed

lguest is dumb and drops *all* the pagetables for set_pte (which is
only used for kernel mapping manipulation, so it's OK without highmem).

But it's used a lot in boot, too. As a guest optimization, we
suppressed this flushing until the first page switch. Now we have
initial_page_table, that happens much earlier, so extend the heuristic
to wait until we switch to something other than the swapper_pg_dir or
initial_page_table.

As measured on my laptop under kvm, this dropped the time-to-mount-root
from 48 seconds to 4.3 seconds.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

+7 -4
+7 -4
arch/x86/lguest/boot.c
··· 531 { 532 lguest_data.pgdir = cr3; 533 lazy_hcall1(LHCALL_NEW_PGTABLE, cr3); 534 - cr3_changed = true; 535 } 536 537 static unsigned long lguest_read_cr3(void) ··· 706 * to forget all of them. Fortunately, this is very rare. 707 * 708 * ... except in early boot when the kernel sets up the initial pagetables, 709 - * which makes booting astonishingly slow: 1.83 seconds! So we don't even tell 710 - * the Host anything changed until we've done the first page table switch, 711 - * which brings boot back to 0.25 seconds. 712 */ 713 static void lguest_set_pte(pte_t *ptep, pte_t pteval) 714 {
··· 531 { 532 lguest_data.pgdir = cr3; 533 lazy_hcall1(LHCALL_NEW_PGTABLE, cr3); 534 + 535 + /* These two page tables are simple, linear, and used during boot */ 536 + if (cr3 != __pa(swapper_pg_dir) && cr3 != __pa(initial_page_table)) 537 + cr3_changed = true; 538 } 539 540 static unsigned long lguest_read_cr3(void) ··· 703 * to forget all of them. Fortunately, this is very rare. 704 * 705 * ... except in early boot when the kernel sets up the initial pagetables, 706 + * which makes booting astonishingly slow: 48 seconds! So we don't even tell 707 + * the Host anything changed until we've done the first real page table switch, 708 + * which brings boot back to 4.3 seconds. 709 */ 710 static void lguest_set_pte(pte_t *ptep, pte_t pteval) 711 {