[CRIU] [PATCH 05/10] uffd: Keep lpi pointer on epoll_event, not fd

Mike Rapoport rppt at linux.vnet.ibm.com
Sat Nov 12 05:53:23 PST 2016


On Sat, Nov 12, 2016 at 08:24:44AM +0300, Pavel Emelyanov wrote:
> This helps us get lpi MUCH faster on #PF.
> 
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>

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

> ---
>  criu/uffd.c | 25 ++++++-------------------
>  1 file changed, 6 insertions(+), 19 deletions(-)
> 
> diff --git a/criu/uffd.c b/criu/uffd.c
> index 950a5ea..3fed7fa 100644
> --- a/criu/uffd.c
> +++ b/criu/uffd.c
> @@ -98,19 +98,6 @@ static void lpi_hash_init(void)
>  		INIT_HLIST_HEAD(&lpi_hash[i]);
>  }
> 
> -struct lazy_pages_info *uffd_to_lpi(int uffd)
> -{
> -	struct lazy_pages_info *lpi;
> -	struct hlist_head *head;
> -
> -	head = &lpi_hash[uffd % LPI_HASH_SIZE];
> -	hlist_for_each_entry(lpi, head, hash)
> -		if (lpi->uffd == uffd)
> -			return lpi;
> -
> -	return NULL;
> -}
> -
>  static void lpi_hash_fini(void)
>  {
>  	struct lazy_pages_info *p;
> @@ -779,8 +766,8 @@ static int handle_requests(int epollfd, struct epoll_event *events)
> 
>  		for (i = 0; i < ret; i++) {
>  			int err;
> -			lpi = uffd_to_lpi(events[i].data.fd);
> -			BUG_ON(!lpi);
> +
> +			lpi = (struct lazy_pages_info *)events[i].data.ptr;
>  			err = handle_user_fault(lpi, dest);
>  			if (err < 0)
>  				goto out;
> @@ -844,13 +831,13 @@ free_events:
>  	return -1;
>  }
> 
> -static int epoll_add_fd(int epollfd, int fd)
> +static int epoll_add_lpi(int epollfd, struct lazy_pages_info *lpi)
>  {
>  	struct epoll_event ev;
> 
>  	ev.events = EPOLLIN;
> -	ev.data.fd = fd;
> -	if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev) == -1) {
> +	ev.data.ptr = lpi;
> +	if (epoll_ctl(epollfd, EPOLL_CTL_ADD, lpi->uffd, &ev) == -1) {
>  		pr_perror("epoll_ctl failed");
>  		return -1;
>  	}
> @@ -897,7 +884,7 @@ static int prepare_uffds(int listen, int epollfd)
>  			goto close_uffd;
>  		if (lpi == NULL)
>  			continue;
> -		if (epoll_add_fd(epollfd, lpi->uffd))
> +		if (epoll_add_lpi(epollfd, lpi))
>  			goto close_uffd;
>  	}
> 
> -- 
> 2.5.0
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> 



More information about the CRIU mailing list