more swapoff fixes
Subsystems (8)
A message that is not in the archive (sent off-list or not yet received): 020901c1251a$e9386850$bef7020a@mammon
PATCH 1/1 more swapoff fixes
Jeremy and list,
Below is my patch of further bugfixes and speedups to swapoff, based on 2.4.9. For now it's an all-in-one patch: one of these days when Linus gets back I'll cut it into little pieces, with justification for each of those pieces. Like most of VM, I think it's very much a "Linus" thing rather than an "Alan" thing, so I won't be pressing for inclusion in -ac.
I'm mostly happy with it, but there's one issue outstanding: need to make sure we scan child _after_ parent if caught in dup_mmap(). I'll come back to that when I'm fresher: I've kept your "repeat until empty", so I believe it's safe unless SWAP_MAP_MAX.
Please would someone explain to me how the SWAP_MAP_MAX case can arise, I confess I don't get it. I see how a shared file page only needs 256 processes mapping in 256 places to overflow an unsigned short; but I don't see how we get there with swap pages. It does govern the approach quite strictly, and I found the current algorithm much better suited to its constraints than I'd originally
supposed: no radical departure, sorry, even the BKL is still needed (probably quite easy to eliminate, but more a 2.5 thing).
The most serious bugfix, I believe, is to the "dirty" handling. try_to_unuse() used to remove page from pagecache after the loop filling in ptes, but at some point it's been moved before the loop. I prefer it before the loop, because that keeps try_to_swap_out() from duping the entry while we're unduping it; but try_to_swap_out() was discarding a non-swapcache page if its pte was not dirty. So if a swapcache page was already faulted in read-only, and swap_out() reached it after freed from swapcache, before unuse_pte() got there, your data would be wiped - or have I misunderstood? (I should say that the races I found were all long-standing, no problems from Jeremy's 2.4.8 version.)
Faster? please decide for yourself.
Review and testing very welcome!
Thanks,
Hugh
include/linux/pagemap.h +0 -5
@@ -81,11 +81,6 @@#define find_lock_page (mapping, index) \ __find_lock_page(mapping, index, page_hash(mapping, index)) -extern struct page *__find_get_swapcache_page (struct address_space * mapping, -unsigned long index,struct page **hash); -#define find_get_swapcache_page (mapping, index) \ - __find_get_swapcache_page(mapping, index, page_hash(mapping, index)) -extern void __add_page_to_hash_queue (struct page * page,struct page **p);extern void add_to_page_cache (struct page * page,struct address_space *mapping,unsigned long index);
kernel/fork.c +23 -21
81 lines not on this page · raw message
mm/filemap.c +0 -28
@@ -682,34 +682,6 @@ }/* -* Find a swapcache page (and get a reference) or return NULL. -* The SwapCache check is protected by the pagecache lock. -*/ -struct page *__find_get_swapcache_page (struct address_space *mapping, -unsigned long offset,struct page **hash) -{ -struct page *page; - -/* -* We need the LRU lock to protect against page_launder(). -*/ - -spin_lock (&pagecache_lock); - page =__find_page_nolock (mapping, offset, *hash); -if (page) { -spin_lock (&pagemap_lru_lock); -if (PageSwapCache (page)) -page_cache_get (page); -else - page =NULL ; -spin_unlock (&pagemap_lru_lock); - } -spin_unlock (&pagecache_lock); - -return page; -} - -/* * Same as the above, but lock the page too, verifying that * it's still valid once we own it. */
mm/memory.c +8 -10
@@ -148,6 +148,9 @@* * 08Jan98 Merged into one routine from several inline routines to reduce * variable count and make things faster. -jj +* +* dst->page_table_lock is held on entry and exit, +* but may be dropped within pmd_alloc() and pte_alloc(). */ int copy_page_range (struct mm_struct *dst,struct mm_struct *src,struct vm_area_struct *vma)
@@ -159,8 +162,7 @@ src_pgd =pgd_offset (src, address)-1 ; dst_pgd =pgd_offset (dst, address)-1 ; - -spin_lock (&dst->page_table_lock); +for (;;) {pmd_t * src_pmd, * dst_pmd;
@@ -234,6 +236,7 @@ pte =pte_mkclean (pte); pte =pte_mkold (pte);get_page (ptepage); + dst->rss++; cont_copy_pte_range:set_pte (dst_pte, pte); cont_copy_pte_range_noset: address +=PAGE_SIZE ;
@@ -251,11 +254,8 @@ out_unlock:spin_unlock (&src->page_table_lock); out: -spin_unlock (&dst->page_table_lock);return 0 ; - nomem: -spin_unlock (&dst->page_table_lock);return -ENOMEM ; }
@@ -1080,15 +1080,13 @@/* Don't block on I/O for read-ahead */ if (atomic_read (&nr_async_pages) >= pager_daemon.swap_cluster * (1 << page_cluster)) { -while (i++ < num) -swap_free (SWP_ENTRY (SWP_TYPE (entry), offset++));break ; }/* Ok, do the async read-ahead now */ new_page =read_swap_cache_async (SWP_ENTRY (SWP_TYPE (entry), offset)); -if (new_page !=NULL ) -page_cache_release (new_page); -swap_free (SWP_ENTRY (SWP_TYPE (entry), offset)); +if (new_page ==NULL ) +break ; +page_cache_release (new_page); }return ; }
mm/swap_state.c +46 -50
177 lines not on this page · raw message
mm/swapfile.c +190 -139
477 lines not on this page · raw message
mm/vmscan.c +13 -15
@@ -111,6 +111,7 @@* is needed on CPUs which update the accessed and dirty * bits in hardware. */ +flush_cache_page (vma, address); pte =ptep_get_and_clear (page_table);flush_tlb_page (vma, address);
@@ -148,20 +149,13 @@* Basically, this just makes it possible for us to do * some real work in the future in "refill_inactive()". */ -flush_cache_page (vma, address); -if (!pte_dirty (pte)) - goto drop_pte; - -/* -* Ok, it's really dirty. That means that -* we should either create a new swap cache -* entry for it, or we should write it back -* to its own backing store. -*/ if (page->mapping) { -set_page_dirty (page); +if (pte_dirty (pte)) +set_page_dirty (page); goto drop_pte; } +if (!pte_dirty (pte) && !PageDirty (page)) + goto drop_pte;/* * This is a dirty, swappable page. First of all,
@@ -539,8 +533,12 @@* last copy.. */ if (PageDirty (page)) { -int (*writepage)(struct page *) = page->mapping->a_ops->writepage; +int (*writepage)(struct page *); +/* Can a page get here without page->mapping? */ +if (!page->mapping) + goto page_active; + writepage = page->mapping->a_ops->writepage;if (!writepage) goto page_active;
@@ -779,7 +777,7 @@ {pg_data_t *pgdat;unsigned int global_target = freepages.high + inactive_target; -unsigned int global_incative =0 ; +unsigned int global_inactive =0 ; pgdat = pgdat_list; do {
@@ -799,13 +797,13 @@if (inactive < zone->pages_high)return 1 ; - global_incative += inactive; + global_inactive += inactive; } pgdat = pgdat->node_next; }while (pgdat);/* Global shortage? */ -return global_incative < global_target; +return global_inactive < global_target; }/*
--
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/
Quoted 4 lines
Jeremy and list,
Below is my patch of further bugfixes and speedups to swapoff, based on 2.4.9. For now it's an all-in-one patch: one of these
2.4.9 stock is broken with my tests. Let me see if I can track the
problem down before I give your stuff a spin. Looks like it might be USB related but...
jlinton
--
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/