aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Jackson <pj@sgi.com>2006-01-08 04:02:01 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-08 23:13:44 -0500
commitc417f0242ebe578924a30d4e53d35b5059fed4e7 (patch)
tree3058c7c79aedb11e7013f5faca34eb07e9a761bd
parent04c19fa6f16047abff2288ddbc1f0798ede5a849 (diff)
[PATCH] cpuset: remove test for null cpuset from alloc code path
Remove a couple of more lines of code from the cpuset hooks in the page allocation code path. There was a check for a NULL cpuset pointer in the routine cpuset_update_task_memory_state() that was only needed during system boot, after the memory subsystem was initialized, before the cpuset subsystem was initialized, to catch a NULL task->cpuset pointer. Add a cpuset_init_early() routine, just before the mem_init() call in init/main.c, that sets up just enough of the init tasks cpuset structure to render cpuset_update_task_memory_state() calls harmless. Signed-off-by: Paul Jackson <pj@sgi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--include/linux/cpuset.h2
-rw-r--r--init/main.c1
-rw-r--r--kernel/cpuset.c22
3 files changed, 19 insertions, 6 deletions
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 34081c168af5..c472f972bd6d 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -16,6 +16,7 @@
16 16
17extern int number_of_cpusets; /* How many cpusets are defined in system? */ 17extern int number_of_cpusets; /* How many cpusets are defined in system? */
18 18
19extern int cpuset_init_early(void);
19extern int cpuset_init(void); 20extern int cpuset_init(void);
20extern void cpuset_init_smp(void); 21extern void cpuset_init_smp(void);
21extern void cpuset_fork(struct task_struct *p); 22extern void cpuset_fork(struct task_struct *p);
@@ -49,6 +50,7 @@ extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
49 50
50#else /* !CONFIG_CPUSETS */ 51#else /* !CONFIG_CPUSETS */
51 52
53static inline int cpuset_init_early(void) { return 0; }
52static inline int cpuset_init(void) { return 0; } 54static inline int cpuset_init(void) { return 0; }
53static inline void cpuset_init_smp(void) {} 55static inline void cpuset_init_smp(void) {}
54static inline void cpuset_fork(struct task_struct *p) {} 56static inline void cpuset_fork(struct task_struct *p) {}
diff --git a/init/main.c b/init/main.c
index 2ed3638deec7..afe5eb84ad52 100644
--- a/init/main.c
+++ b/init/main.c
@@ -512,6 +512,7 @@ asmlinkage void __init start_kernel(void)
512 } 512 }
513#endif 513#endif
514 vfs_caches_init_early(); 514 vfs_caches_init_early();
515 cpuset_init_early();
515 mem_init(); 516 mem_init();
516 kmem_cache_init(); 517 kmem_cache_init();
517 setup_per_cpu_pageset(); 518 setup_per_cpu_pageset();
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index cf8203a5fa71..fc949e4a625c 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -603,9 +603,7 @@ static void guarantee_online_mems(const struct cpuset *cs, nodemask_t *pmask)
603 * Do not call this routine if in_interrupt(). 603 * Do not call this routine if in_interrupt().
604 * 604 *
605 * Call without callback_sem or task_lock() held. May be called 605 * Call without callback_sem or task_lock() held. May be called
606 * with or without manage_sem held. Except in early boot or 606 * with or without manage_sem held. Doesn't need task_lock to guard
607 * an exiting task, when tsk->cpuset is NULL, this routine will
608 * acquire task_lock(). We don't need to use task_lock to guard
609 * against another task changing a non-NULL cpuset pointer to NULL, 607 * against another task changing a non-NULL cpuset pointer to NULL,
610 * as that is only done by a task on itself, and if the current task 608 * as that is only done by a task on itself, and if the current task
611 * is here, it is not simultaneously in the exit code NULL'ing its 609 * is here, it is not simultaneously in the exit code NULL'ing its
@@ -631,9 +629,6 @@ void cpuset_update_task_memory_state()
631 struct task_struct *tsk = current; 629 struct task_struct *tsk = current;
632 struct cpuset *cs = tsk->cpuset; 630 struct cpuset *cs = tsk->cpuset;
633 631
634 if (unlikely(!cs))
635 return;
636
637 task_lock(tsk); 632 task_lock(tsk);
638 my_cpusets_mem_gen = cs->mems_generation; 633 my_cpusets_mem_gen = cs->mems_generation;
639 task_unlock(tsk); 634 task_unlock(tsk);
@@ -1836,6 +1831,21 @@ static int cpuset_rmdir(struct inode *unused_dir, struct dentry *dentry)
1836 return 0; 1831 return 0;
1837} 1832}
1838 1833
1834/*
1835 * cpuset_init_early - just enough so that the calls to
1836 * cpuset_update_task_memory_state() in early init code
1837 * are harmless.
1838 */
1839
1840int __init cpuset_init_early(void)
1841{
1842 struct task_struct *tsk = current;
1843
1844 tsk->cpuset = &top_cpuset;
1845 tsk->cpuset->mems_generation = atomic_read(&cpuset_mems_generation);
1846 return 0;
1847}
1848
1839/** 1849/**
1840 * cpuset_init - initialize cpusets at system boot 1850 * cpuset_init - initialize cpusets at system boot
1841 * 1851 *