Re: [PATCH v7 13/13] vmstat: add pcp remote node draining via cpu_vm_stats_fold

From: Tim Chen
Date: Mon Mar 20 2023 - 16:44:23 EST


On Mon, 2023-03-20 at 15:03 -0300, Marcelo Tosatti wrote:
>
> +
> + if (do_pagesets) {
> + cond_resched();
> + /*
> + * Deal with draining the remote pageset of a
> + * processor
> + *
> + * Check if there are pages remaining in this pageset
> + * if not then there is nothing to expire.
> + */
> + if (!pcp->expire || !pcp->count)
> + continue;refresh_cpu_vm_stats
> +
> + /*
> + * We never drain zones local to this processor.
> + */
> + if (zone_to_nid(zone) == cpu_to_node(cpu)) {
> + pcp->expire = 0;
> + continue;
> + }
> +
> + WARN_ON(pcp->expire < 0);
> + /*
> + * pcp->expire is only accessed from vmstat_shepherd context,
> + * therefore no locking is required.
> + */
> + if (--pcp->expire)
> + continue;
> +
> + if (pcp->count)
> + drain_zone_pages(zone, pcp);
> + }

This logic is the same to that for the do_pagesets portion of code in refresh_cpu_vm_stats().
Is it possible to consolidate to avoid replicating the logic across two functions?

Tim