Re: [PATCH 1/3] mm, vmscan: fix zone balance check in prepare_kswapd_sleep
From: Mel Gorman
Date: Thu Feb 23 2017 - 10:06:58 EST
On Wed, Feb 22, 2017 at 04:00:36PM +0900, Minchan Kim wrote:
> > There are also more allocation stalls. One of the largest impacts was due
> > to pages written back from kswapd context rising from 0 pages to 4516642
> > pages during the hour the workload ran for. By and large, the patch has very
> > bad behaviour but easily missed as the impact on a UMA machine is negligible.
> > This patch is included with the data in case a bisection leads to this area.
> > This patch is also a pre-requisite for the rest of the series.
> > Signed-off-by: Shantanu Goel <sgoel01@xxxxxxxxx>
> > Signed-off-by: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx>
> Hmm, I don't understand why we should bind wakeup_kcompactd to kswapd's
> short sleep point where every eligible zones are balanced.
> What's the correlation between them?
If kswapd is ready for a short sleep, eligible zones are balanced for
order-0 but not necessarily the originally requested order if kswapd
gave up reclaiming as compaction was ready to start. As kswapd is ready
to sleep for a short period, it's a suitable time for kcompactd to decide
if it should start working or not. There is no need for kswapd to be aware
of kcompactd's wakeup criteria.
> Can't we wake up kcompactd once we found a zone has enough free pages
> above high watermark like this?
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 26c3b405ef34..f4f0ad0e9ede 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -3346,13 +3346,6 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o
> * that pages and compaction may succeed so reset the cache.
> - /*
> - * We have freed the memory, now we should compact it to make
> - * allocation of the requested order possible.
> - */
> - wakeup_kcompactd(pgdat, alloc_order, classzone_idx);
> remaining = schedule_timeout(HZ/10);
> @@ -3451,6 +3444,14 @@ static int kswapd(void *p)
> bool ret;
> + /*
> + * We have freed the memory, now we should compact it to make
> + * allocation of the requested order possible.
> + */
> + if (alloc_order > 0 && zone_balanced(zone, reclaim_order,
> + classzone_idx))
> + wakeup_kcompactd(pgdat, alloc_order, classzone_idx);
> kswapd_try_to_sleep(pgdat, alloc_order, reclaim_order,
That's functionally very similar to what happens already. wakeup_kcompactd
checks the order and does not wake for order-0. It also makes its own
decisions that include zone_balanced on whether it is safe to wakeup.
I doubt there would be any measurable difference from a patch like this
and to my mind at least, it does not improve the readability or flow of