From: Nick Piggin <piggin@cyberone.com.au>
To: Andrew Morton <akpm@osdl.org>
Cc: schwidefsky@de.ibm.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: blk_congestion_wait racy?
Date: Wed, 10 Mar 2004 16:47:01 +1100 [thread overview]
Message-ID: <404EABD5.4060607@cyberone.com.au> (raw)
In-Reply-To: <20040309213518.44adb33d.akpm@osdl.org>
[-- Attachment #1: Type: text/plain, Size: 835 bytes --]
Andrew Morton wrote:
>Nick Piggin <piggin@cyberone.com.au> wrote:
>
>>But I'm guessing that you have no requests in flight by the time
>> blk_congestion_wait gets called, so nothing ever gets kicked.
>>
>
>That's why blk_congestion_wait() in -mm propagates the schedule_timeout()
>return value. You can do:
>
> if (blk_congestion_wait(...))
> printk("ouch\n");
>
>If your kernel says ouch much, we have a problem.
>
>
Martin, have you tried adding this printk?
Andrew, could you take the following patch (even though it didn't fix
the problem).
I think the smp_mb isn't needed because the rl waitqueue stuff is
serialised by the queue spinlocks.
The addition of the smp_mb and the other change is to try to close the
window for races a bit. Obviously they can still happen, it's a racy
interface and it doesn't matter much.
[-- Attachment #2: blk-congestion-races.patch --]
[-- Type: text/x-patch, Size: 1341 bytes --]
linux-2.6-npiggin/drivers/block/ll_rw_blk.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff -puN drivers/block/ll_rw_blk.c~blk-congestion-races drivers/block/ll_rw_blk.c
--- linux-2.6/drivers/block/ll_rw_blk.c~blk-congestion-races 2004-03-10 16:38:33.000000000 +1100
+++ linux-2.6-npiggin/drivers/block/ll_rw_blk.c 2004-03-10 16:41:29.000000000 +1100
@@ -110,6 +110,9 @@ static void clear_queue_congested(reques
bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested;
clear_bit(bit, &q->backing_dev_info.state);
+
+ smp_mb(); /* congestion_wqh is not synchronised. This is still racy,
+ * but better. It isn't a big deal */
if (waitqueue_active(wqh))
wake_up(wqh);
}
@@ -1543,7 +1546,6 @@ static void freed_request(request_queue_
if (rl->count[rw] < queue_congestion_off_threshold(q))
clear_queue_congested(q, rw);
if (rl->count[rw]+1 <= q->nr_requests) {
- smp_mb();
if (waitqueue_active(&rl->wait[rw]))
wake_up(&rl->wait[rw]);
if (!waitqueue_active(&rl->wait[rw]))
@@ -2036,8 +2038,8 @@ long blk_congestion_wait(int rw, long ti
DEFINE_WAIT(wait);
wait_queue_head_t *wqh = &congestion_wqh[rw];
- blk_run_queues();
prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE);
+ blk_run_queues();
ret = io_schedule_timeout(timeout);
finish_wait(wqh, &wait);
return ret;
_
next prev parent reply other threads:[~2004-03-10 5:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-09 17:54 Martin Schwidefsky
2004-03-10 5:23 ` Nick Piggin
2004-03-10 5:35 ` Andrew Morton
2004-03-10 5:47 ` Nick Piggin [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-03-11 19:04 Martin Schwidefsky
2004-03-11 23:25 ` Andrew Morton
2004-03-12 2:31 ` Nick Piggin
2004-03-11 18:24 Martin Schwidefsky
2004-03-11 18:55 ` Andrew Morton
2004-03-08 13:38 Martin Schwidefsky
2004-03-08 23:50 ` Nick Piggin
2004-03-08 9:59 Martin Schwidefsky
2004-03-08 12:24 ` Andrew Morton
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=404EABD5.4060607@cyberone.com.au \
--to=piggin@cyberone.com.au \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=schwidefsky@de.ibm.com \
/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