From: "Chen, Yu C" <yu.c.chen@intel.com>
To: Libo Chen <libo.chen@oracle.com>
Cc: <kprateek.nayak@amd.com>, <raghavendra.kt@amd.com>,
<tim.c.chen@intel.com>, <vineethr@linux.ibm.com>,
<chris.hyser@oracle.com>, <daniel.m.jordan@oracle.com>,
<lorenzo.stoakes@oracle.com>, <mkoutny@suse.com>,
<Dhaval.Giani@amd.com>, <cgroups@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <mingo@redhat.com>,
<mgorman@suse.de>, <vincent.guittot@linaro.org>,
<rostedt@goodmis.org>, <llong@redhat.com>,
<akpm@linux-foundation.org>, <tj@kernel.org>,
<juri.lelli@redhat.com>, <peterz@infradead.org>,
<yu.chen.surf@foxmail.com>
Subject: Re: [PATCH v3 1/2] sched/numa: Skip VMA scanning on memory pinned to one NUMA node via cpuset.mems
Date: Wed, 23 Apr 2025 07:27:48 +0800 [thread overview]
Message-ID: <b3661d40-536e-4a07-8872-7c5ae5e1166e@intel.com> (raw)
In-Reply-To: <2ce24cae-12fc-4a28-8396-c5b46a5f76d3@oracle.com>
On 4/23/2025 6:20 AM, Libo Chen wrote:
> Hi Yu
>
> On 4/19/25 04:16, Chen, Yu C wrote:
>> Hi Libo,
>>
>> On 4/18/2025 3:15 AM, Libo Chen wrote:
>>> When the memory of the current task is pinned to one NUMA node by cgroup,
>>> there is no point in continuing the rest of VMA scanning and hinting page
>>> faults as they will just be overhead. With this change, there will be no
>>> more unnecessary PTE updates or page faults in this scenario.
>>>
>>> We have seen up to a 6x improvement on a typical java workload running on
>>> VMs with memory and CPU pinned to one NUMA node via cpuset in a two-socket
>>> AARCH64 system. With the same pinning, on a 18-cores-per-socket Intel
>>> platform, we have seen 20% improvment in a microbench that creates a
>>> 30-vCPU selftest KVM guest with 4GB memory, where each vCPU reads 4KB
>>> pages in a fixed number of loops.
>>>
>>> Signed-off-by: Libo Chen <libo.chen@oracle.com>
>>
>> I think this is a promising change that we can perform fine-grain NUMA
>> balance control on a per-cgroup basis rather than system-wide NUMA
>> balance for every task, which is costly.
>>
>
> Yes indeed, the cost, from we have seen, can be quite astonishing
>
>>> ---
>>> kernel/sched/fair.c | 7 +++++++
>>> 1 file changed, 7 insertions(+)
>>>
>>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>>> index e43993a4e5807..c9903b1b39487 100644
>>> --- a/kernel/sched/fair.c
>>> +++ b/kernel/sched/fair.c
>>> @@ -3329,6 +3329,13 @@ static void task_numa_work(struct callback_head *work)
>>> if (p->flags & PF_EXITING)
>>> return;
>>> + /*
>>> + * Memory is pinned to only one NUMA node via cpuset.mems, naturally
>>> + * no page can be migrated.
>>> + */
>>> + if (cpusets_enabled() && nodes_weight(cpuset_current_mems_allowed) == 1)
>>> + return;
>>> +
>>
>> I found that you had a proposal in V1 to address Peter's concern[1]:
>> Allow the task to be migrated to its preferred Node, even if the task's
>> memory policy is restricted to 1 Node. In your previous proposal, only if the task's cpumask is bound to the same Node as its memory policy node, the NUMA balance scanning is skipped, because a cgroup usually binds its tasks and memory allocation policy to the same node. Not sure if that could be turned into:
>>
>> If the task's memory policy node's CPU mask is a subset of the task's cpumask, the NUMA balance scan is allowed.
>>
>
> I guess fundamentally is this really worth it? Do the benefits of NUMA task migrations only outweigh the overheads of VMA scanning, PTE updates and page faults etc? I suppose this is workload-dependent, but what about the best-case scenario? I think we probably need more data. Also if we do that, we also need to do the same for other VMA skipping scenarios.
>
Overall that can be a future work and I agree for now this patch is
simple enough and feel free to add:
Tested-by: Chen Yu <yu.c.chen@intel.com>
thanks,
Chenyu
next prev parent reply other threads:[~2025-04-22 23:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-17 19:15 [PATCH v3 0/2] sched/numa: Skip VMA scanning on memory pinned Libo Chen
2025-04-17 19:15 ` [PATCH v3 1/2] sched/numa: Skip VMA scanning on memory pinned to one NUMA node via cpuset.mems Libo Chen
2025-04-19 11:16 ` Chen, Yu C
2025-04-22 22:20 ` Libo Chen
2025-04-22 23:27 ` Chen, Yu C [this message]
2025-04-17 19:15 ` [PATCH v3 2/2] sched/numa: Add tracepoint that tracks the skipping of numa balancing due to cpuset memory pinning Libo Chen
2025-04-23 15:34 ` Steven Rostedt
2025-04-23 16:05 ` Libo Chen
2025-04-23 16:12 ` Steven Rostedt
2025-04-23 16:50 ` Libo Chen
2025-04-23 16:56 ` Steven Rostedt
2025-04-23 16:57 ` Steven Rostedt
2025-04-23 18:22 ` Libo Chen
2025-04-17 20:12 ` [PATCH v3 0/2] sched/numa: Skip VMA scanning on memory pinned Andrew Morton
2025-04-17 21:07 ` Libo Chen
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=b3661d40-536e-4a07-8872-7c5ae5e1166e@intel.com \
--to=yu.c.chen@intel.com \
--cc=Dhaval.Giani@amd.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=chris.hyser@oracle.com \
--cc=daniel.m.jordan@oracle.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=libo.chen@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llong@redhat.com \
--cc=lorenzo.stoakes@oracle.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=peterz@infradead.org \
--cc=raghavendra.kt@amd.com \
--cc=rostedt@goodmis.org \
--cc=tim.c.chen@intel.com \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vineethr@linux.ibm.com \
--cc=yu.chen.surf@foxmail.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®