From: "David S. Miller" <davem@redhat.com>
To: andrewm@uow.edu.au
Cc: linux-kernel@vger.kernel.org
Subject: Re: [patch] NE2000
Date: Thu, 9 Nov 2000 03:20:57 -0800 [thread overview]
Message-ID: <200011091120.DAA27190@pizda.ninka.net> (raw)
In-Reply-To: <3A0A8236.2166E00@uow.edu.au> (message from Andrew Morton on Thu, 09 Nov 2000 21:53:42 +1100)
In-Reply-To: <200011082031.XAA20453@ms2.inr.ac.ru> (kuznet@ms2.inr.ac.ru), <200011082031.XAA20453@ms2.inr.ac.ru> <200011090127.RAA17691@pizda.ninka.net> <3A0A8236.2166E00@uow.edu.au>
Date: Thu, 09 Nov 2000 21:53:42 +1100
From: Andrew Morton <andrewm@uow.edu.au>
"David S. Miller" wrote:
> I will compose a patch to fix all this.
I've quickly been through just about all of the kernel wrt
waitqueues.
My analysis was in error, BEWARE!
Being on multiple wait queues at once is just fine. I verified this
with Linus tonight.
The problem case is in mixing TASK_EXCLUSIVE and non-TASK_EXCLUSIVE
sleeps, that is what can actually cause problems.
Everything else is fine. Anyways, the (untested) patch below should
cure the lock_sock() cases.
--- ./net/ipv4/af_inet.c.~1~ Tue Oct 24 14:26:18 2000
+++ ./net/ipv4/af_inet.c Wed Nov 8 17:28:47 2000
@@ -543,24 +543,27 @@
{
DECLARE_WAITQUEUE(wait, current);
- __set_current_state(TASK_INTERRUPTIBLE);
- add_wait_queue(sk->sleep, &wait);
-
/* Basic assumption: if someone sets sk->err, he _must_
* change state of the socket from TCP_SYN_*.
* Connect() does not allow to get error notifications
* without closing the socket.
*/
while ((1<<sk->state)&(TCPF_SYN_SENT|TCPF_SYN_RECV)) {
+ __set_current_state(TASK_INTERRUPTIBLE);
+ add_wait_queue(sk->sleep, &wait);
+
release_sock(sk);
- timeo = schedule_timeout(timeo);
+
+ if ((1<<sk->state)&(TCPF_SYN_SENT|TCPF_SYN_RECV))
+ timeo = schedule_timeout(timeo);
+
+ __set_current_state(TASK_RUNNING);
+ remove_wait_queue(sk->sleep, &wait);
+
lock_sock(sk);
if (signal_pending(current) || !timeo)
break;
- set_current_state(TASK_INTERRUPTIBLE);
}
- __set_current_state(TASK_RUNNING);
- remove_wait_queue(sk->sleep, &wait);
return timeo;
}
--- ./net/ipv4/tcp.c.~1~ Fri Oct 6 15:45:41 2000
+++ ./net/ipv4/tcp.c Wed Nov 8 17:35:31 2000
@@ -826,10 +826,12 @@
release_sock(sk);
*timeo_p = schedule_timeout(*timeo_p);
- lock_sock(sk);
__set_task_state(tsk, TASK_RUNNING);
remove_wait_queue(sk->sleep, &wait);
+
+ lock_sock(sk);
+
sk->tp_pinfo.af_tcp.write_pending--;
}
return 0;
@@ -854,24 +856,31 @@
clear_bit(SOCK_ASYNC_NOSPACE, &sk->socket->flags);
- add_wait_queue(sk->sleep, &wait);
for (;;) {
set_bit(SOCK_NOSPACE, &sk->socket->flags);
+ add_wait_queue(sk->sleep, &wait);
set_current_state(TASK_INTERRUPTIBLE);
- if (signal_pending(current))
- break;
- if (tcp_memory_free(sk) && !vm_wait)
- break;
- if (sk->shutdown & SEND_SHUTDOWN)
- break;
- if (sk->err)
+ if (signal_pending(current) ||
+ (tcp_memory_free(sk) && !vm_wait) ||
+ (sk->shutdown & SEND_SHUTDOWN) ||
+ sk->err) {
+ current->state = TASK_RUNNING;
+ remove_wait_queue(sk->sleep, &wait);
break;
+ }
+
release_sock(sk);
+
if (!tcp_memory_free(sk) || vm_wait)
current_timeo = schedule_timeout(current_timeo);
+
+ current->state = TASK_RUNNING;
+ remove_wait_queue(sk->sleep, &wait);
+
lock_sock(sk);
+
if (vm_wait) {
if (timeo != MAX_SCHEDULE_TIMEOUT &&
(timeo -= vm_wait-current_timeo) < 0)
@@ -881,8 +890,6 @@
timeo = current_timeo;
}
}
- current->state = TASK_RUNNING;
- remove_wait_queue(sk->sleep, &wait);
return timeo;
}
@@ -1266,7 +1273,6 @@
DECLARE_WAITQUEUE(wait, current);
add_wait_queue(sk->sleep, &wait);
-
__set_current_state(TASK_INTERRUPTIBLE);
set_bit(SOCK_ASYNC_WAITDATA, &sk->socket->flags);
@@ -1275,11 +1281,12 @@
if (skb_queue_empty(&sk->receive_queue))
timeo = schedule_timeout(timeo);
+ remove_wait_queue(sk->sleep, &wait);
+ __set_current_state(TASK_RUNNING);
+
lock_sock(sk);
clear_bit(SOCK_ASYNC_WAITDATA, &sk->socket->flags);
- remove_wait_queue(sk->sleep, &wait);
- __set_current_state(TASK_RUNNING);
return timeo;
}
@@ -1826,19 +1833,23 @@
struct task_struct *tsk = current;
DECLARE_WAITQUEUE(wait, current);
- add_wait_queue(sk->sleep, &wait);
-
do {
+ add_wait_queue(sk->sleep, &wait);
set_current_state(TASK_INTERRUPTIBLE);
- if (!closing(sk))
+ if (!closing(sk)) {
+ tsk->state = TASK_RUNNING;
+ remove_wait_queue(sk->sleep, &wait);
break;
+ }
release_sock(sk);
+
timeout = schedule_timeout(timeout);
+
+ tsk->state = TASK_RUNNING;
+ remove_wait_queue(sk->sleep, &wait);
+
lock_sock(sk);
} while (!signal_pending(tsk) && timeout);
-
- tsk->state = TASK_RUNNING;
- remove_wait_queue(sk->sleep, &wait);
}
adjudge_to_death:
@@ -2009,12 +2020,17 @@
* our exclusiveness temporarily when we get woken up without
* having to remove and re-insert us on the wait queue.
*/
- add_wait_queue_exclusive(sk->sleep, &wait);
for (;;) {
+ add_wait_queue_exclusive(sk->sleep, &wait);
current->state = TASK_EXCLUSIVE | TASK_INTERRUPTIBLE;
+
release_sock(sk);
if (sk->tp_pinfo.af_tcp.accept_queue == NULL)
timeo = schedule_timeout(timeo);
+
+ current->state = TASK_RUNNING;
+ remove_wait_queue(sk->sleep, &wait);
+
lock_sock(sk);
err = 0;
if (sk->tp_pinfo.af_tcp.accept_queue)
@@ -2029,8 +2045,6 @@
if (!timeo)
break;
}
- current->state = TASK_RUNNING;
- remove_wait_queue(sk->sleep, &wait);
return err;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2000-11-09 11:36 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.4.21.0010300344130.6792-100000@web.sajt.cz>
2000-10-29 20:08 ` Jeff Garzik
2000-10-29 20:34 ` Alan Cox
2000-10-30 10:57 ` Jorge Nerin
2000-10-31 13:54 ` changed section attributes Petko Manolov
2000-10-31 14:15 ` Keith Owens
2000-10-31 14:29 ` Petko Manolov
2000-10-31 14:34 ` Keith Owens
2000-10-31 14:41 ` Petko Manolov
[not found] ` <39FFE612.2688A5AD@yahoo.com>
2000-11-03 17:45 ` [patch] NE2000 Jorge Nerin
2000-11-04 5:28 ` Andrew Morton
2000-11-06 11:34 ` Jorge Nerin
2000-11-06 18:40 ` kuznet
2000-11-06 18:46 ` kuznet
2000-11-06 22:32 ` Andrew Morton
2000-11-08 16:45 ` kuznet
2000-11-07 2:40 ` Andrew Morton
2000-11-08 20:31 ` kuznet
2000-11-09 1:18 ` David S. Miller
2000-11-09 1:27 ` David S. Miller
2000-11-09 11:20 ` David S. Miller [this message]
2000-11-10 1:45 ` Tom Leete
2000-11-09 18:03 ` kuznet
2000-11-09 18:01 ` Steve Whitehouse
2000-11-06 7:06 ` ping -f kills ne2k (was:[patch] NE2000) Paul Gortmaker
2000-11-06 20:08 ` Jorge Nerin
2000-11-09 15:11 ` Jorge Nerin
2000-10-30 9:17 ` [patch] NE2000 Paul Gortmaker
2000-10-30 14:58 ` pavel rabel
2000-10-30 19:29 ` Jeff Garzik
2000-11-01 5:31 ` Paul Gortmaker
2000-11-01 8:23 ` Donald Becker
2000-11-01 13:27 ` Jeff Garzik
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=200011091120.DAA27190@pizda.ninka.net \
--to=davem@redhat.com \
--cc=andrewm@uow.edu.au \
--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
all inboxes | Powered by JetHome®