[5/5] uffd: Relax counting the number of sockets

Submitted by Pavel Emelianov on Nov. 21, 2016, 11:27 a.m.

Details

Message ID 5832DA0F.4000205@virtuozzo.com
State Superseded
Series "Some more cleanups over uffd.c"
Headers show

Commit Message

Pavel Emelianov Nov. 21, 2016, 11:27 a.m.
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/uffd.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/uffd.c b/criu/uffd.c
index a3c72aa..6bf3897 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -108,13 +108,6 @@  static void lpi_fini(struct lazy_pages_info *lpi)
 	free(lpi);
 }
 
-static int epoll_nr_fds(int nr_tasks)
-{
-       if (opts.use_page_server)
-               return nr_tasks + 1;
-       return nr_tasks;
-}
-
 static int prepare_sock_addr(struct sockaddr_un *saddr)
 {
 	int len;
@@ -730,12 +723,12 @@  static int lazy_pages_summary(struct lazy_pages_info *lpi)
 
 #define POLL_TIMEOUT 5000
 
-static int handle_requests(int epollfd, struct epoll_event *events)
+static int handle_requests(int epollfd, struct epoll_event *events, int nr_fds)
 {
 	struct lazy_pages_info *lpi;
 	int ret;
 
-	ret = epoll_run_rfds(epollfd, events, epoll_nr_fds(task_entries->nr_tasks), POLL_TIMEOUT);
+	ret = epoll_run_rfds(epollfd, events, nr_fds, POLL_TIMEOUT);
 	if (ret < 0)
 		goto out;
 
@@ -887,7 +880,7 @@  int cr_lazy_pages(bool daemon)
 		}
 	}
 
-	nr_fds = epoll_nr_fds(task_entries->nr_tasks);
+	nr_fds = task_entries->nr_tasks + (opts.use_page_server ? 1 : 0);
 	epollfd = prepare_epoll(nr_fds, &events);
 	if (epollfd < 0)
 		return -1;
@@ -900,7 +893,7 @@  int cr_lazy_pages(bool daemon)
 			return -1;
 	}
 
-	ret = handle_requests(epollfd, events);
+	ret = handle_requests(epollfd, events, nr_fds);
 
 	return ret;
 }

Comments

Mike Rapoport Nov. 21, 2016, 12:52 p.m.
On Mon, Nov 21, 2016 at 02:27:11PM +0300, Pavel Emelyanov wrote:
> 
> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>

Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com>

> ---
>  criu/uffd.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/criu/uffd.c b/criu/uffd.c
> index a3c72aa..6bf3897 100644
> --- a/criu/uffd.c
> +++ b/criu/uffd.c
> @@ -108,13 +108,6 @@ static void lpi_fini(struct lazy_pages_info *lpi)
>  	free(lpi);
>  }
>  
> -static int epoll_nr_fds(int nr_tasks)
> -{
> -       if (opts.use_page_server)
> -               return nr_tasks + 1;
> -       return nr_tasks;
> -}
> -
>  static int prepare_sock_addr(struct sockaddr_un *saddr)
>  {
>  	int len;
> @@ -730,12 +723,12 @@ static int lazy_pages_summary(struct lazy_pages_info *lpi)
>  
>  #define POLL_TIMEOUT 5000
>  
> -static int handle_requests(int epollfd, struct epoll_event *events)
> +static int handle_requests(int epollfd, struct epoll_event *events, int nr_fds)
>  {
>  	struct lazy_pages_info *lpi;
>  	int ret;
>  
> -	ret = epoll_run_rfds(epollfd, events, epoll_nr_fds(task_entries->nr_tasks), POLL_TIMEOUT);
> +	ret = epoll_run_rfds(epollfd, events, nr_fds, POLL_TIMEOUT);
>  	if (ret < 0)
>  		goto out;
>  
> @@ -887,7 +880,7 @@ int cr_lazy_pages(bool daemon)
>  		}
>  	}
>  
> -	nr_fds = epoll_nr_fds(task_entries->nr_tasks);
> +	nr_fds = task_entries->nr_tasks + (opts.use_page_server ? 1 : 0);
>  	epollfd = prepare_epoll(nr_fds, &events);
>  	if (epollfd < 0)
>  		return -1;
> @@ -900,7 +893,7 @@ int cr_lazy_pages(bool daemon)
>  			return -1;
>  	}
>  
> -	ret = handle_requests(epollfd, events);
> +	ret = handle_requests(epollfd, events, nr_fds);
>  
>  	return ret;
>  }
> -- 
> 2.5.0
>