Re: improved memory defragger

David S. Miller (davem@dm.cobaltmicro.com)
Thu, 23 Jul 1998 16:14:45 -0700


Date: Thu, 23 Jul 1998 18:36:39 -0400
From: Bill Hawes <whawes@star.net>

The crux of the page replacement is in this bit of code, with new_page
being freshly allocated and old_page with count == 1:

/* Create the new pte value */
new_pte = mk_pte(new_page, vma->vm_page_prot);
if (pte_write(pte))
new_pte = pte_mkwrite(new_pte);
if (pte_dirty(pte))
new_pte = pte_mkdirty(new_pte);
printk("do_defrag: changing pte, old=%08x, new=%08x\n", pte, new_pte);
/* copy the data */
copy_page(new_page, old_page);
flush_cache_page(vma, addr);
/* install the new pte */
set_pte(dir, new_pte);
flush_tlb_page(vma, addr);

I think this is OK, but if I've overlooked any cache-flushing, pte-bit,
or other considerations, hopefully someone will spot it.

You need to add this after the copy_page():

flush_page_to_ram(old_page);
flush_page_to_ram(new_page);

so that the kernel space dirty cache lines for the page data get
sucked back out to main memory, and thus the user space mappings will
view the uptodate contents of the physical pages, on architectures
where this is relevant.

Otherwise it looks fine wrt. cache/tlb flushing issues.

Later,
David S. Miller
davem@dm.cobaltmicro.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html