On Tue, Feb 23, 2016 at 03:04:31PM +0000, Mel Gorman wrote: > @@ -3299,20 +3191,37 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) > break; > > /* > + * Stop reclaiming if any eligible zone is balanced and clear > + * node writeback or congested. > + */ > + for (i = 0; i <= classzone_idx; i++) { > + zone = pgdat->node_zones + i; > + if (!populated_zone(zone)) > + continue; > + > + if (zone_balanced(zone, sc.order, 0, classzone_idx)) { > + clear_bit(PGDAT_CONGESTED, &pgdat->flags); > + clear_bit(PGDAT_DIRTY, &pgdat->flags); > + goto out; > + } > + } > + > + /* > * Raise priority if scanning rate is too low or there was no > * progress in reclaiming pages > */ > if (raise_priority || !sc.nr_reclaimed) > sc.priority--; > - } while (sc.priority >= 1 && > - !pgdat_balanced(pgdat, order, classzone_idx)); > + } while (sc.priority >= 1); > > out: > /* > - * Return the highest zone idx we were reclaiming at so > - * prepare_kswapd_sleep() makes the same decisions as here. > + * Return the order we were reclaiming at so prepare_kswapd_sleep() > + * makes a decision on the order we were last reclaiming at. However, > + * if another caller entered the allocator slow path while kswapd > + * was awake, order will remain at the higher level > */ > - return end_zone; > + return order; It's sc.order that's updated based on fragmentation, not order. There is also a now-stale comment above the function saying it returns the highest reclaimed zone index. Otherwise, the patch looks good to me. Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>