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

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

static noinline_for_stack unsigned long shrink_inactive_list(unsigned long nr_to_scan,

struct lruvec *lruvec, struct scan_control *sc, enum lru_list lru)

{

       LIST_HEAD(page_list);

       unsignedlong nr_scanned;

       unsignedlong nr_reclaimed = 0;

       unsignedlong nr_taken;

       unsignedlong nr_dirty = 0;

       unsignedlong nr_congested = 0;

       unsignedlong nr_unqueued_dirty = 0;

       unsignedlong nr_writeback = 0;

       unsignedlong nr_immediate = 0;

       isolate_mode_tisolate_mode = 0;

       int file = is_file_lru(lru);

       struct zone *zone = lruvec_zone(lruvec);

       struct zone_reclaim_stat *reclaim_stat =&lruvec->reclaim_stat;

 

       while (unlikely(too_many_isolated(zone,file, sc))) {

              congestion_wait(BLK_RW_ASYNC, HZ/10);

              if(fatal_signal_pending(current))

                     returnSWAP_CLUSTER_MAX;

       }

 

       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, &page_list,&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);

              if(current_is_kswapd())

                     __count_zone_vm_events(PGSCAN_KSWAPD,zone, nr_scanned);

              else

                     __count_zone_vm_events(PGSCAN_DIRECT,zone, nr_scanned);

       }

       spin_unlock_irq(&zone->lru_lock);

 

       if(nr_taken == 0)

              return0;

 

       nr_reclaimed=shrink_page_list(&page_list,zone,sc,TU_UNMAP,&nr_dirty,

&nr_unqueued_dirty,&nr_congested,&nr_writeback,

&nr_immediate,false);

 

       spin_lock_irq(&zone->lru_lock);

 

       if (global_reclaim(sc)) {

              if(current_is_kswapd())

                     __count_zone_vm_events(PGSTEAL_KSWAPD,zone, nr_reclaimed);

              else

                     __count_zone_vm_events(PGSTEAL_DIRECT,zone, nr_reclaimed);

       }

 

       putback_inactive_pages(lruvec,&page_list);

 

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

 

       spin_unlock_irq(&zone->lru_lock);

 

       mem_cgroup_uncharge_list(&page_list);

       free_hot_cold_page_list(&page_list,true);

 

       if (nr_writeback && nr_writeback== nr_taken)

              set_bit(ZONE_WRITEBACK,&zone->flags);

 

 

       if (sane_reclaim(sc)) {

              if(nr_dirty && nr_dirty == nr_congested)

                     set_bit(ZONE_CONGESTED,&zone->flags);

 

              if(nr_unqueued_dirty == nr_taken)

                     set_bit(ZONE_DIRTY,&zone->flags);

 

              if(nr_immediate && current_may_throttle())

                     congestion_wait(BLK_RW_ASYNC,HZ/10);

       }

       if(!sc->hibernation_mode && !current_is_kswapd() &&current_may_throttle())

              wait_iff_congested(zone,BLK_RW_ASYNC, HZ/10);

 

       trace_mm_vmscan_lru_shrink_inactive(zone,nr_scanned, nr_reclaimed,sc->priority, file);

       return nr_reclaimed;

}

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

你可能感兴趣的文章
Jupyter NotebooK去掉警告
查看>>
CSPNet论文笔记
查看>>
scipy.signal.peak_prominences解析
查看>>
python产生不重复随机数
查看>>
无法获得锁 /var/lib/dpkg/lock-frontend - open (11: 资源暂时不可用)
查看>>
ubuntu安装tensorflow2.1、2.2、2.3、2.4
查看>>
ubuntu18.04 安装搜狗输入法时Manage Installed Language打不开
查看>>
Ubuntu重新挂载home
查看>>
“ValueError: zero-size array to reduction operation maximum which has no identity”解决方法
查看>>
numpy数组展开方法
查看>>
python同时随机排序多个数组
查看>>
Xgboost自定义目标函数
查看>>
多种方法判断某个值是否在一个有序的二维数组中
查看>>
TypeError: cannot perform std with type Sparse[float64, 0.0]
查看>>
常见的类别型数据列编码方法汇总
查看>>
牛顿法和最优化
查看>>
特征金字塔网络总结
查看>>
修改pytorch和Keras预训练模型路径
查看>>
yolov4中的route和shortcut层
查看>>
Pytorch中loss计算解析
查看>>