Partial object-based rmap implementation
Subsystems (7)
PATCH 1/1 Partial object-based rmap implementation
There's been a fair amount of discussion about the advantages of doing object-based rmap. I've been looking into it, and we have the pieces to do it for file-backed objects, ie the ones that have a real address_space object pointed to from struct page. The stumbling block has always been anonymous pages.
At Martin Bligh's suggestion, I coded up an object-based implementation for non-anon pages while leaving the pte_chain code intact for anon pages. My fork/exit microbenchmark shows roughly 50% improvement for tasks that are composes of file-backed and/or shared pages. This is the code that Martin included in 2.5.62-mjb2 and reported his performance results on.
Anyway, here's the patch if anyone wants to check it out.
Dave McCracken
======================================================================
Dave McCracken IBM Linux Base Kernel Team 1-512-838-3059
[email protected] T/L 678-3059
./include/linux/mm.h +1 -0
@@ -171,6 +171,7 @@struct pte_chain *chain;/* Reverse pte mapping pointer. * protected by PG_chainlock */ pte_addr_t direct; +atomic_t mapcount; } pte;unsigned long private;/* mapping-private opaque data */
./include/linux/page-flags.h +5 -0
@@ -74,6 +74,7 @@#define PG_mappedtodisk 17/* Has blocks allocated on-disk */ #define PG_reclaim 18/* To be reclaimed asap */ #define PG_compound 19/* Part of a compound page */ +#define PG_anon 20/* Anonymous page */ /* * Global page accounting. One instance per CPU. Only unsigned longs are
@@ -256,6 +257,10 @@#define SetPageCompound (page) set_bit(PG_compound, &(page)->flags)#define ClearPageCompound (page) clear_bit(PG_compound, &(page)->flags) +#define PageAnon (page) test_bit(PG_anon, &(page)->flags) +#define SetPageAnon (page) set_bit(PG_anon, &(page)->flags) +#define ClearPageAnon (page) clear_bit(PG_anon, &(page)->flags) +/* * The PageSwapCache predicate doesn't use a PG_flag at this time, * but it may again do so one day.
./fs/exec.c +1 -0
@@ -316,6 +316,7 @@lru_cache_add_active (page);flush_dcache_page (page);flush_page_to_ram (page); +SetPageAnon (page);set_pte (pte,pte_mkdirty (pte_mkwrite (mk_pte (page,PAGE_COPY )))); pte_chain =page_add_rmap (page, pte, pte_chain);pte_unmap (pte);
./mm/page_alloc.c +2 -0
@@ -220,6 +220,8 @@bad_page (function, page);if (PageDirty (page))ClearPageDirty (page); +if (PageAnon (page)) +ClearPageAnon (page); }/*
./mm/swapfile.c +1 -0
@@ -390,6 +390,7 @@return ;get_page (page);set_pte (dir,pte_mkold (mk_pte (page, vma->vm_page_prot))); +SetPageAnon (page); *pte_chainp =page_add_rmap (page, dir, *pte_chainp);swap_free (entry); ++vma->vm_mm->rss;
./mm/memory.c +4 -0
@@ -988,6 +988,7 @@ ++mm->rss;page_remove_rmap (old_page, page_table);break_cow (vma, new_page, address, page_table); +SetPageAnon (new_page); pte_chain =page_add_rmap (new_page, page_table, pte_chain);lru_cache_add_active (new_page);
@@ -1197,6 +1198,7 @@flush_page_to_ram (page);flush_icache_page (vma, page);set_pte (page_table, pte); +SetPageAnon (page); pte_chain =page_add_rmap (page, page_table, pte_chain);/* No need to invalidate - it was non-present before */
@@ -1263,6 +1265,7 @@ entry =pte_mkwrite (pte_mkdirty (mk_pte (page, vma->vm_page_prot)));lru_cache_add_active (page);mark_page_accessed (page); +SetPageAnon (page); }set_pte (page_table, entry);
@@ -1334,6 +1337,7 @@copy_user_highpage (page, new_page, address);page_cache_release (new_page);lru_cache_add_active (page); +SetPageAnon (page); new_page = page; }
./mm/rmap.c +219 -0
261 lines not on this page · raw message
Quoted 2 lines · Dave McCracken
There's been a fair amount of discussion about the advantages of doing object-based rmap.
Unfortunately, not nearly as much about the disadvantages.
There are big advantages and disadvantages to both ways of doing reverse mappings. I'm planning to write about both for my OLS paper and analise the algorithmic complexities in more detail so we've got a better idea of exactly what we're facing.
Quoted 4 lines
I've been looking into it, and we have the pieces to
do it for file-backed objects, ie the ones that have a realaddress_spaceobject pointed to from struct page. The stumbling block has always been anonymous pages.
And algorithmic complexities, for some reason those always seem to be about as unexpected as the Spanish Inquisition. ;)
Quoted 5 lines
At Martin Bligh's suggestion, I coded up an object-based implementation for non-anon pages while leaving the
pte_chaincode intact for anon pages. My fork/exit microbenchmark shows roughly 50% improvement for tasks that are composes of file-backed and/or shared pages. This is the code that Martin included in 2.5.62-mjb2 and reported his performance results on.
But how is performance under memory pressure ?
Quoted 1 line
Anyway, here's the patch if anyone wants to check it out.
It's nice, but we'll want to find a way to alleviate some of the
worst case complexities. Definately something worth exploring
further.
It would be good to discuss the pitfalls of object based reverse mapping with Ben LaHaise and Dave Miller, who have implemented such schemes in the past.
kind regards,
Rik
Signature · 7 lines
Engineers don't grow up, they grow sideways. http://www.surriel.com/ http://kernelnewbies.org/ -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]">[email protected]</a>