fix BUG at include/linux/mm.h:220!
Subsystems (4)
PATCH 1/3 fix BUG at include/linux/mm.h:220!
a.k.a. mm-use-pagevec-to-rotate-reclaimable-page-fix-3.patch
put_page_testzero's VM_BUG_ON(atomic_read(&page->_count) == 0) fired a couple of times while heavily swapping (on -rc7-mm1 and -rc8-mm1).
release_pages() has been using spin_lock_irq/spin_unlock_irq: but now that it's being called by pagevec_move_tail() with interrupts disabled, it must use spin_lock_irqsave/spin_unlock_irqrestore instead.
Aside from it being generally wrong to enable IRQs behind the caller's back, here a pagevec might overflow, or (as I think must have happened to cause those BUGs) release_pages() may be preempted to another cpu while still acting on the pagevec of the cpu it started out with, and that owning cpu also come in to drain it. Hmm, no, one of the BUGs was with preemption disabled: so I don't fully understand it.
Tested for 39 hours with rc8-mm1 on three 4cpu machines: no more BUGs.
--- mm/swap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
mm/swap.c +7 -5
@@ -299,6 +299,7 @@ void release_pages(struct page **pages,int i;struct pagevec pages_to_free;struct zone *zone =NULL ; +unsigned long uninitialized_var (flags );pagevec_init (&pages_to_free, cold);for (i =0 ; i < nr; i++) {
@@ -306,7 +307,7 @@ void release_pages(struct page **pages,if (unlikely (PageCompound (page))) {if (zone) { -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irqrestore (&zone->lru_lock, flags); zone =NULL ; }put_compound_page (page);
@@ -320,9 +321,10 @@ void release_pages(struct page **pages,struct zone *pagezone =page_zone (page);if (pagezone != zone) {if (zone) -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irqrestore (&zone->lru_lock, + flags); zone = pagezone; -spin_lock_irq (&zone->lru_lock); +spin_lock_irqsave (&zone->lru_lock, flags); }VM_BUG_ON (!PageLRU (page));__ClearPageLRU (page);
@@ -331,7 +333,7 @@ void release_pages(struct page **pages,if (!pagevec_add (&pages_to_free, page)) {if (zone) { -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irqrestore (&zone->lru_lock, flags); zone =NULL ; }__pagevec_free (&pages_to_free);
@@ -339,7 +341,7 @@ void release_pages(struct page **pages, } }if (zone) -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irqrestore (&zone->lru_lock, flags);pagevec_free (&pages_to_free); }
PATCH 2/3 kill redundancy in rotate_reclaimable_page
a.k.a. mm-use-pagevec-to-rotate-reclaimable-page-cleanup.patch
diff -U5 shows rotate_reclaimable_page() is pointlessly testing PageActive and PageLRU twice in a row: of course there used to be a lock taken in between those tests; but now that pagevec_move_tail() is making those tests under lock, there's no point to repeating them here.
--- mm/swap.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
mm/swap.c +7 -8
@@ -158,18 +158,17 @@ int rotate_reclaimable_page(struct pageif (PageActive (page))return 1 ;if (!PageLRU (page))return 1 ; -if (PageLRU (page) && !PageActive (page)) { -page_cache_get (page); -local_irq_save (flags); - pvec = &__get_cpu_var (rotate_pvecs); -if (!pagevec_add (pvec, page)) -pagevec_move_tail (pvec); -local_irq_restore (flags); - } +page_cache_get (page); +local_irq_save (flags); + pvec = &__get_cpu_var (lru_rotate_pvecs); +if (!pagevec_add (pvec, page)) +pagevec_move_tail (pvec); +local_irq_restore (flags); +if (!test_clear_page_writeback (page))BUG ();return 0 ; }
PATCH 3/3 move_tail_pages into lru_add_drain
In reply to Hugh Dickinsa.k.a. mm-use-pagevec-to-rotate-reclaimable-page-cleanup-2.patch
Opinions may differ, but I'm uneasy with leaving pages to be rotated on their pagevecs for too long: although they're still visible via the LRU, their page counts are raised, which excludes them from some operations.
Memory hotplug and page migration clearly want to be draining them:
but rather than add move_tail_pages calls in various places, won't we be safer just to drain them whenever we drain the lru_add pagevecs?
So merge move_tail_pages into __lru_add_drain, which lets us remove cpu_movetail_callback. Rename __lru_add_drain to drain_cpu_pagevecs, and correct the misleading "CPU is dead" comment found there.
---
You may disagree with this one, or your unease with these rotation patches may have grown to the point that you want to back them all out:
I've no strong feeling on it - it was a good idea to try to batch them, but has turned out to be more complicated than was foreseen.
include/linux/swap.h | 1 mm/swap.c | 65 +++++++++++++++-------------------------- mm/vmscan.c | 1 3 files changed, 25 insertions(+), 42 deletions(-)
include/linux/swap.h +0 -1
@@ -181,7 +181,6 @@ extern void FASTCALL(mark_page_accessed(extern void lru_add_drain (void );extern int lru_add_drain_all (void );extern int rotate_reclaimable_page (struct page *page); -extern void move_tail_pages (void );extern void swap_setup (void );/* linux/mm/vmscan.c */
mm/swap.c +25 -40
112 lines not on this page · raw message
mm/vmscan.c +0 -1
@@ -824,7 +824,6 @@ static unsigned long shrink_inactive_lispagevec_init (&pvec,1 ); -move_tail_pages ();lru_add_drain ();spin_lock_irq (&zone->lru_lock); do {