netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: David Miller <davem@davemloft.net>
Cc: Peter Zijlstra <peterz@infradead.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: net/ && prepare_to_wait_exclusive()
Date: Wed, 14 May 2014 20:40:59 +0200	[thread overview]
Message-ID: <20140514184059.GA9730@redhat.com> (raw)

Hello,

I know almost nothing about networking and of course I do not understand
this code. So I can be easily wrong, but (at least) unix_wait_for_peer()
looks wrong wrt prepare_to_wait_exclusive(), and ignoring the potential
optimizations it needs

	-	finish_wait(&u->peer_wait, &wait);
	+	abort_exclusive_wait(..., TASK_INTERRUPTIBLE, NULL);

change?

Suppose that unix_recvq_full(X) == true and 2 threads, T1 and T2, are
sleeping in unix_dgram_sendmsg().

Another thread does read(X) and this empties ->sk_receive_queue so that
the next read(X) will block. We should wake up at least one thread.

The reader does wake_up_interruptible_sync_poll() and this is
__wake_up_common(nr_exclusive => 1), so this (say) wakes T1 up.

Suppose that this wake_up() races with (to simplify) SIGKILL and thus
T1 writes nothing and exits.

Now, the reader does another read(X) and blocks, ->sk_receive_queue is
empty, we have the writer T2 but it is still blocked too?

Or I completely misread this code?


(On a related note... looks like ___wait_event() is not complicated^W
 clever enough to implement wait_event_interruptible_exclusive_timeout)

Oleg.

                 reply	other threads:[~2014-05-14 18:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20140514184059.GA9730@redhat.com \
    --to=oleg@redhat.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).