[PATCH] de-xchg fork.c

Rusty Russell (rusty@rustcorp.com.au)
Mon, 23 Sep 2002 11:06:14 +1000


Don't know who put this in for 2.5.38.

I realize that using xchg() makes you 'leet. But doing an atomic op
where none is required is suboptimal and confusing.

Hey, at least it wasn't:
if (likely(tsk = xchg(task_cache + cpu, tsk))) {

Cheers,
Rusty.

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.38/kernel/fork.c working-2.5.38-unxchg/kernel/fork.c
--- linux-2.5.38/kernel/fork.c 2002-09-21 13:55:19.000000000 +1000
+++ working-2.5.38-unxchg/kernel/fork.c 2002-09-23 11:00:31.000000000 +1000
@@ -64,11 +64,12 @@ void __put_task_struct(struct task_struc
} 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;
}
}

--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
-
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/