Re: [PATCH] Fixes for RCU handling of task_struct

From: Paul E. McKenney
Date: Sun Nov 06 2005 - 17:43:52 EST


On Sun, Nov 06, 2005 at 01:49:45PM -0800, Andrew Morton wrote:
> Ingo Molnar <mingo@xxxxxxx> wrote:
> >
> > ...
> >
> > RCU signal handling: send signals RCU-read-locked instead of
> > tasklist_lock read-locked. This is a scalability improvement on SMP and
> > a preemption-latency improvement under PREEMPT_RCU.
> >
> > Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
> > Signed-off-by: Ingo Molnar <mingo@xxxxxxx>
> >
> > ...
> > +static inline int get_task_struct_rcu(struct task_struct *t)
> > +{
> > + int oldusage;
> > +
> > + do {
> > + oldusage = atomic_read(&t->usage);
> > + if (oldusage == 0) {
> > + return 0;
> > + }
> > + } while (cmpxchg(&t->usage.counter,
> > + oldusage, oldusage + 1) != oldusage);
> > + return 1;
> > +}
>
> arm (at least) does not implement cmpxchg.
>
> I think Nick is working on patches which implement cmpxchg on all
> architectures?

That he is, but the latest set of signal-RCU patches does not use
get_task_struct_rcu(). Attached is a patch that removes it.

That said, it would be good if there was a set of cmpxchg functions
for all architectures.

Thanx, Paul

Signed-off-by: <paulmck@xxxxxxxxxx>

---

diff -urpNa -X dontdiff linux-2.6.14-rt6/include/linux/sched.h linux-2.6.14-rt6-nocmpxchg/include/linux/sched.h
--- linux-2.6.14-rt6/include/linux/sched.h 2005-11-04 12:38:05.000000000 -0800
+++ linux-2.6.14-rt6-nocmpxchg/include/linux/sched.h 2005-11-06 14:41:26.000000000 -0800
@@ -1057,20 +1057,6 @@ extern void free_task(struct task_struct
extern void __put_task_struct(struct task_struct *tsk);
#define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0)

-static inline int get_task_struct_rcu(struct task_struct *t)
-{
- int oldusage;
-
- do {
- oldusage = atomic_read(&t->usage);
- if (oldusage == 0) {
- return 0;
- }
- } while (cmpxchg(&t->usage.counter,
- oldusage, oldusage + 1) != oldusage);
- return 1;
-}
-
extern void __put_task_struct_cb(struct rcu_head *rhp);

static inline void put_task_struct(struct task_struct *t)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/