Эх сурвалжийг харах

[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>
Paul Jackson 19 жил өмнө
parent
commit
c417f0242e

+ 2 - 0
include/linux/cpuset.h

@@ -16,6 +16,7 @@
 
 
 extern int number_of_cpusets;	/* How many cpusets are defined in system? */
 extern int number_of_cpusets;	/* How many cpusets are defined in system? */
 
 
+extern int cpuset_init_early(void);
 extern int cpuset_init(void);
 extern int cpuset_init(void);
 extern void cpuset_init_smp(void);
 extern void cpuset_init_smp(void);
 extern void cpuset_fork(struct task_struct *p);
 extern void cpuset_fork(struct task_struct *p);
@@ -49,6 +50,7 @@ extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
 
 
 #else /* !CONFIG_CPUSETS */
 #else /* !CONFIG_CPUSETS */
 
 
+static inline int cpuset_init_early(void) { return 0; }
 static inline int cpuset_init(void) { return 0; }
 static inline int cpuset_init(void) { return 0; }
 static inline void cpuset_init_smp(void) {}
 static inline void cpuset_init_smp(void) {}
 static inline void cpuset_fork(struct task_struct *p) {}
 static inline void cpuset_fork(struct task_struct *p) {}

+ 1 - 0
init/main.c

@@ -512,6 +512,7 @@ asmlinkage void __init start_kernel(void)
 	}
 	}
 #endif
 #endif
 	vfs_caches_init_early();
 	vfs_caches_init_early();
+	cpuset_init_early();
 	mem_init();
 	mem_init();
 	kmem_cache_init();
 	kmem_cache_init();
 	setup_per_cpu_pageset();
 	setup_per_cpu_pageset();

+ 16 - 6
kernel/cpuset.c

@@ -603,9 +603,7 @@ static void guarantee_online_mems(const struct cpuset *cs, nodemask_t *pmask)
  * Do not call this routine if in_interrupt().
  * Do not call this routine if in_interrupt().
  *
  *
  * Call without callback_sem or task_lock() held.  May be called
  * Call without callback_sem or task_lock() held.  May be called
- * with or without manage_sem held.  Except in early boot or
- * an exiting task, when tsk->cpuset is NULL, this routine will
- * acquire task_lock().  We don't need to use task_lock to guard
+ * with or without manage_sem held.  Doesn't need task_lock to guard
  * against another task changing a non-NULL cpuset pointer to NULL,
  * against another task changing a non-NULL cpuset pointer to NULL,
  * as that is only done by a task on itself, and if the current task
  * as that is only done by a task on itself, and if the current task
  * is here, it is not simultaneously in the exit code NULL'ing its
  * is here, it is not simultaneously in the exit code NULL'ing its
@@ -631,9 +629,6 @@ void cpuset_update_task_memory_state()
 	struct task_struct *tsk = current;
 	struct task_struct *tsk = current;
 	struct cpuset *cs = tsk->cpuset;
 	struct cpuset *cs = tsk->cpuset;
 
 
-	if (unlikely(!cs))
-		return;
-
 	task_lock(tsk);
 	task_lock(tsk);
 	my_cpusets_mem_gen = cs->mems_generation;
 	my_cpusets_mem_gen = cs->mems_generation;
 	task_unlock(tsk);
 	task_unlock(tsk);
@@ -1836,6 +1831,21 @@ static int cpuset_rmdir(struct inode *unused_dir, struct dentry *dentry)
 	return 0;
 	return 0;
 }
 }
 
 
+/*
+ * cpuset_init_early - just enough so that the calls to
+ * cpuset_update_task_memory_state() in early init code
+ * are harmless.
+ */
+
+int __init cpuset_init_early(void)
+{
+	struct task_struct *tsk = current;
+
+	tsk->cpuset = &top_cpuset;
+	tsk->cpuset->mems_generation = atomic_read(&cpuset_mems_generation);
+	return 0;
+}
+
 /**
 /**
  * cpuset_init - initialize cpusets at system boot
  * cpuset_init - initialize cpusets at system boot
  *
  *