diff options
| author | Ingo Molnar <mingo@elte.hu> | 2002-09-22 21:46:20 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-09-22 21:46:20 -0700 |
| commit | 94eda0969bf8f7ea58872e5c1069e2c0b203e877 (patch) | |
| tree | 4983925cbaa71bf3bea75b13658ff957ce1d48ed /kernel | |
| parent | 817fdd72fae82f7b43b06ee7733c8ede31a4365b (diff) | |
[PATCH] de-xchg fork.c
This fixes all xchg()'s and a preemption bug.
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/fork.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 4688c232b9a5..062a4d1f9c3e 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -62,13 +62,15 @@ void __put_task_struct(struct task_struct *tsk) free_thread_info(tsk->thread_info); kmem_cache_free(task_struct_cachep,tsk); } else { - int cpu = smp_processor_id(); + int cpu = get_cpu(); - tsk = xchg(task_cache + cpu, tsk); + tsk = task_cache[cpu]; if (tsk) { free_thread_info(tsk->thread_info); kmem_cache_free(task_struct_cachep,tsk); } + task_cache[cpu] = current; + put_cpu(); } } @@ -126,8 +128,11 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) { struct task_struct *tsk; struct thread_info *ti; + int cpu = get_cpu(); - tsk = xchg(task_cache + smp_processor_id(), NULL); + tsk = task_cache[cpu]; + task_cache[cpu] = NULL; + put_cpu(); if (!tsk) { ti = alloc_thread_info(); if (!ti) |
