Commit 51e6e19d authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

uffd: Turn lpi_hash into list

After previous patch we no longer need this hash since
we don't need fd -> lpi conversion.

travis-ci: success for uffd: A set of improvements over criu/uffd.c
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Acked-by: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
parent 6f4c60c6
...@@ -57,11 +57,10 @@ struct lazy_pages_info { ...@@ -57,11 +57,10 @@ struct lazy_pages_info {
unsigned long total_pages; unsigned long total_pages;
unsigned long copied_pages; unsigned long copied_pages;
struct hlist_node hash; struct list_head l;
}; };
#define LPI_HASH_SIZE 16 static LIST_HEAD(lpis);
static struct hlist_head lpi_hash[LPI_HASH_SIZE];
static struct lazy_pages_info *lpi_init(void) static struct lazy_pages_info *lpi_init(void)
{ {
...@@ -73,7 +72,7 @@ static struct lazy_pages_info *lpi_init(void) ...@@ -73,7 +72,7 @@ static struct lazy_pages_info *lpi_init(void)
memset(lpi, 0, sizeof(*lpi)); memset(lpi, 0, sizeof(*lpi));
INIT_LIST_HEAD(&lpi->pages); INIT_LIST_HEAD(&lpi->pages);
INIT_HLIST_NODE(&lpi->hash); INIT_LIST_HEAD(&lpi->l);
return lpi; return lpi;
} }
...@@ -89,25 +88,6 @@ static void lpi_fini(struct lazy_pages_info *lpi) ...@@ -89,25 +88,6 @@ static void lpi_fini(struct lazy_pages_info *lpi)
free(lpi); free(lpi);
} }
static void lpi_hash_init(void)
{
int i;
for (i = 0; i < LPI_HASH_SIZE; i++)
INIT_HLIST_HEAD(&lpi_hash[i]);
}
static void lpi_hash_fini(void)
{
struct lazy_pages_info *p;
struct hlist_node *n;
int i;
for (i = 0; i < LPI_HASH_SIZE; i++)
hlist_for_each_entry_safe(p, n, &lpi_hash[i], hash)
lpi_fini(p);
}
static int prepare_sock_addr(struct sockaddr_un *saddr) static int prepare_sock_addr(struct sockaddr_un *saddr)
{ {
int len; int len;
...@@ -354,7 +334,7 @@ static int ud_open(int client, struct lazy_pages_info **_lpi) ...@@ -354,7 +334,7 @@ static int ud_open(int client, struct lazy_pages_info **_lpi)
if ((lpi->total_pages = find_vmas(lpi)) == -1) if ((lpi->total_pages = find_vmas(lpi)) == -1)
goto out; goto out;
hlist_add_head(&lpi->hash, &lpi_hash[lpi->uffd % LPI_HASH_SIZE]); list_add_tail(&lpi->l, &lpis);
*_lpi = lpi; *_lpi = lpi;
return 0; return 0;
...@@ -770,20 +750,17 @@ static int handle_requests(int epollfd, struct epoll_event *events) ...@@ -770,20 +750,17 @@ static int handle_requests(int epollfd, struct epoll_event *events)
} }
} }
pr_debug("Handle remaining pages\n"); pr_debug("Handle remaining pages\n");
for (i = 0; i < LPI_HASH_SIZE; i++) { list_for_each_entry(lpi, &lpis, l) {
hlist_for_each_entry(lpi, &lpi_hash[i], hash) { ret = handle_remaining_pages(lpi, dest);
ret = handle_remaining_pages(lpi, dest); if (ret < 0) {
if (ret < 0) { pr_err("Error during remaining page copy\n");
pr_err("Error during remaining page copy\n"); ret = 1;
ret = 1; goto out;
goto out;
}
} }
} }
for (i = 0; i < LPI_HASH_SIZE; i++) list_for_each_entry(lpi, &lpis, l)
hlist_for_each_entry(lpi, &lpi_hash[i], hash) ret += lazy_pages_summary(lpi);
ret += lazy_pages_summary(lpi);
out: out:
free(dest); free(dest);
...@@ -882,7 +859,6 @@ static int prepare_uffds(int epollfd) ...@@ -882,7 +859,6 @@ static int prepare_uffds(int epollfd)
return 0; return 0;
close_uffd: close_uffd:
lpi_hash_fini();
close_safe(&client); close_safe(&client);
close(listen); close(listen);
return -1; return -1;
...@@ -897,8 +873,6 @@ int cr_lazy_pages() ...@@ -897,8 +873,6 @@ int cr_lazy_pages()
if (check_for_uffd()) if (check_for_uffd())
return -1; return -1;
lpi_hash_init();
if (lazy_pages_prepare_pstree()) if (lazy_pages_prepare_pstree())
return -1; return -1;
...@@ -913,7 +887,6 @@ int cr_lazy_pages() ...@@ -913,7 +887,6 @@ int cr_lazy_pages()
return -1; return -1;
ret = handle_requests(epollfd, events); ret = handle_requests(epollfd, events);
lpi_hash_fini();
return ret; return ret;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment