Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Gregory Price (Meta)" <gourry@gourry.net>, linux-mm@kvack.org
Cc: kernel-team@meta.com, akpm@linux-foundation.org,
	david@kernel.org, ljs@kernel.org, liam@infradead.org,
	vbabka@kernel.org, rppt@kernel.org, surenb@google.com,
	mhocko@suse.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com,
	mgorman@techsingularity.net, mingo@kernel.org,
	vschneid@redhat.com, kprateek.nayak@amd.com, ziy@nvidia.com,
	baolin.wang@linux.alibaba.com, nico.pache@linux.dev,
	ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org,
	lance.yang@linux.dev, usama.arif@linux.dev, kas@kernel.org,
	joshua.hahnjy@gmail.com, rakie.kim@sk.com,
	ying.huang@linux.alibaba.com, matthew.brost@intel.com,
	byungchul@sk.com, apopple@nvidia.com, jannh@google.com,
	pfalcato@suse.de, hannes@cmpxchg.org, osalvador@suse.de,
	raghavendra.kt@amd.com
Subject: Re: [PATCH v5 5/7] sched/numa: scan PID-inactive VMAs for promotion
Date: Tue, 10 Nov 2026 19:33:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-207664@kernel.org> (raw)
In-Reply-To: <20261110150446.2452975-6-gourry@gourry.net>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/numa: skipped VMA scan completion update in
  task_numa_work()
--

commit f65331bdcd950c59eb449c304cff02b0db3d6e66
Author: Gregory Price (Meta) <gourry@gourry.net>

sched/numa: scan PID-inactive VMAs for promotion

This commit allows memory tiering to scan PID-inactive VMAs with
promotion-only scans when placement sampling is not due, and tracks the
last completed placement scan sequence separately from promotion-only
scans.

> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 778ba0ed34fe8..279bf12b74b64 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
[ ... ]
> @@ -4506,8 +4519,14 @@ static void task_numa_work(struct callback_head *work)
>  			cond_resched();
>  		} while (end != vma->vm_end);
>  
> -		/* VMA scan is complete, do not scan until next sequence. */
> +		/*
> +		 * VMA scan is complete, do not scan until next sequence.
> +		 * A promotion-only scan did not cover top-tier folios, so it
> +		 * does not count towards the placement-scan starvation check.
> +		 */
>  		vma->numab_state->prev_scan_seq = mm->numa_scan_seq;
> +		if (placement_scan)
> +			vma->numab_state->prev_placement_scan_seq = mm->numa_scan_seq;
>  		vma->numab_state->promo_only = false;

[Severity: Medium]
Can task_numa_work() skip updating prev_placement_scan_seq, prev_scan_seq
and promo_only when the final chunk of a VMA exhausts the scan budget?

Inside the loop right above this block, task_numa_work() jumps to out when
pages <= 0 || virtpages <= 0 before checking while (end != vma->vm_end):

kernel/sched/fair.c:task_numa_work() {
	...
			if (nr_pte_updates)
				pages -= (end - start) >> PAGE_SHIFT;
			virtpages -= (end - start) >> PAGE_SHIFT;

			start = end;
			if (pages <= 0 || virtpages <= 0)
				goto out;

			cond_resched();
		} while (end != vma->vm_end);
	...
out:
	if (vma)
		mm->numa_scan_offset = start;
	...
}

When a VMA's size (or remaining unscanned range) is an exact multiple of
sysctl_numa_balancing_scan_size, the last chunk reaches end == vma->vm_end
with pages <= 0 and jumps to out.  That sets mm->numa_scan_offset to
vma->vm_end, so the next task_numa_work() call moves on to the next VMA
without ever running the completion block for the finished VMA.

Because prev_placement_scan_seq is never updated on such a VMA,
vma_needs_placement_scan() permanently returns true once mm->numa_scan_seq
passes prev_placement_scan_seq + get_nr_threads(current), preventing
promotion-only scans on PID-inactive VMAs.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261110150446.2452975-1-gourry@gourry.net?part=5


  reply	other threads:[~2026-11-10 19:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 15:04 [PATCH v5 0/7] sched/numa: stop VMA scan filters from gating promotion Gregory Price (Meta)
2026-11-10 15:04 ` [PATCH v5 1/7] mm: support promotion-only NUMA hinting scans Gregory Price (Meta)
2026-11-10 15:04 ` [PATCH v5 2/7] mm: allow shared folios to be promoted to a fast tier Gregory Price (Meta)
2026-11-12  4:04   ` Bharata B Rao
2026-11-10 15:04 ` [PATCH v5 3/7] sched/numa: scan read-only file mappings in tiering mode Gregory Price (Meta)
2026-11-10 15:04 ` [PATCH v5 4/7] sched/numa: separate VMA placement from scan continuation Gregory Price (Meta)
2026-11-10 15:04 ` [PATCH v5 5/7] sched/numa: scan PID-inactive VMAs for promotion Gregory Price (Meta)
2026-11-10 19:33   ` sashiko-bot [this message]
2026-11-10 20:36   ` Gregory Price (Meta)
2026-11-10 15:04 ` [PATCH v5 6/7] mm: use BIT() for change_protection() flags Gregory Price (Meta)
2026-11-10 15:16   ` Lorenzo Stoakes (ARM)
2026-11-10 15:04 ` [PATCH v5 7/7] mm: use VMA flag helpers in NUMA balancing Gregory Price (Meta)
2026-11-10 15:15   ` Lorenzo Stoakes (ARM)
2026-11-10 16:24     ` Gregory Price (Meta)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-207664@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=bsegall@google.com \
    --cc=byungchul@sk.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=gourry@gourry.net \
    --cc=hannes@cmpxchg.org \
    --cc=jannh@google.com \
    --cc=joshua.hahnjy@gmail.com \
    --cc=juri.lelli@redhat.com \
    --cc=kas@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kprateek.nayak@amd.com \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=nico.pache@linux.dev \
    --cc=osalvador@suse.de \
    --cc=peterz@infradead.org \
    --cc=pfalcato@suse.de \
    --cc=raghavendra.kt@amd.com \
    --cc=rakie.kim@sk.com \
    --cc=rostedt@goodmis.org \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=surenb@google.com \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=ying.huang@linux.alibaba.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox