From: Matthew Dobson sched_best_cpu schedules processes on nodes based on node_nr_running. For CPU-less nodes, this is always 0, and thus sched_best_cpu tends to migrate tasks to these nodes, which eventually get remigrated elsewhere. Patch 1/3: This patch adds include/linux/topology.h, and modifies all includes of asm/topology.h to linux/topology.h. A subsequent patch in this series adds helper functions to linux/topology.h to ensure processes are only migrated to nodes with CPUs. Test compiled and booted by Andrew Theurer (habanero@us.ibm.com) on both x440 and ppc64. 25-akpm/drivers/base/cpu.c | 3 +-- 25-akpm/drivers/base/memblk.c | 3 +-- 25-akpm/drivers/base/node.c | 3 +-- 25-akpm/include/asm-i386/cpu.h | 2 +- 25-akpm/include/asm-i386/memblk.h | 2 +- 25-akpm/include/asm-i386/node.h | 3 +-- 25-akpm/include/linux/mmzone.h | 2 +- 25-akpm/include/linux/topology.h | 32 ++++++++++++++++++++++++++++++++ 25-akpm/mm/page_alloc.c | 3 +-- 25-akpm/mm/vmscan.c | 2 +- 10 files changed, 41 insertions(+), 14 deletions(-) diff -puN drivers/base/cpu.c~sched_best_cpu-fix-01 drivers/base/cpu.c --- 25/drivers/base/cpu.c~sched_best_cpu-fix-01 Tue Jun 3 13:03:25 2003 +++ 25-akpm/drivers/base/cpu.c Tue Jun 3 13:03:25 2003 @@ -6,8 +6,7 @@ #include #include #include - -#include +#include struct class cpu_class = { diff -puN drivers/base/memblk.c~sched_best_cpu-fix-01 drivers/base/memblk.c --- 25/drivers/base/memblk.c~sched_best_cpu-fix-01 Tue Jun 3 13:03:25 2003 +++ 25-akpm/drivers/base/memblk.c Tue Jun 3 13:03:25 2003 @@ -7,8 +7,7 @@ #include #include #include - -#include +#include static struct class memblk_class = { diff -puN drivers/base/node.c~sched_best_cpu-fix-01 drivers/base/node.c --- 25/drivers/base/node.c~sched_best_cpu-fix-01 Tue Jun 3 13:03:25 2003 +++ 25-akpm/drivers/base/node.c Tue Jun 3 13:03:25 2003 @@ -7,8 +7,7 @@ #include #include #include - -#include +#include static struct class node_class = { diff -puN include/asm-i386/cpu.h~sched_best_cpu-fix-01 include/asm-i386/cpu.h --- 25/include/asm-i386/cpu.h~sched_best_cpu-fix-01 Tue Jun 3 13:03:25 2003 +++ 25-akpm/include/asm-i386/cpu.h Tue Jun 3 13:03:25 2003 @@ -3,8 +3,8 @@ #include #include +#include -#include #include struct i386_cpu { diff -puN include/asm-i386/memblk.h~sched_best_cpu-fix-01 include/asm-i386/memblk.h --- 25/include/asm-i386/memblk.h~sched_best_cpu-fix-01 Tue Jun 3 13:03:25 2003 +++ 25-akpm/include/asm-i386/memblk.h Tue Jun 3 13:03:25 2003 @@ -4,8 +4,8 @@ #include #include #include +#include -#include #include struct i386_memblk { diff -puN include/asm-i386/node.h~sched_best_cpu-fix-01 include/asm-i386/node.h --- 25/include/asm-i386/node.h~sched_best_cpu-fix-01 Tue Jun 3 13:03:25 2003 +++ 25-akpm/include/asm-i386/node.h Tue Jun 3 13:03:25 2003 @@ -4,8 +4,7 @@ #include #include #include - -#include +#include struct i386_node { struct node node; diff -puN include/linux/mmzone.h~sched_best_cpu-fix-01 include/linux/mmzone.h --- 25/include/linux/mmzone.h~sched_best_cpu-fix-01 Tue Jun 3 13:03:25 2003 +++ 25-akpm/include/linux/mmzone.h Tue Jun 3 13:03:25 2003 @@ -255,7 +255,7 @@ static inline struct zone *next_zone(str #define MAX_NR_MEMBLKS 1 #endif /* CONFIG_NUMA */ -#include +#include /* Returns the number of the current Node. */ #define numa_node_id() (cpu_to_node(smp_processor_id())) diff -puN /dev/null include/linux/topology.h --- /dev/null Thu Apr 11 07:25:15 2002 +++ 25-akpm/include/linux/topology.h Tue Jun 3 13:03:25 2003 @@ -0,0 +1,32 @@ +/* + * include/linux/topology.h + * + * Written by: Matthew Dobson, IBM Corporation + * + * Copyright (C) 2002, IBM Corp. + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Send feedback to + */ +#ifndef _LINUX_TOPOLOGY_H +#define _LINUX_TOPOLOGY_H + +#include + +#endif /* _LINUX_TOPOLOGY_H */ diff -puN mm/page_alloc.c~sched_best_cpu-fix-01 mm/page_alloc.c --- 25/mm/page_alloc.c~sched_best_cpu-fix-01 Tue Jun 3 13:03:25 2003 +++ 25-akpm/mm/page_alloc.c Tue Jun 3 13:03:25 2003 @@ -28,8 +28,7 @@ #include #include #include - -#include +#include DECLARE_BITMAP(node_online_map, MAX_NUMNODES); DECLARE_BITMAP(memblk_online_map, MAX_NR_MEMBLKS); diff -puN mm/vmscan.c~sched_best_cpu-fix-01 mm/vmscan.c --- 25/mm/vmscan.c~sched_best_cpu-fix-01 Tue Jun 3 13:03:25 2003 +++ 25-akpm/mm/vmscan.c Tue Jun 3 13:03:25 2003 @@ -28,10 +28,10 @@ #include #include #include +#include #include #include -#include #include #include _