From: Joe Korty <joe.korty@ccur.com>
To: David Howells <dhowells@redhat.com>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] volatile may be needed in rwsem
Date: Tue, 27 Jan 2004 14:43:43 -0500 [thread overview]
Message-ID: <20040127194343.GA12763@tsunami.ccur.com> (raw)
In-Reply-To: <23376.1075231180@redhat.com>
On Tue, Jan 27, 2004 at 07:19:40PM +0000, David Howells wrote:
>> 'flags' should be declared volatile as rwsem_down_failed_common() spins
>> waiting for this to change. Untested.
>
> Is it though? Does this fix an error?
>
> The thing is, we make a function call inside of the loop:
>
> /* wait to be given the lock */
> for (;;) {
> if (!waiter->flags)
> break;
> schedule();
> set_task_state(tsk, TASK_UNINTERRUPTIBLE);
> }
>
> Which might preclude that need. I'm not entirely sure, though... it's one of
> those compiler black magic things.
>
> I suppose it can't hurt...
>
> David
Hi David,
I misspoke. The potentially failing spin is in __down_write and
__down_read in lib/rwsem-spinlock.c, not in rwsem_down_failed_common.
The problem is is that 'flags' is on the callee's stack and is thus
subject to be optimized out of the loop if the compiler is smart enough
to discover that it is on the stack. Apparently gcc is not yet smart
enough but that doesn't mean it won't be so soon.
Joe
next prev parent reply other threads:[~2004-01-27 19:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-27 19:11 [PATCH] volatile may be needed in rwsem Joe Korty
2004-01-27 19:19 ` David Howells
2004-01-27 19:43 ` Joe Korty [this message]
2004-01-27 20:23 ` Paulo Marques
2004-01-27 20:20 ` Christian Borntraeger
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=20040127194343.GA12763@tsunami.ccur.com \
--to=joe.korty@ccur.com \
--cc=akpm@osdl.org \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/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