[CRIU] [PATCH 07/12] page-xfer: Rework send_psi to use send (and flags)

Mike Rapoport rppt at linux.vnet.ibm.com
Wed Jun 28 19:12:55 MSK 2017


On Wed, Jun 28, 2017 at 04:47:32PM +0300, Pavel Emelyanov wrote:
> There are cases when we need to specify flags with which
> to send the ps_iov, so tune-up the send_psi for that and
> use where needed.
> 
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
> ---
>  criu/page-xfer.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/criu/page-xfer.c b/criu/page-xfer.c
> index d2745e2..e2c4e10 100644
> --- a/criu/page-xfer.c
> +++ b/criu/page-xfer.c
> @@ -84,16 +84,21 @@ static inline u32 decode_ps_flags(u32 cmd)
>  	return cmd >> PS_CMD_BITS;
>  }
> 
> -static inline int send_psi(int sk, struct page_server_iov *pi)
> +static inline int send_psi_flags(int sk, struct page_server_iov *pi, int flags)
>  {
> -	if (write(sk, pi, sizeof(*pi)) != sizeof(*pi)) {
> -		pr_perror("Can't write PSI %d to server", pi->cmd);
> +	if (send(sk, pi, sizeof(*pi), flags) != sizeof(*pi)) {
> +		pr_perror("Can't send PSI %d to server", pi->cmd);
>  		return -1;
>  	}
> 
>  	return 0;
>  }
> 
> +static inline int send_psi(int sk, struct page_server_iov *pi)
> +{
> +	return send_psi_flags(sk, pi, 0);
> +}
> +
>  /* page-server xfer */
>  static int write_pages_to_server(struct page_xfer *xfer,
>  		int p, unsigned long len)
> @@ -1161,11 +1166,9 @@ int request_remote_pages(int pid, unsigned long addr, int nr_pages)
>  		.dst_id		= pid,
>  	};
> 
> -	/* We cannot use send_psi here because we have to use MSG_DONTWAIT */
> -	if (send(page_server_sk, &pi, sizeof(pi), MSG_DONTWAIT) != sizeof(pi)) {
> -		pr_perror("Can't write PSI to server");
> +	/* XXX: why MSG_DONTWAIT here? */

Frankly, I don't remember...

> +	if (send_psi_flags(page_server_sk, &pi, MSG_DONTWAIT))
>  		return -1;
> -	}
> 
>  	tcp_nodelay(page_server_sk, true);
>  	return 0;
> -- 
> 2.1.4
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> 



More information about the CRIU mailing list