lkml.org 
[lkml]   [2005]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] RT: Checks for cmpxchg in get_task_struct_rcu()
Daniel Walker wrote:
> Adds a check for cmpxchg in get_task_struct_rcu(), and implements the
> case when it doesn't exist.
>

I believe this is racy.

> Signed-Off-By: Daniel Walker <dwalker@mvista.com>
>
> Index: linux-2.6.13/include/linux/sched.h
> ===================================================================
> --- linux-2.6.13.orig/include/linux/sched.h
> +++ linux-2.6.13/include/linux/sched.h
> @@ -1026,13 +1026,21 @@ static inline int get_task_struct_rcu(st
> {
> int oldusage;
>
> +#ifdef __HAVE_ARCH_CMPXCHG
> do {
> oldusage = atomic_read(&t->usage);
> if (oldusage == 0) {
> return 0;
> }
> } while (cmpxchg(&t->usage.counter,
> - oldusage, oldusage + 1) != oldusage);
> + oldusage, oldusage + 1) != oldusage);
> +#else
> + oldusage = atomic_read(&t->usage);
> + if (oldusage == 0) {
> + return 0;
> + }

What if t->usage becomes 0 here?

> + atomic_inc(&t->usage);
> +#endif
> return 1;
> }
>

You need my atomic_cmpxchg patches that provide an atomic_cmpxchg
(and atomic_inc_not_zero) for all architectures.

--
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com

-
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/

\
 
 \ /
  Last update: 2005-09-22 03:37    [W:0.098 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site