Commit 4da99f75 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] remove task_cache entirely

From: Manfred Spraul <manfred@colorfullife.com>

kernel/fork.c contains a disabled cache for task stuctures.  task
structures are placed into the task cache only if "tsk==current", and
"tsk==current" is impossible.  There is even a WARN_ON against that in
__put_task_struct().

So remove it entirely - it's dead code.

One problem is that order-1 allocations are not cached per-cpu - we can
use kmalloc for the stack.
parent 04af9e58
...@@ -53,13 +53,6 @@ DEFINE_PER_CPU(unsigned long, process_counts) = 0; ...@@ -53,13 +53,6 @@ DEFINE_PER_CPU(unsigned long, process_counts) = 0;
rwlock_t tasklist_lock __cacheline_aligned = RW_LOCK_UNLOCKED; /* outer */ rwlock_t tasklist_lock __cacheline_aligned = RW_LOCK_UNLOCKED; /* outer */
/*
* A per-CPU task cache - this relies on the fact that
* the very last portion of sys_exit() is executed with
* preemption turned off.
*/
static task_t *task_cache[NR_CPUS] __cacheline_aligned;
int nr_processes(void) int nr_processes(void)
{ {
int cpu; int cpu;
...@@ -80,26 +73,8 @@ static kmem_cache_t *task_struct_cachep; ...@@ -80,26 +73,8 @@ static kmem_cache_t *task_struct_cachep;
static void free_task(struct task_struct *tsk) static void free_task(struct task_struct *tsk)
{ {
/* free_thread_info(tsk->thread_info);
* The task cache is effectively disabled right now. free_task_struct(tsk);
* Do we want it? The slab cache already has per-cpu
* stuff, but the thread info (usually a order-1 page
* allocation) doesn't.
*/
if (tsk != current) {
free_thread_info(tsk->thread_info);
free_task_struct(tsk);
} else {
int cpu = get_cpu();
tsk = task_cache[cpu];
if (tsk) {
free_thread_info(tsk->thread_info);
free_task_struct(tsk);
}
task_cache[cpu] = current;
put_cpu();
}
} }
void __put_task_struct(struct task_struct *tsk) void __put_task_struct(struct task_struct *tsk)
...@@ -220,25 +195,18 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) ...@@ -220,25 +195,18 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
{ {
struct task_struct *tsk; struct task_struct *tsk;
struct thread_info *ti; struct thread_info *ti;
int cpu = get_cpu();
prepare_to_copy(orig); prepare_to_copy(orig);
tsk = task_cache[cpu]; tsk = alloc_task_struct();
task_cache[cpu] = NULL; if (!tsk)
put_cpu(); return NULL;
if (!tsk) {
tsk = alloc_task_struct(); ti = alloc_thread_info(tsk);
if (!tsk) if (!ti) {
return NULL; free_task_struct(tsk);
return NULL;
ti = alloc_thread_info(tsk); }
if (!ti) {
free_task_struct(tsk);
return NULL;
}
} else
ti = tsk->thread_info;
*ti = *orig->thread_info; *ti = *orig->thread_info;
*tsk = *orig; *tsk = *orig;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment