shrink_zones

来源:互联网 发布:淘宝一级类目有哪些 编辑:程序博客网 时间:2024/05/03 23:58

static void shrink_zones(struct zonelist *zonelist,struct scan_control *sc)

{

       struct zoneref *z;

       struct zone *zone;

       unsigned long nr_soft_reclaimed;

       unsigned long nr_soft_scanned;

       gfp_t orig_mask;

       enumzone_type requested_highidx = gfp_zone(sc->gfp_mask);

 

       orig_mask = sc->gfp_mask;

       if(buffer_heads_over_limit)

              sc->gfp_mask |= __GFP_HIGHMEM;

 

       for_each_zone_zonelist_nodemask(zone,z,zonelist,gfp_zone(sc->gfp_mask),sc->nodemask){

              enum zone_type classzone_idx;

 

              if (!populated_zone(zone))

                     continue;

 

              classzone_idx = requested_highidx;

              while (!populated_zone(zone->zone_pgdat->node_zones +classzone_idx))

                     classzone_idx--;

 

              if (global_reclaim(sc)) {

                     if(!cpuset_zone_allowed(zone, GFP_KERNEL |

                                                        __GFP_HARDWALL))

                            continue;

 

                     if (sc->priority !=DEF_PRIORITY &&

                         !zone_reclaimable(zone))

                            continue;      /* Let kswapd poll it */

 

                     if (IS_ENABLED(CONFIG_COMPACTION)&&

                         sc->order > PAGE_ALLOC_COSTLY_ORDER&&

                         zonelist_zone_idx(z) <=requested_highidx &&

                         compaction_ready(zone, sc->order,requested_highidx)) {

                            sc->compaction_ready= true;

                            continue;

                     }

 

                     nr_soft_scanned = 0;

                     nr_soft_reclaimed =mem_cgroup_soft_limit_reclaim(zone,

                                          sc->order,sc->gfp_mask,&nr_soft_scanned);

                     sc->nr_reclaimed +=nr_soft_reclaimed;

                     sc->nr_scanned +=nr_soft_scanned;

                     /* need some check foravoid more shrink_zone() */

              }

 

              shrink_zone(zone, sc,zone_idx(zone) == classzone_idx);

       }

 

       sc->gfp_mask = orig_mask;

}

0 0