shrink_active_list

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值