refill_inactive_zone
637 static void
638 refill_inactive_zone(struct zone *zone, struct scan_control *sc)
639 {
640 int pgmoved;
641 int pgdeactivate = 0;
642 int pgscanned = 0;
643 int nr_pages = sc->nr_to_scan;
644 LIST_HEAD(l_hold); /* The pages which were snipped off */
645 LIST_HEAD(l_inactive); /* Pages to go onto the inactive_list */
646 LIST_HEAD(l_active); /* Pages to go onto the active_list */
647 struct page *page;
648 struct pagevec pvec;
649 int reclaim_mapped = 0;
650 long mapped_ratio;
651 long distress;
652 long swap_tendency;
653
654 lru_add_drain();
655 pgmoved = 0;
656 spin_lock_irq(&zone->lru_lock);
657 while (pgscanned < nr_pages && !list_empty(&zone->active_list)) {
658 page = lru_to_page(&zone->active_list); //取出zone的active_list链表的一个节点,并找到这个节点对应的page的指针
659 prefetchw_prev_lru_page(page, &zone->active_list, flags);
660 if (!TestClearPageLRU(page)) //清除页中的LRU标志
661 BUG();
662 list_del(&page->lru); //从zone的active_list链表中删除这个page
663 if (get_page_testone(page)) {
664 /*
665 * It was already free! release_pages() or put_page()
666 * are about to remove it from the LRU and free it. So
667 * put the refcount back and put the page back on the
668 * LRU
669 */
670 __put_page(page);
671 SetPageLRU(page);
672 list_add(&page->lru, &zone->active_list);
673 } else {
674 list_add(&page->lru, &l_hold);
675 pgmoved++;
676 }
677 pgscanned++;
637 static void
638 refill_inactive_zone(struct zone *zone, struct scan_control sc)
639 {
640 int pgmoved;
641 int pgdeactivate = 0;
642 int pgscanned = 0;
643 int nr_pages = sc->nr_to_scan;
644 LIST_HEAD(l_hold); / The pages which were snipped off /
645 LIST_HEAD(l_inactive); / Pages to go onto the inactive_list /
646 LIST_HEAD(l_active); / Pages to go onto the active_list */
647 struct page page;
648 struct pagevec pvec;
649 int reclaim_mapped = 0;
650 long mapped_ratio;
651 long distress;
652 long swap_tendency;
653
654 lru_add_drain();
655 pgmoved = 0;
656 spin_lock_irq(&zone->lru_lock);
657 while (pgscanned < nr_pages && !list_empty(&zone->active_list)) {
658 page = lru_to_page(&zone->active_list);
659 prefetchw_prev_lru_page(page, &zone->active_list, flags);
660 if (!TestClearPageLRU(page))
661 BUG();
662 list_del(&page->lru);
663 if (get_page_testone(page)) {
664 /
665 * It was already free! release_pages() or put_page()
666 * are about to remove it from the LRU and free it. So
667 * put the refcount back and put the page back on the
668 * LRU
669 */
670 __put_page(page);
671 SetPageLRU(page);
672 list_add(&page->lru, &zone->active_list);
673 } else {
674 list_add(&page->lru, &l_hold);
675 pgmoved++;
676 }
677 pgscanned++;