Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6163a194 authored by Jon Paul Maloy's avatar Jon Paul Maloy Committed by David S. Miller
Browse files

tipc: decrease connection flow control window



Memory overhead when allocating big buffers for data transfer may
be quite significant. E.g., truesize of a 64 KB buffer turns out
to be 132 KB, 2 x the requested size.

This invalidates the "worst case" calculation we have been
using to determine the default socket receive buffer limit,
which is based on the assumption that 1024x64KB = 67MB buffers
may be queued up on a socket.

Since TIPC connections cannot survive hitting the buffer limit,
we have to compensate for this overhead.

We do that in this commit by dividing the fix connection flow
control window from 1024 (2*512) messages to 512 (2*256). Since
older version nodes send out acks at 512 message intervals,
compatibility with such nodes is guaranteed, although performance
may be non-optimal in such cases.

Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Reviewed-by: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3fdddd85
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -154,10 +154,11 @@ static int __init tipc_init(void)
	tipc_max_ports = CONFIG_TIPC_PORTS;
	tipc_max_ports = CONFIG_TIPC_PORTS;
	tipc_net_id = 4711;
	tipc_net_id = 4711;


	sysctl_tipc_rmem[0] = CONN_OVERLOAD_LIMIT >> 4 << TIPC_LOW_IMPORTANCE;
	sysctl_tipc_rmem[0] = TIPC_CONN_OVERLOAD_LIMIT >> 4 <<
	sysctl_tipc_rmem[1] = CONN_OVERLOAD_LIMIT >> 4 <<
			      TIPC_LOW_IMPORTANCE;
	sysctl_tipc_rmem[1] = TIPC_CONN_OVERLOAD_LIMIT >> 4 <<
			      TIPC_CRITICAL_IMPORTANCE;
			      TIPC_CRITICAL_IMPORTANCE;
	sysctl_tipc_rmem[2] = CONN_OVERLOAD_LIMIT;
	sysctl_tipc_rmem[2] = TIPC_CONN_OVERLOAD_LIMIT;


	res = tipc_core_start();
	res = tipc_core_start();
	if (res)
	if (res)
+5 −4
Original line number Original line Diff line number Diff line
@@ -42,8 +42,9 @@
#include "msg.h"
#include "msg.h"
#include "node_subscr.h"
#include "node_subscr.h"


#define TIPC_FLOW_CONTROL_WIN 512
#define TIPC_CONNACK_INTV         256
#define CONN_OVERLOAD_LIMIT	((TIPC_FLOW_CONTROL_WIN * 2 + 1) * \
#define TIPC_FLOWCTRL_WIN        (TIPC_CONNACK_INTV * 2)
#define TIPC_CONN_OVERLOAD_LIMIT ((TIPC_FLOWCTRL_WIN * 2 + 1) * \
				  SKB_TRUESIZE(TIPC_MAX_USER_MSG_SIZE))
				  SKB_TRUESIZE(TIPC_MAX_USER_MSG_SIZE))


/**
/**
@@ -187,7 +188,7 @@ static inline void tipc_port_unlock(struct tipc_port *p_ptr)


static inline int tipc_port_congested(struct tipc_port *p_ptr)
static inline int tipc_port_congested(struct tipc_port *p_ptr)
{
{
	return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2);
	return ((p_ptr->sent - p_ptr->acked) >= TIPC_FLOWCTRL_WIN);
}
}




+2 −2
Original line number Original line Diff line number Diff line
@@ -1101,7 +1101,7 @@ static int tipc_recvmsg(struct kiocb *iocb, struct socket *sock,
	/* Consume received message (optional) */
	/* Consume received message (optional) */
	if (likely(!(flags & MSG_PEEK))) {
	if (likely(!(flags & MSG_PEEK))) {
		if ((sock->state != SS_READY) &&
		if ((sock->state != SS_READY) &&
		    (++port->conn_unacked >= TIPC_FLOW_CONTROL_WIN))
		    (++port->conn_unacked >= TIPC_CONNACK_INTV))
			tipc_acknowledge(port->ref, port->conn_unacked);
			tipc_acknowledge(port->ref, port->conn_unacked);
		advance_rx_queue(sk);
		advance_rx_queue(sk);
	}
	}
@@ -1210,7 +1210,7 @@ static int tipc_recv_stream(struct kiocb *iocb, struct socket *sock,


	/* Consume received message (optional) */
	/* Consume received message (optional) */
	if (likely(!(flags & MSG_PEEK))) {
	if (likely(!(flags & MSG_PEEK))) {
		if (unlikely(++port->conn_unacked >= TIPC_FLOW_CONTROL_WIN))
		if (unlikely(++port->conn_unacked >= TIPC_CONNACK_INTV))
			tipc_acknowledge(port->ref, port->conn_unacked);
			tipc_acknowledge(port->ref, port->conn_unacked);
		advance_rx_queue(sk);
		advance_rx_queue(sk);
	}
	}