[02/10] uffdd: Read pages directly into destination buffer

Submitted by Pavel Emelianov on Nov. 12, 2016, 5:23 a.m.

Details

Message ID 5826A762.30108@virtuozzo.com
State Accepted
Series "uffd: A set of improvements over criu/uffd.c"
Commit 641add36d161af7f8beac8a4fe7e4537681db24a
Headers show

Commit Message

Pavel Emelianov Nov. 12, 2016, 5:23 a.m.
This avoids excessive memcpy() one instruction below.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/uffd.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/uffd.c b/criu/uffd.c
index 3472e7d..4ee37fa 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -381,7 +381,6 @@  out:
 static int get_page(struct lazy_pages_info *lpi, unsigned long addr, void *dest)
 {
 	int ret;
-	unsigned char buf[PAGE_SIZE];
 
 	lpi->pr.reset(&lpi->pr);
 
@@ -393,13 +392,11 @@  static int get_page(struct lazy_pages_info *lpi, unsigned long addr, void *dest)
 	if (pagemap_zero(lpi->pr.pe))
 		return 0;
 
-	ret = lpi->pr.read_pages(&lpi->pr, addr, 1, buf);
+	ret = lpi->pr.read_pages(&lpi->pr, addr, 1, dest);
 	pr_debug("read_pages ret %d\n", ret);
 	if (ret <= 0)
 		return ret;
 
-	memcpy(dest, buf, PAGE_SIZE);
-
 	return 1;
 }
 

Comments

Mike Rapoport Nov. 12, 2016, 1:40 p.m.
On Sat, Nov 12, 2016 at 08:23:46AM +0300, Pavel Emelyanov wrote:
> This avoids excessive memcpy() one instruction below.
> 
> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>

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

> ---
>  criu/uffd.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/criu/uffd.c b/criu/uffd.c
> index 3472e7d..4ee37fa 100644
> --- a/criu/uffd.c
> +++ b/criu/uffd.c
> @@ -381,7 +381,6 @@ out:
>  static int get_page(struct lazy_pages_info *lpi, unsigned long addr, void *dest)
>  {
>  	int ret;
> -	unsigned char buf[PAGE_SIZE];
> 
>  	lpi->pr.reset(&lpi->pr);
> 
> @@ -393,13 +392,11 @@ static int get_page(struct lazy_pages_info *lpi, unsigned long addr, void *dest)
>  	if (pagemap_zero(lpi->pr.pe))
>  		return 0;
> 
> -	ret = lpi->pr.read_pages(&lpi->pr, addr, 1, buf);
> +	ret = lpi->pr.read_pages(&lpi->pr, addr, 1, dest);
>  	pr_debug("read_pages ret %d\n", ret);
>  	if (ret <= 0)
>  		return ret;
> 
> -	memcpy(dest, buf, PAGE_SIZE);
> -
>  	return 1;
>  }
> 
> -- 
> 2.5.0
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
>