[CRIU] [PATCH 2/2] tcp: don't split packets for restoring a send queue

Pavel Emelyanov xemul at parallels.com
Mon Dec 8 04:46:52 PST 2014


On 11/21/2014 05:10 PM, Andrey Vagin wrote:
> The kernel can do it better. The problem exists only for recv queues.
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>

Applied.

> ---
>  include/kerndat.h | 1 -
>  kerndat.c         | 7 ++-----
>  sk-tcp.c          | 8 +++++---
>  3 files changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/include/kerndat.h b/include/kerndat.h
> index 1f511cf..12517d1 100644
> --- a/include/kerndat.h
> +++ b/include/kerndat.h
> @@ -16,7 +16,6 @@ extern int kerndat_get_dirty_track(void);
>  
>  struct kerndat_s {
>  	dev_t shmem_dev;
> -	int tcp_max_wshare;
>  	int tcp_max_rshare;
>  	int last_cap;
>  	u64 zero_page_pfn;
> diff --git a/kerndat.c b/kerndat.c
> index 68c3e35..7855066 100644
> --- a/kerndat.c
> +++ b/kerndat.c
> @@ -19,7 +19,6 @@
>  #include "util.h"
>  
>  struct kerndat_s kdat = {
> -	.tcp_max_wshare = 2U << 20,
>  	.tcp_max_rshare = 3U << 20,
>  };
>  
> @@ -197,7 +196,6 @@ static int tcp_read_sysctl_limits(void)
>  	int ret;
>  
>  	struct sysctl_req req[] = {
> -		{ "net/ipv4/tcp_wmem", &vect[0], CTL_U32A(ARRAY_SIZE(vect[0])) },
>  		{ "net/ipv4/tcp_rmem", &vect[1], CTL_U32A(ARRAY_SIZE(vect[1])) },
>  		{ },
>  	};
> @@ -212,13 +210,12 @@ static int tcp_read_sysctl_limits(void)
>  		goto out;
>  	}
>  
> -	kdat.tcp_max_wshare = min(kdat.tcp_max_wshare, (int)vect[0][2]);
>  	kdat.tcp_max_rshare = min(kdat.tcp_max_rshare, (int)vect[1][2]);
>  
> -	if (kdat.tcp_max_wshare < 128 || kdat.tcp_max_rshare < 128)
> +	if (kdat.tcp_max_rshare < 128)
>  		pr_warn("The memory limits for TCP queues are suspiciously small\n");
>  out:
> -	pr_debug("TCP queue memory limits are %d:%d\n", kdat.tcp_max_wshare, kdat.tcp_max_rshare);
> +	pr_debug("TCP recv queue memory limit is %d\n", kdat.tcp_max_rshare);
>  	return 0;
>  }
>  
> diff --git a/sk-tcp.c b/sk-tcp.c
> index 3ef7015..e280ee6 100644
> --- a/sk-tcp.c
> +++ b/sk-tcp.c
> @@ -456,7 +456,7 @@ static int restore_tcp_seqs(int sk, TcpStreamEntry *tse)
>  static int __send_tcp_queue(int sk, int queue, u32 len, struct cr_img *img)
>  {
>  	int ret, err = -1;
> -	int off, max;
> +	int off;
>  	char *buf;
>  
>  	buf = xmalloc(len);
> @@ -466,10 +466,12 @@ static int __send_tcp_queue(int sk, int queue, u32 len, struct cr_img *img)
>  	if (read_img_buf(img, buf, len) < 0)
>  		goto err;
>  
> -	max = (queue == TCP_SEND_QUEUE) ? kdat.tcp_max_wshare : kdat.tcp_max_rshare;
>  	off = 0;
>  	while (len) {
> -		int chunk = (len > max ? max : len);
> +		int chunk = len;
> +
> +		if (queue == TCP_RECV_QUEUE && len > kdat.tcp_max_rshare)
> +			chunk = kdat.tcp_max_rshare;
>  
>  		ret = send(sk, buf + off, chunk, 0);
>  		if (ret <= 0) {
> 



More information about the CRIU mailing list