netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sowmini Varadhan <sowmini.varadhan@oracle.com>
To: Tom Herbert <tom@herbertland.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v2 net-next 11/13] kcm: Add memory limit for receive message construction
Date: Mon, 7 Mar 2016 20:28:01 -0500	[thread overview]
Message-ID: <20160308012726.GA10335@oracle.com> (raw)
In-Reply-To: <1457388672-2600559-12-git-send-email-tom@herbertland.com>

On (03/07/16 14:11), Tom Herbert wrote:
> 
> Message assembly is performed on the TCP socket. This is logically
> equivalent of an application that performs a peek on the socket to find
> out how much memory is needed for a receive buffer. The receive socket
> buffer also provides the maximum message size which is checked.
> 
> The receive algorithm is something like:
> 
>    1) Receive the first skbuf for a message (or skbufs if multiple are
>       needed to determine message length).
>    2) Check the message length against the number of bytes in the TCP
>       receive queue (tcp_inq()).
> 	- If all the bytes of the message are in the queue (incluing the
> 	  skbuf received), then proceed with message assembly (it should
> 	  complete with the tcp_read_sock)
>         - Else, mark the psock with the number of bytes needed to
> 	  complete the message.
>    3) In TCP data ready function, if the psock indicates that we are
>       waiting for the rest of the bytes of a messages, check the number
>       of queued bytes against that.
>         - If there are still not enough bytes for the message, just
> 	  return
>         - Else, clear the waiting bytes and proceed to receive the
> 	  skbufs.  The message should now be received in one
> 	  tcp_read_sock

AIUI, the above logic will make sure that ->sk_data_ready reads the entire
message in one shot.  For "very large" messages, TCP's windowing logic
will eventually kick in, and the sender (all threads in the sender
that share the single tcp socket)  will be throttled, correct?  

I suppose that (all sender threads being blocked behind one "too large"
message) may not an unreasonable constraint, but is it possible to end up
with a deadlocked TCP (recv) socket- one for which the receiver 
closed the window (so sender TCP cannot send the remaining
bytes of the kcm message), but cannot be drained because of #3 above?

BTW there are a couple of typos above;
s/skbuf/skbuff
s/incluing/including

--Sowmini

  reply	other threads:[~2016-03-08  1:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-07 22:10 [PATCH v2 net-next 00/13] kcm: Kernel Connection Multiplexor (KCM) Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 01/13] rcu: Add list_next_or_null_rcu Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 02/13] net: Make sock_alloc exportable Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 03/13] net: Allow MSG_EOR in each msghdr of sendmmsg Tom Herbert
2018-04-07  8:40   ` Andreas Schwab
2016-03-07 22:11 ` [PATCH v2 net-next 04/13] net: Add MSG_BATCH flag Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 05/13] net: Walk fragments in __skb_splice_bits Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 06/13] tcp: Add tcp_inq to get available receive bytes on socket Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 07/13] kcm: Kernel Connection Multiplexor module Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 08/13] kcm: Add statistics and proc interfaces Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 09/13] kcm: Splice support Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 10/13] kcm: Sendpage support Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 11/13] kcm: Add memory limit for receive message construction Tom Herbert
2016-03-08  1:28   ` Sowmini Varadhan [this message]
2016-03-07 22:11 ` [PATCH v2 net-next 12/13] kcm: Add receive message timeout Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 13/13] kcm: Add description in Documentation Tom Herbert
2016-03-09 21:38 ` [PATCH v2 net-next 00/13] kcm: Kernel Connection Multiplexor (KCM) 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=20160308012726.GA10335@oracle.com \
    --to=sowmini.varadhan@oracle.com \
    --cc=davem@davemloft.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=tom@herbertland.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;
as well as URLs for NNTP newsgroup(s).