10 Matching Annotations
  1. Last 7 days
    1. /* * !costly requests are much more important than * __GFP_RETRY_MAYFAIL costly ones because they are de * facto nofail and invoke OOM killer to move on while * costly can fail and users are ready to cope with * that. 1/4 retries is rather arbitrary but we would * need much more detailed feedback from compaction to * make a better decision. */ if (order > PAGE_ALLOC_COSTLY_ORDER) max_retries /= 4; if (++(*compaction_retries) <= max_retries) { ret = true; goto out; }

      PAGE_ALLOC_COSTLY_ORDER and 1/4 retries are also based on a heuristic.

    2. if (!order || order > PAGE_ALLOC_COSTLY_ORDER)

      Here using PAGE_ALLOC_COSTLY_ORDER to determine whether should retry the compact or not. PAGE_ALLOC_COSTLY_ORDER is a constant value served as a heuristic policy.

    3. if (did_some_progress && order <= PAGE_ALLOC_COSTLY_ORDER) *no_progress_loops = 0; else (*no_progress_loops)++;

      Here using PAGE_ALLOC_COSTLY_ORDER to determine whether should retry the reclaim or not. PAGE_ALLOC_COSTLY_ORDER is a constant value served as a heuristic policy.

    4. if (gfp_mask & __GFP_NORETRY)

      gfp_mask is provided by caller. This configuration determine whether the function would retry to allocate pages or not.

    5. if (!can_direct_reclaim)

      Caller's gfp_t specify whether would want to reclaim if failed to directly allocate.

    6. if (costly_order && (gfp_mask & __GFP_NORETRY))

      const bool costly_order = order > PAGE_ALLOC_COSTLY_ORDER; The value of PAGE_ALLOC_COSTLY_ORDER is defined as 3. The costly allocation will happens based on this heuristic value.

    7. if (can_direct_reclaim && can_compact && (costly_order || (order > 0 && ac->migratetype != MIGRATE_MOVABLE)) && !gfp_pfmemalloc_allowed(gfp_mask))

      const bool costly_order = order > PAGE_ALLOC_COSTLY_ORDER; The value of PAGE_ALLOC_COSTLY_ORDER is defined as 3. The costly allocation will happens based on this heuristic value.

    8. high = max(high, batch << 2);

      Heuristic way to determine the value of high (based on historical relationship between high and batch)

    9. batch = min(zone_managed_pages(zone) >> 10, SZ_1M / PAGE_SIZE); batch /= 4; /* We effectively *= 4 below */ if (batch < 1) batch = 1; /* * Clamp the batch to a 2^n - 1 value. Having a power * of 2 value was found to be more likely to have * suboptimal cache aliasing properties in some cases. * * For example if 2 tasks are alternately allocating * batches of pages, one task can end up with a lot * of pages of one half of the possible page colors * and the other with pages of the other colors. */ batch = rounddown_pow_of_two(batch + batch/2) - 1;

      Using a heuristic way to decide the number of pages (for batch allocating)

    10. if (!node_isset(node, *used_node_mask)) { node_set(node, *used_node_mask); return node; } for_each_node_state(n, N_MEMORY) { /* Don't want a node to appear more than once */ if (node_isset(n, *used_node_mask)) continue; /* Use the distance array to find the distance */ val = node_distance(node, n); /* Penalize nodes under us ("prefer the next node") */ val += (n < node); /* Give preference to headless and unused nodes */ if (!cpumask_empty(cpumask_of_node(n))) val += PENALTY_FOR_NODE_WITH_CPUS; /* Slight preference for less loaded node */ val *= MAX_NUMNODES; val += node_load[n]; if (val < min_val) { min_val = val; best_node = n; } } if (best_node >= 0) node_set(best_node, *used_node_mask);

      Determine the next best node based on some criteria