博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
shrink_active_list
阅读量:4153 次
发布时间:2019-05-25

本文共 2090 字,大约阅读时间需要 6 分钟。

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);

}

转载地址:http://xxqti.baihongyu.com/

你可能感兴趣的文章
过滤器及JSP九大隐式对象
查看>>
软件(项目)的分层
查看>>
【Python】学习笔记——-7.0、面向对象编程
查看>>
【Python】学习笔记——-7.2、访问限制
查看>>
【Python】学习笔记——-7.3、继承和多态
查看>>
【Python】学习笔记——-7.5、实例属性和类属性
查看>>
git中文安装教程
查看>>
虚拟机 CentOS7/RedHat7/OracleLinux7 配置静态IP地址 Ping 物理机和互联网
查看>>
Jackson Tree Model Example
查看>>
常用js收集
查看>>
如何防止sql注入
查看>>
springmvc传值
查看>>
在Eclipse中查看Android源码
查看>>
Android使用webservice客户端实例
查看>>
[转]C语言printf
查看>>
C 语言学习 --设置文本框内容及进制转换
查看>>
C 语言 学习---判断文本框取得的数是否是整数
查看>>
C 语言 学习---ComboBox相关、简易“假”管理系统
查看>>
C 语言 学习---回调、时间定时更新程序
查看>>
第十一章 - 直接内存
查看>>