mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kuznet@ms2.inr.ac.ru
To: morton@nortelnetworks.com (Andrew Morton)
Cc: andrewm@uow.edu.au, davem@redhat.com (Dave Miller),
	linux-kernel@vger.kernel.org
Subject: Re: [patch] NE2000
Date: Wed, 8 Nov 2000 23:31:28 +0300 (MSK)	[thread overview]
Message-ID: <200011082031.XAA20453@ms2.inr.ac.ru> (raw)
In-Reply-To: <3A076B91.80C63C58@asiapacificm01.nt.com> from "Andrew Morton" at Nov 7, 0 02:40:17 am

Hello!

[ Dave, please, look! I will strain brains this night too.
  Indeed, this sounds dubious. ]

No, Andrew, this is surely not related to either of puzzles even if it
is really buggy place. ping does not use either tcp or socket lock. 8)

> Can sock_fasync() be called when we're on a waitqueue, not in
> state TASK_RUNNING and prior to schedule()?

No top level syscalls can be called in either state but running.
That funny BUG() proves the opposite, but this must not happen in any case.
At least, I still cannot reproduce this here. 8)

Alexey



> OK, there are a few areas which look fishy.
> 
> Calling __lock_sock when we're getting ready to wait
> on a different waitqueue looks like a rather risky area.
> We have a single task which is on two waitqueues.
> 
> Consider the case of tcp_data_wait():
> 
> 	add_wait_queue(sk->sleep)
> 	set_current_state(TASK_INTERRUPTIBLE);
> 	release_sock(sk);
> 	if (...)	/* Suppose this evaluates to false */
> 		schedule_timeout();
> 	lock_sock();
> 
> 	__lock_sock()
> 	{
> 		add_wait_queue_exclusive(sk->lock.wq);
> 		/* Window 1: What does a wake_up(sk->sleep) do here? */
> 		current->state = TASK_EXCLUSIVE | TASK_UNINTERRUPTIBLE;
> 		/* Window 2: Bad things happen here */
> 		schedule();
> 
> If someone does a wakeup(sk->sleep) in Window 2 in
> __lock_sock() the wakeup code will think that the
> task is sleeping on sk->sleep in state
> TASK_EXCLUSIVE|TASK_UNINTERRUPTIBLE,
> when in fact it is not.  So a wakeup which _should_ have gone to
> a different exclusive task actually goes to this one. This is
> fantastically hard to hit because of the direction of the
> waitqueue scan.
> 
> If the wakeup on sk->sleep happens during Window 1
> it will be completely lost, but that's OK because
> this task is not yet TASK_EXCLUSIVE (providing the
> write ordering behaves as we want?)
> 
> If a wakeup on sk->lock.wq happens during Window 1
> it will be completely lost.
> 
> wait_for_connect() and wait_for_tcp_memory() play similar
> games with lock_sock() whereby they can appear to be on
> two waitqueues at the same time. And again, because
> lock_sock() uses TASK_EXCLUSIVE a wake_up on sk->sleep
> could choose this task instead of a TASK_EXCLUSIVE task
> which is _really_ sleeping on sk->sleep.
> 
> Now, this may not be a problem in practise, and in fact the
> above may not be bugs because I missed something. But I suggest you
> have a think about it.  My brain is starting to hurt.
> 
> But none of these explain Jorge's problem.  How he got to where
> he did in !TASK_RUNNING.  Plus the possible lock_sock problems
> just look too damn hard to hit to explain Jorge's repeatability.
> 
> It may be useful to put a Pentium hardware watchpoint onto
> current->state.  Does kdb support those?
> 
> Can sock_fasync() be called when we're on a waitqueue, not in
> state TASK_RUNNING and prior to schedule()?
> 
> inet_wait_for_connect() is OK.
> wait_for_tcp_connect() is OK.
> tcp_close() is OK.
> 
> Also, are you sure that all occurrences of 
> 
> 	current->state = <whatever>;
> 
> are still safe on weakly ordered CPUs? (Not that this
> would explain Jorge's problem).
> 
> hmm..  khttpd tries to do wake-one, but
> interruptible_sleep_on_timeout() confounds it.
> Bummer.
> 

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

  reply	other threads:[~2000-11-08 20:32 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 [this message]
2000-11-09  1:18                   ` David S. Miller
2000-11-09  1:27                   ` David S. Miller
2000-11-09 11:20                     ` David S. Miller
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=200011082031.XAA20453@ms2.inr.ac.ru \
    --to=kuznet@ms2.inr.ac.ru \
    --cc=andrewm@uow.edu.au \
    --cc=davem@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=morton@nortelnetworks.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

all inboxes | Powered by JetHome®