mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Li Zhe" <lizhe.67@bytedance.com>
To: "Gregory Price" <gourry@gourry.net>
Cc: <akpm@linux-foundation.org>, <david@kernel.org>, <ljs@kernel.org>,
	 <joshua.hahnjy@gmail.com>, <ziy@nvidia.com>, <mingo@redhat.com>,
	 <peterz@infradead.org>, <mgorman@suse.de>, <riel@redhat.com>,
	 <juri.lelli@redhat.com>, <vincent.guittot@linaro.org>,
	 <dietmar.eggemann@arm.com>, <rostedt@goodmis.org>,
	<bsegall@google.com>,  <vschneid@redhat.com>,
	<kprateek.nayak@amd.com>,  <linux-doc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,  <linux-mm@kvack.org>
Subject: Re: [PATCH 2/6] sched/numa: fix scan-period ratio denominator checks
Date: Thu, 15 Oct 2026 11:49:34 +0800	[thread overview]
Message-ID: <4231150e-ea20-473b-bec7-cf2787c1b567@bytedance.com> (raw)
In-Reply-To: <as97rD5uxYva4ayg@gourry-fedora-PF4VCD3F>

On 10/14/26 8:56 PM, Gregory Price wrote:
> On Wed, Oct 14, 2026 at 05:43:43PM +0800, Li Zhe wrote:
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 1053437933ee..76532b8202dc 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -3698,6 +3698,8 @@ static void update_task_scan_period(struct task_struct *p,
>>   
>>   	unsigned long remote = p->numa_faults_locality[0];
>>   	unsigned long local = p->numa_faults_locality[1];
>> +	unsigned long locality_faults = local + remote;
>> +	unsigned long type_faults = private + shared;
>>   
>>   	/*
>>   	 * If there were no record hinting faults then either the task is
>> @@ -3706,7 +3708,7 @@ static void update_task_scan_period(struct task_struct *p,
>>   	 * migration then it implies we are migrating too quickly or the local
>>   	 * node is overloaded. In either case, scan slower
>>   	 */
>> -	if (local + shared == 0 || p->numa_faults_locality[2]) {
>> +	if (!locality_faults || !type_faults || p->numa_faults_locality[2]) {
>>   		p->numa_scan_period = min(p->numa_scan_period_max,
>>   			p->numa_scan_period << 1);
>>
> This does more than just change the div/o below, it changes the behavior
> of the function overall.  It's not clear to me this change is correct.

Yes, this intentionally changes the fallback condition.

The old local + shared check mixes two independent dimensions. The
ratios below are computed from local + remote and private + shared, so
those are the denominators that decide whether the sample is usable.

The old check can also classify a pure remote-private window as an
unusable sample: local == 0 and shared == 0, while remote and private
are non-zero. That is exactly the kind of signal that should go through
the normal scan-period decision, since commit 37ec97deb3a8 wanted to
speed scanning up only when many private faults are on remote memory.

So the fallback is meant to be used when one of the actual ratios cannot
be computed, i.e. when local + remote == 0 or private + shared == 0.
Otherwise the sample should not be discarded before the ratio logic.

Thanks,
Zhe

>
>> @@ -3723,8 +3725,8 @@ static void update_task_scan_period(struct task_struct *p,
>>   	 *	 >= NUMA_PERIOD_THRESHOLD scan period increases (scan slower)
>>   	 */
>>   	period_slot = DIV_ROUND_UP(p->numa_scan_period, NUMA_PERIOD_SLOTS);
>> -	lr_ratio = (local * NUMA_PERIOD_SLOTS) / (local + remote);
>> -	ps_ratio = (private * NUMA_PERIOD_SLOTS) / (private + shared);
>> +	lr_ratio = (local * NUMA_PERIOD_SLOTS) / locality_faults;
>> +	ps_ratio = (private * NUMA_PERIOD_SLOTS) / type_faults;
>>   
> This otherwise looks fine.
>
> ~Gregory

  reply	other threads:[~2026-10-15  3:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14  9:43 [PATCH 0/6] sched/numa: fix several NUMA balancing issues Li Zhe
2026-10-14  9:43 ` [PATCH 1/6] sched/numa: clear fault locality state on execve Li Zhe
2026-10-14 13:02   ` Gregory Price
2026-10-15  3:41     ` Li Zhe
2026-10-14  9:43 ` [PATCH 2/6] sched/numa: fix scan-period ratio denominator checks Li Zhe
2026-10-14 12:56   ` Gregory Price
2026-10-15  3:49     ` Li Zhe [this message]
2026-10-14  9:43 ` [PATCH 3/6] sched/numa: fix scan-period adjustment for shared faults Li Zhe
2026-10-14 13:12   ` Gregory Price
2026-10-14  9:43 ` [PATCH 4/6] sched/numa: make free-space tiering promotion bypass configurable Li Zhe
2026-10-14 13:16   ` Gregory Price
2026-10-15  4:09     ` Li Zhe
2026-10-14  9:43 ` [PATCH 5/6] sched/numa: do not feed tiering promotions into task placement stats Li Zhe
2026-10-14 13:26   ` Gregory Price
2026-10-15  5:07   ` kernel test robot
2026-10-15  5:07   ` kernel test robot
2026-10-14  9:43 ` [PATCH 6/6] sched/numa: ignore preferred nodes without normal balancing Li Zhe
2026-10-14 13:30   ` Gregory Price

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=4231150e-ea20-473b-bec7-cf2787c1b567@bytedance.com \
    --to=lizhe.67@bytedance.com \
    --cc=akpm@linux-foundation.org \
    --cc=bsegall@google.com \
    --cc=david@kernel.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=gourry@gourry.net \
    --cc=joshua.hahnjy@gmail.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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

all inboxes | Powered by JetHome®