From: Christoph Hellwig - don't include mempolicy.h in sched.h and mm.h when a forward delcaration is enough. Andi argued against that in the past, but I'd really hate to add another header to two of the includes used in basically every driver when we can include it in the six files actually needing it instead (that number is for my ppc32 system, maybe other arches need more include in their directories) - make numa api fields in tast_struct conditional on CONFIG_NUMA, this gives us a few ugly ifdefs but avoids wasting memory on non-NUMA systems. --- 25-akpm/fs/exec.c | 1 + 25-akpm/include/linux/mm.h | 3 ++- 25-akpm/include/linux/sched.h | 4 +++- 25-akpm/kernel/exit.c | 2 ++ 25-akpm/kernel/fork.c | 5 +++++ 25-akpm/mm/mempolicy.c | 1 + 25-akpm/mm/mmap.c | 1 + 25-akpm/mm/mprotect.c | 1 + 25-akpm/mm/shmem.c | 1 + 9 files changed, 17 insertions(+), 2 deletions(-) diff -puN fs/exec.c~small-numa-api-fixups fs/exec.c --- 25/fs/exec.c~small-numa-api-fixups Mon May 3 13:31:07 2004 +++ 25-akpm/fs/exec.c Mon May 3 13:31:07 2004 @@ -46,6 +46,7 @@ #include #include #include +#include #include #include diff -puN include/linux/mm.h~small-numa-api-fixups include/linux/mm.h --- 25/include/linux/mm.h~small-numa-api-fixups Mon May 3 13:31:07 2004 +++ 25-akpm/include/linux/mm.h Mon May 3 13:31:07 2004 @@ -12,7 +12,8 @@ #include #include #include -#include + +struct mempolicy; #ifndef CONFIG_DISCONTIGMEM /* Don't use mapnrs, do it properly */ extern unsigned long max_mapnr; diff -puN include/linux/sched.h~small-numa-api-fixups include/linux/sched.h --- 25/include/linux/sched.h~small-numa-api-fixups Mon May 3 13:31:07 2004 +++ 25-akpm/include/linux/sched.h Mon May 3 13:31:07 2004 @@ -29,7 +29,6 @@ #include #include #include -#include struct exec_domain; @@ -378,6 +377,7 @@ int set_current_groups(struct group_info struct audit_context; /* See audit.c */ +struct mempolicy; struct task_struct { volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */ @@ -507,8 +507,10 @@ struct task_struct { unsigned long ptrace_message; siginfo_t *last_siginfo; /* For ptrace use. */ +#ifdef CONFIG_NUMA struct mempolicy *mempolicy; short il_next; /* could be shared with used_math */ +#endif }; static inline pid_t process_group(struct task_struct *tsk) diff -puN kernel/exit.c~small-numa-api-fixups kernel/exit.c --- 25/kernel/exit.c~small-numa-api-fixups Mon May 3 13:31:07 2004 +++ 25-akpm/kernel/exit.c Mon May 3 13:31:07 2004 @@ -790,7 +790,9 @@ asmlinkage NORET_TYPE void do_exit(long __exit_fs(tsk); exit_namespace(tsk); exit_thread(); +#ifdef CONFIG_NUMA mpol_free(tsk->mempolicy); +#endif if (tsk->signal->leader) disassociate_ctty(1); diff -puN kernel/fork.c~small-numa-api-fixups kernel/fork.c --- 25/kernel/fork.c~small-numa-api-fixups Mon May 3 13:31:07 2004 +++ 25-akpm/kernel/fork.c Mon May 3 13:31:07 2004 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -971,12 +972,14 @@ struct task_struct *copy_process(unsigne p->security = NULL; p->io_context = NULL; p->audit_context = NULL; +#ifdef CONFIG_NUMA p->mempolicy = mpol_copy(p->mempolicy); if (IS_ERR(p->mempolicy)) { retval = PTR_ERR(p->mempolicy); p->mempolicy = NULL; goto bad_fork_cleanup; } +#endif retval = -ENOMEM; if ((retval = security_task_alloc(p))) @@ -1127,7 +1130,9 @@ bad_fork_cleanup_audit: bad_fork_cleanup_security: security_task_free(p); bad_fork_cleanup_policy: +#ifdef CONFIG_NUMA mpol_free(p->mempolicy); +#endif bad_fork_cleanup: if (p->pid > 0) free_pidmap(p->pid); diff -puN mm/mempolicy.c~small-numa-api-fixups mm/mempolicy.c --- 25/mm/mempolicy.c~small-numa-api-fixups Mon May 3 13:31:07 2004 +++ 25-akpm/mm/mempolicy.c Mon May 3 13:31:07 2004 @@ -72,6 +72,7 @@ #include #include #include +#include #include static kmem_cache_t *policy_cache; diff -puN mm/mmap.c~small-numa-api-fixups mm/mmap.c --- 25/mm/mmap.c~small-numa-api-fixups Mon May 3 13:31:07 2004 +++ 25-akpm/mm/mmap.c Mon May 3 13:31:07 2004 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include diff -puN mm/mprotect.c~small-numa-api-fixups mm/mprotect.c --- 25/mm/mprotect.c~small-numa-api-fixups Mon May 3 13:31:07 2004 +++ 25-akpm/mm/mprotect.c Mon May 3 13:31:07 2004 @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff -puN mm/shmem.c~small-numa-api-fixups mm/shmem.c --- 25/mm/shmem.c~small-numa-api-fixups Mon May 3 13:31:07 2004 +++ 25-akpm/mm/shmem.c Mon May 3 13:31:07 2004 @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include _