From: Nick Piggin <nickpiggin@yahoo.com.au>
To: dwalker@mvista.com
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RT: Checks for cmpxchg in get_task_struct_rcu()
Date: Thu, 22 Sep 2005 10:59:40 +1000 [thread overview]
Message-ID: <433201FC.8040004@yahoo.com.au> (raw)
In-Reply-To: <1127345874.19506.43.camel@dhcp153.mvista.com>
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
next prev parent reply other threads:[~2005-09-22 1:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-21 23:37 [PATCH] RT: Checks for cmpxchg in get_task_struct_rcu() Daniel Walker
2005-09-22 0:59 ` Nick Piggin [this message]
2005-09-22 2:18 ` Daniel Walker
2005-09-22 3:27 ` Nick Piggin
2005-09-22 4:50 ` Daniel Walker
2005-09-22 5:05 ` Nick Piggin
2005-09-26 6:25 ` Ingo Molnar
2005-09-26 14:44 ` Daniel Walker
2005-09-26 6:26 ` Ingo Molnar
2005-09-26 6:39 ` Nick Piggin
2005-09-26 6:48 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=433201FC.8040004@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=dwalker@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox