From: David Miller <davem@davemloft.net>
To: jbaron@akamai.com
Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com
Subject: Re: [PATCH] tcp: set SOCK_NOSPACE under memory presure
Date: Tue, 21 Apr 2015 17:33:00 -0400 (EDT) [thread overview]
Message-ID: <20150421.173300.553980773035401270.davem@davemloft.net> (raw)
In-Reply-To: <20150420200513.11D8E202D@prod-mail-relay06.akamai.com>
From: Jason Baron <jbaron@akamai.com>
Date: Mon, 20 Apr 2015 20:05:13 +0000 (GMT)
> Under tcp memory pressure, calling epoll_wait() in edge triggered
> mode after -EAGAIN, can result in an indefinite hang in epoll_wait(),
> even when there is suffcient memory available to continue making
> progress. The problem is that __sk_mem_schedule() can return 0,
> under memory pressure without having set the SOCK_NOSPACE flag. Thus,
> even though all the outstanding packets have been acked, we never
> get the EPOLLOUT that we are expecting from epoll_wait().
>
> This issue is currently limited to epoll when used in edge trigger
> mode, since 'tcp_poll()', does in fact currently set SOCK_NOSPACE.
> This is sufficient for poll()/select() and epoll() in level trigger
> mode. However, in edge trigger mode, epoll() is relying on the write
> path to set SOCK_NOSPACE. So I view this patch as bringing us into
> sync with poll()/select() and epoll() level trigger behavior.
Can you explain exactly how epoll in edge trigger mode is
depending upon SOCK_NOSPACE being set in this way? I tried
to read the epoll code and it just seems to call ->poll()
in the normal way when returning event state.
Also, there are exactly two call sites of sk_stream_wait_space()
for TCP, and they both look like this:
====================
wait_for_sndbuf:
set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
wait_for_memory:
tcp_push(sk, flags & ~MSG_MORE, mss_now,
TCP_NAGLE_PUSH, size_goal);
if ((err = sk_stream_wait_memory(sk, &timeo)) != 0)
goto do_error;
====================
Definitely, the person who wrote this code intended SOCK_NOSPACE to be
set only when we are waiting for sndbuf space rather than just memory.
At a minimum, I need a more detailed commit log message for this,
showing the exact code paths in epoll() that have this requirement and
thus create the looping condition. Because with a casual scan of the
epoll code I could not figure it out.
Thanks.
next prev parent reply other threads:[~2015-04-21 21:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-20 20:05 [PATCH] tcp: set SOCK_NOSPACE under memory presure Jason Baron
2015-04-21 21:33 ` David Miller [this message]
2015-04-22 14:25 ` Jason Baron
2015-04-30 14:34 ` Jason Baron
2015-04-30 15:44 ` David Miller
2015-05-04 23:12 ` David Miller
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=20150421.173300.553980773035401270.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=jbaron@akamai.com \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).