vmscan.c (0cee34fd72c582b4f8ad8ce00645b75fb4168199) vmscan.c (2bcf887963812c075f80a14e1fad8ec7e1c67acf)
1/*
2 * linux/mm/vmscan.c
3 *
4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
5 *
6 * Swap reorganised 29.12.95, Stephen Tweedie.
7 * kswapd added: 7.1.96 sct
8 * Removed kswapd_ctl limits, and swap out as many pages as needed

--- 1384 unchanged lines hidden (view full) ---

1393 * TODO: Try merging with migrations version of putback_lru_pages
1394 */
1395static noinline_for_stack void
1396putback_lru_pages(struct mem_cgroup_zone *mz, struct scan_control *sc,
1397 unsigned long nr_anon, unsigned long nr_file,
1398 struct list_head *page_list)
1399{
1400 struct page *page;
1/*
2 * linux/mm/vmscan.c
3 *
4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
5 *
6 * Swap reorganised 29.12.95, Stephen Tweedie.
7 * kswapd added: 7.1.96 sct
8 * Removed kswapd_ctl limits, and swap out as many pages as needed

--- 1384 unchanged lines hidden (view full) ---

1393 * TODO: Try merging with migrations version of putback_lru_pages
1394 */
1395static noinline_for_stack void
1396putback_lru_pages(struct mem_cgroup_zone *mz, struct scan_control *sc,
1397 unsigned long nr_anon, unsigned long nr_file,
1398 struct list_head *page_list)
1399{
1400 struct page *page;
1401 struct pagevec pvec;
1401 LIST_HEAD(pages_to_free);
1402 struct zone *zone = mz->zone;
1403 struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(mz);
1404
1402 struct zone *zone = mz->zone;
1403 struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(mz);
1404
1405 pagevec_init(&pvec, 1);
1406
1407 /*
1408 * Put back any unfreeable pages.
1409 */
1410 spin_lock(&zone->lru_lock);
1411 while (!list_empty(page_list)) {
1412 int lru;
1413 page = lru_to_page(page_list);
1414 VM_BUG_ON(PageLRU(page));

--- 7 unchanged lines hidden (view full) ---

1422 SetPageLRU(page);
1423 lru = page_lru(page);
1424 add_page_to_lru_list(zone, page, lru);
1425 if (is_active_lru(lru)) {
1426 int file = is_file_lru(lru);
1427 int numpages = hpage_nr_pages(page);
1428 reclaim_stat->recent_rotated[file] += numpages;
1429 }
1405 /*
1406 * Put back any unfreeable pages.
1407 */
1408 spin_lock(&zone->lru_lock);
1409 while (!list_empty(page_list)) {
1410 int lru;
1411 page = lru_to_page(page_list);
1412 VM_BUG_ON(PageLRU(page));

--- 7 unchanged lines hidden (view full) ---

1420 SetPageLRU(page);
1421 lru = page_lru(page);
1422 add_page_to_lru_list(zone, page, lru);
1423 if (is_active_lru(lru)) {
1424 int file = is_file_lru(lru);
1425 int numpages = hpage_nr_pages(page);
1426 reclaim_stat->recent_rotated[file] += numpages;
1427 }
1430 if (!pagevec_add(&pvec, page)) {
1431 spin_unlock_irq(&zone->lru_lock);
1432 __pagevec_release(&pvec);
1433 spin_lock_irq(&zone->lru_lock);
1428 if (put_page_testzero(page)) {
1429 __ClearPageLRU(page);
1430 __ClearPageActive(page);
1431 del_page_from_lru_list(zone, page, lru);
1432
1433 if (unlikely(PageCompound(page))) {
1434 spin_unlock_irq(&zone->lru_lock);
1435 (*get_compound_page_dtor(page))(page);
1436 spin_lock_irq(&zone->lru_lock);
1437 } else
1438 list_add(&page->lru, &pages_to_free);
1434 }
1435 }
1436 __mod_zone_page_state(zone, NR_ISOLATED_ANON, -nr_anon);
1437 __mod_zone_page_state(zone, NR_ISOLATED_FILE, -nr_file);
1438
1439 spin_unlock_irq(&zone->lru_lock);
1439 }
1440 }
1441 __mod_zone_page_state(zone, NR_ISOLATED_ANON, -nr_anon);
1442 __mod_zone_page_state(zone, NR_ISOLATED_FILE, -nr_file);
1443
1444 spin_unlock_irq(&zone->lru_lock);
1440 pagevec_release(&pvec);
1445 free_hot_cold_page_list(&pages_to_free, 1);
1441}
1442
1443static noinline_for_stack void
1444update_isolated_counts(struct mem_cgroup_zone *mz,
1445 struct scan_control *sc,
1446 unsigned long *nr_anon,
1447 unsigned long *nr_file,
1448 struct list_head *isolated_list)

--- 193 unchanged lines hidden (view full) ---

1642 * nobody will play with that bit on a non-LRU page.
1643 *
1644 * The downside is that we have to touch page->_count against each page.
1645 * But we had to alter page->flags anyway.
1646 */
1647
1648static void move_active_pages_to_lru(struct zone *zone,
1649 struct list_head *list,
1446}
1447
1448static noinline_for_stack void
1449update_isolated_counts(struct mem_cgroup_zone *mz,
1450 struct scan_control *sc,
1451 unsigned long *nr_anon,
1452 unsigned long *nr_file,
1453 struct list_head *isolated_list)

--- 193 unchanged lines hidden (view full) ---

1647 * nobody will play with that bit on a non-LRU page.
1648 *
1649 * The downside is that we have to touch page->_count against each page.
1650 * But we had to alter page->flags anyway.
1651 */
1652
1653static void move_active_pages_to_lru(struct zone *zone,
1654 struct list_head *list,
1655 struct list_head *pages_to_free,
1650 enum lru_list lru)
1651{
1652 unsigned long pgmoved = 0;
1656 enum lru_list lru)
1657{
1658 unsigned long pgmoved = 0;
1653 struct pagevec pvec;
1654 struct page *page;
1655
1659 struct page *page;
1660
1656 pagevec_init(&pvec, 1);
1661 if (buffer_heads_over_limit) {
1662 spin_unlock_irq(&zone->lru_lock);
1663 list_for_each_entry(page, list, lru) {
1664 if (page_has_private(page) && trylock_page(page)) {
1665 if (page_has_private(page))
1666 try_to_release_page(page, 0);
1667 unlock_page(page);
1668 }
1669 }
1670 spin_lock_irq(&zone->lru_lock);
1671 }
1657
1658 while (!list_empty(list)) {
1659 struct lruvec *lruvec;
1660
1661 page = lru_to_page(list);
1662
1663 VM_BUG_ON(PageLRU(page));
1664 SetPageLRU(page);
1665
1666 lruvec = mem_cgroup_lru_add_list(zone, page, lru);
1667 list_move(&page->lru, &lruvec->lists[lru]);
1668 pgmoved += hpage_nr_pages(page);
1669
1672
1673 while (!list_empty(list)) {
1674 struct lruvec *lruvec;
1675
1676 page = lru_to_page(list);
1677
1678 VM_BUG_ON(PageLRU(page));
1679 SetPageLRU(page);
1680
1681 lruvec = mem_cgroup_lru_add_list(zone, page, lru);
1682 list_move(&page->lru, &lruvec->lists[lru]);
1683 pgmoved += hpage_nr_pages(page);
1684
1670 if (!pagevec_add(&pvec, page) || list_empty(list)) {
1671 spin_unlock_irq(&zone->lru_lock);
1672 if (buffer_heads_over_limit)
1673 pagevec_strip(&pvec);
1674 __pagevec_release(&pvec);
1675 spin_lock_irq(&zone->lru_lock);
1685 if (put_page_testzero(page)) {
1686 __ClearPageLRU(page);
1687 __ClearPageActive(page);
1688 del_page_from_lru_list(zone, page, lru);
1689
1690 if (unlikely(PageCompound(page))) {
1691 spin_unlock_irq(&zone->lru_lock);
1692 (*get_compound_page_dtor(page))(page);
1693 spin_lock_irq(&zone->lru_lock);
1694 } else
1695 list_add(&page->lru, pages_to_free);
1676 }
1677 }
1678 __mod_zone_page_state(zone, NR_LRU_BASE + lru, pgmoved);
1679 if (!is_active_lru(lru))
1680 __count_vm_events(PGDEACTIVATE, pgmoved);
1681}
1682
1683static void shrink_active_list(unsigned long nr_pages,

--- 77 unchanged lines hidden (view full) ---

1761 /*
1762 * Count referenced pages from currently used mappings as rotated,
1763 * even though only some of them are actually re-activated. This
1764 * helps balance scan pressure between file and anonymous pages in
1765 * get_scan_ratio.
1766 */
1767 reclaim_stat->recent_rotated[file] += nr_rotated;
1768
1696 }
1697 }
1698 __mod_zone_page_state(zone, NR_LRU_BASE + lru, pgmoved);
1699 if (!is_active_lru(lru))
1700 __count_vm_events(PGDEACTIVATE, pgmoved);
1701}
1702
1703static void shrink_active_list(unsigned long nr_pages,

--- 77 unchanged lines hidden (view full) ---

1781 /*
1782 * Count referenced pages from currently used mappings as rotated,
1783 * even though only some of them are actually re-activated. This
1784 * helps balance scan pressure between file and anonymous pages in
1785 * get_scan_ratio.
1786 */
1787 reclaim_stat->recent_rotated[file] += nr_rotated;
1788
1769 move_active_pages_to_lru(zone, &l_active,
1789 move_active_pages_to_lru(zone, &l_active, &l_hold,
1770 LRU_ACTIVE + file * LRU_FILE);
1790 LRU_ACTIVE + file * LRU_FILE);
1771 move_active_pages_to_lru(zone, &l_inactive,
1791 move_active_pages_to_lru(zone, &l_inactive, &l_hold,
1772 LRU_BASE + file * LRU_FILE);
1773 __mod_zone_page_state(zone, NR_ISOLATED_ANON + file, -nr_taken);
1774 spin_unlock_irq(&zone->lru_lock);
1792 LRU_BASE + file * LRU_FILE);
1793 __mod_zone_page_state(zone, NR_ISOLATED_ANON + file, -nr_taken);
1794 spin_unlock_irq(&zone->lru_lock);
1795
1796 free_hot_cold_page_list(&l_hold, 1);
1775}
1776
1777#ifdef CONFIG_SWAP
1778static int inactive_anon_is_low_global(struct zone *zone)
1779{
1780 unsigned long active, inactive;
1781
1782 active = zone_page_state(zone, NR_ACTIVE_ANON);

--- 1869 unchanged lines hidden ---
1797}
1798
1799#ifdef CONFIG_SWAP
1800static int inactive_anon_is_low_global(struct zone *zone)
1801{
1802 unsigned long active, inactive;
1803
1804 active = zone_page_state(zone, NR_ACTIVE_ANON);

--- 1869 unchanged lines hidden ---