lkml.org 
[lkml]   [2022]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mm/khugepaged: sched to numa node when collapse huge page
Date
collapse huge page is slow, specially when khugepaged daemon runs
on different numa node with that of huge page. It suffers from
huge page copying across nodes, also cache is not used for target
node. With this patch, khugepaged daemon switches to the same numa
node with huge page. It saves copying time and makes use of local
cache better.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
mm/khugepaged.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 131492fd1148..460c285dc974 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -116,6 +116,7 @@ struct khugepaged_scan {
struct list_head mm_head;
struct mm_slot *mm_slot;
unsigned long address;
+ int node;
};

static struct khugepaged_scan khugepaged_scan = {
@@ -1066,6 +1067,7 @@ static void collapse_huge_page(struct mm_struct *mm,
struct vm_area_struct *vma;
struct mmu_notifier_range range;
gfp_t gfp;
+ const struct cpumask *cpumask;

VM_BUG_ON(address & ~HPAGE_PMD_MASK);

@@ -1079,6 +1081,13 @@ static void collapse_huge_page(struct mm_struct *mm,
* that. We will recheck the vma after taking it again in write mode.
*/
mmap_read_unlock(mm);
+
+ /* sched to specified node before huage page memory copy */
+ cpumask = cpumask_of_node(node);
+ if ((khugepaged_scan.node != node) && !cpumask_empty(cpumask)) {
+ set_cpus_allowed_ptr(current, cpumask);
+ khugepaged_scan.node = node;
+ }
new_page = khugepaged_alloc_page(hpage, gfp, node);
if (!new_page) {
result = SCAN_ALLOC_HUGE_PAGE_FAIL;
@@ -2380,6 +2389,7 @@ int start_stop_khugepaged(void)
kthread_stop(khugepaged_thread);
khugepaged_thread = NULL;
}
+ khugepaged_scan.node = NUMA_NO_NODE;
set_recommended_min_free_kbytes();
fail:
mutex_unlock(&khugepaged_mutex);
--
2.31.1
\
 
 \ /
  Last update: 2022-03-11 10:03    [W:0.087 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site