pgdat_balanced

来源:互联网 发布:union软件 编辑:程序博客网 时间:2024/05/18 23:13

 

/*

 * pgdat_balanced() is used when checking if anode is balanced.

 *

 * For order-0, all zones must be balanced!

 *

 * For high-order allocations only zones thatmeet watermarks and are in a

 * zone allowed by the callers classzone_idxare added to balanced_pages. The

 * total of balanced pages must be at least 25%of the zones allowed by

 * classzone_idx for the node to be consideredbalanced. Forcing all zones to

 * be balanced for high orders can causeexcessive reclaim when there are

 * imbalanced zones.

 * The choice of 25% is due to

 *   o a16M DMA zone that is balanced will not balance a zone on any

 *    reasonable sized machine

 *   o Onall other machines, the top zone must be at least a reasonable

 *    percentage of the middle zones. For example, on 32-bit x86, highmem

 *    would need to be at least 256M for it to be balance a whole node.

 *    Similarly, on x86-64 the Normal zone would need to be at least 1G

 *     tobalance a node on its own. These seemed like reasonable ratios.

 */

static bool pgdat_balanced(pg_data_t *pgdat, int order, intclasszone_idx)

{

       unsigned long managed_pages = 0;

       unsigned long balanced_pages = 0;

       int i;

 

       /* Check the watermark levels */

       for(i = 0; i <= classzone_idx; i++) {

              struct zone *zone =pgdat->node_zones + i;

 

              if (!populated_zone(zone))

                     continue;

 

              managed_pages +=zone->managed_pages;

              if (!zone_reclaimable(zone)) {

                     balanced_pages +=zone->managed_pages;

                     continue;

              }

 

              if (zone_balanced(zone, order, false, 0, i))

                     balanced_pages +=zone->managed_pages;

              else if (!order)

                     return false;

       }

 

       if (order)

              return balanced_pages >= (managed_pages >> 2);

       else

              return true;

}

0 0
原创粉丝点击