Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e42c8ff2 authored by Mel Gorman's avatar Mel Gorman
Browse files

mm: numa: Use a two-stage filter to restrict pages being migrated for unlikely...


mm: numa: Use a two-stage filter to restrict pages being migrated for unlikely task<->node relationships

Note: This two-stage filter was taken directly from the sched/numa patch
	"sched, numa, mm: Add the scanning page fault machinery" but is
	only a partial extraction. As the end result is not necessarily
	recognisable, the signed-offs-by had to be removed. Will be added
	back if requested.

While it is desirable that all threads in a process run on its home
node, this is not always possible or necessary. There may be more
threads than exist within the node or the node might over-subscribed
with unrelated processes.

This can cause a situation whereby a page gets migrated off its home
node because the threads clearing pte_numa were running off-node. This
patch uses page->last_nid to build a two-stage filter before pages get
migrated to avoid problems with short or unlikely task<->node
relationships.

Signed-off-by: default avatarMel Gorman <mgorman@suse.de>
parent bac0382c
Loading
Loading
Loading
Loading
+29 −1
Original line number Diff line number Diff line
@@ -2317,9 +2317,37 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long
	}

	/* Migrate the page towards the node whose CPU is referencing it */
	if (pol->flags & MPOL_F_MORON)
	if (pol->flags & MPOL_F_MORON) {
		int last_nid;

		polnid = numa_node_id();

		/*
		 * Multi-stage node selection is used in conjunction
		 * with a periodic migration fault to build a temporal
		 * task<->page relation. By using a two-stage filter we
		 * remove short/unlikely relations.
		 *
		 * Using P(p) ~ n_p / n_t as per frequentist
		 * probability, we can equate a task's usage of a
		 * particular page (n_p) per total usage of this
		 * page (n_t) (in a given time-span) to a probability.
		 *
		 * Our periodic faults will sample this probability and
		 * getting the same result twice in a row, given these
		 * samples are fully independent, is then given by
		 * P(n)^2, provided our sample period is sufficiently
		 * short compared to the usage pattern.
		 *
		 * This quadric squishes small probabilities, making
		 * it less likely we act on an unlikely task<->page
		 * relation.
		 */
		last_nid = page_xchg_last_nid(page, polnid);
		if (last_nid != polnid)
			goto out;
	}

	if (curnid != polnid)
		ret = polnid;
out: