[patch 7/8] cpusets v3 - The few, small kernel hooks needed

[patch 7/8] cpusets v3 - The few, small kernel hooks needed

Post by Paul Jacks » Wed, 30 Jun 2004 20:30:15


puset kernel hooks in init, exit, fork, sched_setaffinity,
Kconfig and sched.h.

These hooks establish and propogate cpusets, and enforce
their CPU placement limitations on sched_setaffinity, and
Memory Node placement limitations on mbind, sys_set_mempolicy.

Index: 2.6.7-mm4/include/linux/sched.h
===================================================================
--- 2.6.7-mm4.orig/include/linux/sched.h 2004-06-29 03:54:46.000000000 -0700
+++ 2.6.7-mm4/include/linux/sched.h 2004-06-29 03:55:38.000000000 -0700
@@ -366,6 +366,7 @@ struct k_itimer {

struct io_context; /* See blkdev.h */
void exit_io_context(void);
+struct cpuset;

#define NGROUPS_SMALL 32
#define NGROUPS_PER_BLOCK ((int)(PAGE_SIZE / sizeof(gid_t)))
@@ -535,6 +536,10 @@ struct task_struct {
struct mempolicy *mempolicy;
short il_next; /* could be shared with used_math */
#endif
+
+#ifdef CONFIG_CPUSETS
+ struct cpuset *cpuset;
+#endif
};

static inline pid_t process_group(struct task_struct *tsk)
Index: 2.6.7-mm4/init/Kconfig
===================================================================
--- 2.6.7-mm4.orig/init/Kconfig 2004-06-29 03:54:39.000000000 -0700
+++ 2.6.7-mm4/init/Kconfig 2004-06-29 03:55:38.000000000 -0700
@@ -279,6 +279,16 @@ config EPOLL
Disabling this option will cause the kernel to be built without
support for epoll family of system calls.

+config CPUSETS
+ bool "Cpuset support"
+ help
+ This options will let you create and manage CPUSET's which
+ allow dynamically partitioning a system into sets of CPUs and
+ Memory Nodes and assigning tasks to run only within those sets.
+ This is primarily useful on large SMP or NUMA systems.
+
+ Say N if unsure.
+
source "drivers/block/Kconfig.iosched"

config CC_OPTIMIZE_FOR_SIZE
Index: 2.6.7-mm4/init/main.c
===================================================================
--- 2.6.7-mm4.orig/init/main.c 2004-06-29 03:54:43.000000000 -0700
+++ 2.6.7-mm4/init/main.c 2004-06-29 03:55:38.000000000 -0700
@@ -41,6 +41,7 @@
#include <linux/writeback.h>
#include <linux/cpu.h>
#include <linux/efi.h>
+#include <linux/cpuset.h>
#include <linux/unistd.h>
#include <linux/rmap.h>
#include <linux/mempolicy.h>
@@ -536,6 +537,8 @@ asmlinkage void __init start_kernel(void
#ifdef CONFIG_PROC_FS
proc_root_init();
#endif
+ cpuset_init();
+
check_bugs();

/* Do the rest non-__init'ed, we're now alive */
Index: 2.6.7-mm4/kernel/exit.c
===================================================================
--- 2.6.7-mm4.orig/kernel/exit.c 2004-06-29 03:54:39.000000000 -0700
+++ 2.6.7-mm4/kernel/exit.c 2004-06-29 03:55:38.000000000 -0700
@@ -28,6 +28,7 @@
#include <asm/unistd.h>
#include <asm/pgtable.h>
#include <asm/mmu_context.h>
+#include <linux/cpuset.h>

extern void sem_exit (void);
extern struct task_struct *child_reaper;
@@ -800,6 +801,7 @@ asmlinkage NORET_TYPE void do_exit(long
__exit_fs(tsk);
exit_namespace(tsk);
exit_thread();
+ cpuset_exit(tsk);
#ifdef CONFIG_NUMA
mpol_free(tsk->mempolicy);
#endif
Index: 2.6.7-mm4/kernel/fork.c
===================================================================
--- 2.6.7-mm4.orig/kernel/fork.c 2004-06-29 03:54:43.000000000 -0700
+++ 2.6.7-mm4/kernel/fork.c 2004-06-29 03:55:38.000000000 -0700
@@ -36,6 +36,7 @@
#include <linux/mount.h>
#include <lin