shrink_active_list

来源:互联网 发布:dc数据恢复指南针 编辑:程序博客网 时间:2024/05/01 00:20

static void shrink_active_list(unsignedlong nr_to_scan,  struct lruvec *lruvec,  struct scan_control *sc,  enum lru_list lru)

{

       unsignedlong nr_taken;

       unsignedlong nr_scanned;

       unsignedlong vm_flags;

       LIST_HEAD(l_hold);   /* The pages which were snipped off */

       LIST_HEAD(l_active);

       LIST_HEAD(l_inactive);

       structpage *page;

       structzone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat;

       unsignedlong nr_rotated = 0;

       isolate_mode_tisolate_mode = 0;

       int file = is_file_lru(lru);

       structzone *zone = lruvec_zone(lruvec);

 

       lru_add_drain();

 

       if (!sc->may_unmap)

              isolate_mode|= ISOLATE_UNMAPPED;

       if (!sc->may_writepage)

              isolate_mode|= ISOLATE_CLEAN;

 

       spin_lock_irq(&zone->lru_lock);

 

      nr_taken = isolate_lru_pages(nr_to_scan, lruvec,&l_hold, &nr_scanned, sc, isolate_mode, lru);

 

       update_lru_size(lruvec, lru, -nr_taken);

       __mod_zone_page_state(zone,NR_ISOLATED_ANON + file, nr_taken);

       reclaim_stat->recent_scanned[file] +=nr_taken;

 

       if (global_reclaim(sc))

              __mod_zone_page_state(zone,NR_PAGES_SCANNED, nr_scanned);

       __count_zone_vm_events(PGREFILL,zone, nr_scanned);

 

       spin_unlock_irq(&zone->lru_lock);

 

       while (!list_empty(&l_hold)) {

              cond_resched();

              page= lru_to_page(&l_hold);

              list_del(&page->lru);

 

              if(unlikely(!page_evictable(page))) {

                     putback_lru_page(page);

                     continue;

              }

 

              if(unlikely(buffer_heads_over_limit)) {

                     if(page_has_private(page) && trylock_page(page)) {

                            if(page_has_private(page))

                                   try_to_release_page(page, 0);

                            unlock_page(page);

                     }

              }

 

              if (page_referenced(page, 0,sc->target_mem_cgroup,&vm_flags)) {

                     nr_rotated+= hpage_nr_pages(page);

                     if((vm_flags & VM_EXEC) && page_is_file_cache(page)) {

                            list_add(&page->lru,&l_active);

                            continue;

                     }

              }

 

              ClearPageActive(page);     /* we are de-activating */

              list_add(&page->lru,&l_inactive);

       }

 

       spin_lock_irq(&zone->lru_lock);

       reclaim_stat->recent_rotated[file] +=nr_rotated;

 

       move_active_pages_to_lru(lruvec,&l_active, &l_hold, lru);

       move_active_pages_to_lru(lruvec,&l_inactive, &l_hold, lru - LRU_ACTIVE);

       __mod_zone_page_state(zone,NR_ISOLATED_ANON + file, -nr_taken);

       spin_unlock_irq(&zone->lru_lock);

 

       mem_cgroup_uncharge_list(&l_hold);

       free_hot_cold_page_list(&l_hold,true);

}

0 0
原创粉丝点击