Re: [PATCH] de-xchg fork.c

From: Ingo Molnar (mingo@elte.hu)
Date: Mon Sep 23 2002 - 13:31:41 EST


On Mon, 23 Sep 2002, Rusty Russell wrote:

> - tsk = xchg(task_cache + cpu, tsk);
> + tsk = task_cache[cpu];

this was me - i forgot that this are per-CPU fields. (hey and i wrote the
original task_cache code so there's no excuse :-)

the attached patch (against BK-curr) fixes all xchg()'s and a preemption
bug.

        Ingo

--- linux/kernel/fork.c.orig Mon Sep 23 20:28:36 2002
+++ linux/kernel/fork.c Mon Sep 23 20:30:02 2002
@@ -64,11 +64,12 @@
         } else {
                 int cpu = smp_processor_id();
 
- 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;
         }
 }
 
@@ -126,8 +127,11 @@
 {
         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)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Sep 23 2002 - 22:00:39 EST