Skip to contentSkip to conversation

mm: Fix incorrect mempolicy for idle threads

PATCH New Ravikiran G Thirumalai 1 participant 1 message Oct 3, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: Fix incorrect mempolicy for idle threads

The kernel boots up on the BP with an initial memory policy of MPOL_INTERLEAVE (start_kernel() -> numa_policy_init()). This is done to avoid all boot data structure allocations to be off the boot node. Current mainline resets the memory policy to MPOL_DEFAULT at init(), just before calling userspace init. But, this is too late and leaves the kernel idle thread with MPOL_INTERLEAVE, causing later allocations off interrupt/BH context to use MPOL_INTERLEAVE, rather than MPOL_DEFAULT (if the interrupt occurs on an idle cpu). This can be fixed by changing the mempolicy to MPOL_DEFAULT just before the 'init' kernel thread is spawned, OR just before smp_init() (smp_init would spawn idle threads). The following patch uses the latter approach and moves numa_default_policy() to just before smp_init().

init/main.c +2 -1
Index: linux-2.6.18/init/main.c
===================================================================
@@ -703,6 +703,8 @@ static int init(void * unused)
 
 	do_pre_smp_initcalls();
 
+	numa_default_policy();
+
 	smp_init();
 	sched_init_smp();
 
@@ -738,7 +740,6 @@ static int init(void * unused)
 	unlock_kernel();
 	mark_rodata_ro();
 	system_state = SYSTEM_RUNNING;
-	numa_default_policy();
 
 	if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
 		printk(KERN_WARNING "Warning: unable to open an initial console.\n");