MM: zero memory at free and deferred zero

Change-Id: Ib0055d6f2bdd10d05d749dcd1f3d5c3d318f22f3
This commit is contained in:
Masamichi Takagi
2020-12-08 11:59:08 +09:00
parent fbd121d28c
commit 100bbe6231
7 changed files with 263 additions and 18 deletions

View File

@@ -792,6 +792,27 @@ order_based:
return NULL;
}
/*
* Get NUMA node structure offsetted by index in the order of distance
*/
struct ihk_mc_numa_node *ihk_mc_get_numa_node_by_distance(int i)
{
int numa_id;
if (!cpu_local_var_initialized)
return NULL;
if (i < 0 || i > ihk_mc_get_nr_numa_nodes()) {
return NULL;
}
numa_id = ihk_mc_get_numa_id();
if (!memory_nodes[numa_id].nodes_by_distance)
return NULL;
return &memory_nodes[memory_nodes[numa_id].nodes_by_distance[i].id];
}
static void __mckernel_free_pages_in_allocator(void *va, int npages,
int is_user)
{
@@ -1465,11 +1486,13 @@ static void numa_init(void)
INIT_LIST_HEAD(&memory_nodes[i].allocators);
memory_nodes[i].nodes_by_distance = 0;
#ifdef IHK_RBTREE_ALLOCATOR
memory_nodes[i].zeroed_chunks.rb_node = 0;
memory_nodes[i].free_chunks.rb_node = 0;
mcs_lock_init(&memory_nodes[i].lock);
memory_nodes[i].min_addr = 0xFFFFFFFFFFFFFFFF;
memory_nodes[i].max_addr = 0;
memory_nodes[i].nr_pages = 0;
memory_nodes[i].nr_zeroed_pages = 0;
memory_nodes[i].nr_free_pages = 0;
#endif
}

View File

@@ -3122,6 +3122,7 @@ static void idle(void)
v->status == CPU_STATUS_RESERVED) {
/* No work to do? Consolidate the kmalloc free list */
kmalloc_consolidate_free_list();
ihk_numa_zero_free_pages(ihk_mc_get_numa_node_by_distance(0));
monitor->status = IHK_OS_MONITOR_IDLE;
cpu_local_var(current)->status = PS_INTERRUPTIBLE;
cpu_safe_halt();
@@ -3477,6 +3478,7 @@ void spin_sleep_or_schedule(void)
break;
}
ihk_numa_zero_free_pages(ihk_mc_get_numa_node_by_distance(0));
cpu_pause();
}

View File

@@ -266,6 +266,7 @@ long do_syscall(struct syscall_request *req, int cpu)
cpu_restore_interrupt(runq_irqstate);
if (!do_schedule) {
ihk_numa_zero_free_pages(ihk_mc_get_numa_node_by_distance(0));
continue;
}

View File

@@ -102,6 +102,7 @@ uint64_t schedule_timeout(uint64_t timeout)
/* Spin wait */
while ((rdtsc() - t_s) < LOOP_TIMEOUT) {
ihk_numa_zero_free_pages(ihk_mc_get_numa_node_by_distance(0));
cpu_pause();
}