[03/11] pagemap: Enqueue iovec to some list

Submitted by Pavel Emelianov on May 5, 2017, 4:02 p.m.

Details

Message ID 1a7e9868-2e87-421f-1b00-db03eeca7eec@virtuozzo.com
State New
Series "Do not remap vmas when not needed"
Headers show

Commit Message

Pavel Emelianov May 5, 2017, 4:02 p.m.
We currently can batch pagemap entries into page-read list, but will
need to queue them into per-pstree_entry one.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/include/pagemap.h |  3 +++
 criu/pagemap.c         | 19 ++++++++++---------
 2 files changed, 13 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/include/pagemap.h b/criu/include/pagemap.h
index b23ec3a..aa3c4aa 100644
--- a/criu/include/pagemap.h
+++ b/criu/include/pagemap.h
@@ -104,6 +104,9 @@  extern int open_page_read(int pid, struct page_read *, int pr_flags);
 extern int open_page_read_at(int dfd, int pid, struct page_read *pr,
 		int pr_flags);
 
+int pagemap_enqueue_iovec(struct page_read *pr, void *buf,
+			      unsigned long len, struct list_head *to);
+
 /*
  * Create a shallow copy of page_read object.
  * The new object shares the pagemap structures with the original, but
diff --git a/criu/pagemap.c b/criu/pagemap.c
index 2cf91e3..dcc1332 100644
--- a/criu/pagemap.c
+++ b/criu/pagemap.c
@@ -279,7 +279,8 @@  static int read_local_page(struct page_read *pr, unsigned long vaddr,
 	return 0;
 }
 
-static int enqueue_async_iov(struct page_read *pr, unsigned long len, void *buf)
+static int enqueue_async_iov(struct page_read *pr, void *buf,
+		unsigned long len, struct list_head *to)
 {
 	struct page_read_iov *pr_iov;
 	struct iovec *iov;
@@ -303,19 +304,19 @@  static int enqueue_async_iov(struct page_read *pr, unsigned long len, void *buf)
 	pr_iov->to = iov;
 	pr_iov->nr = 1;
 
-	list_add_tail(&pr_iov->l, &pr->async);
+	list_add_tail(&pr_iov->l, to);
 
 	return 0;
 }
 
-static int enqueue_async_page(struct page_read *pr, unsigned long vaddr,
-			      unsigned long len, void *buf)
+int pagemap_enqueue_iovec(struct page_read *pr, void *buf,
+			      unsigned long len, struct list_head *to)
 {
 	struct page_read_iov *cur_async = NULL;
 	struct iovec *iov;
 
-	if (!list_empty(&pr->async))
-		cur_async = list_entry(pr->async.prev, struct page_read_iov, l);
+	if (!list_empty(to))
+		cur_async = list_entry(to->prev, struct page_read_iov, l);
 
 	/*
 	 * We don't have any async requests or we have new read
@@ -324,7 +325,7 @@  static int enqueue_async_page(struct page_read *pr, unsigned long vaddr,
 	 * Start the new preadv request here.
 	 */
 	if (!cur_async || pr->pi_off != cur_async->end)
-		return enqueue_async_iov(pr, len, buf);
+		return enqueue_async_iov(pr, buf, len, to);
 
 	/*
 	 * This read is pure continuation of the previous one. Let's
@@ -339,7 +340,7 @@  static int enqueue_async_page(struct page_read *pr, unsigned long vaddr,
 		unsigned int n_iovs = cur_async->nr + 1;
 
 		if (n_iovs >= IOV_MAX)
-			return enqueue_async_iov(pr, len, buf);
+			return enqueue_async_iov(pr, buf, len, to);
 
 		iov = xrealloc(cur_async->to, n_iovs * sizeof(*iov));
 		if (!iov)
@@ -372,7 +373,7 @@  static int maybe_read_page_local(struct page_read *pr, unsigned long vaddr,
 	 * cached read.
 	 */
 	if ((flags & (PR_ASYNC|PR_ASAP)) == PR_ASYNC && !opts.remote)
-		ret = enqueue_async_page(pr, vaddr, len, buf);
+		ret = pagemap_enqueue_iovec(pr, buf, len, &pr->async);
 	else {
 		ret = read_local_page(pr, vaddr, len, buf);
 		if (ret == 0 && pr->io_complete)

Comments

Mike Rapoport May 7, 2017, 10:49 a.m.
On Fri, May 05, 2017 at 07:02:15PM +0300, Pavel Emelyanov wrote:
> pagemap: Enqueue iovec to some list

Maybe "pagemap: allow to enqueue iovec to arbitrary list"?

> We currently can batch pagemap entries into page-read list, but will
> need to queue them into per-pstree_entry one.
> 
> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
> ---
>  criu/include/pagemap.h |  3 +++
>  criu/pagemap.c         | 19 ++++++++++---------
>  2 files changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/criu/include/pagemap.h b/criu/include/pagemap.h
> index b23ec3a..aa3c4aa 100644
> --- a/criu/include/pagemap.h
> +++ b/criu/include/pagemap.h
> @@ -104,6 +104,9 @@ extern int open_page_read(int pid, struct page_read *, int pr_flags);
>  extern int open_page_read_at(int dfd, int pid, struct page_read *pr,
>  		int pr_flags);
> 
> +int pagemap_enqueue_iovec(struct page_read *pr, void *buf,
> +			      unsigned long len, struct list_head *to);
> +
>  /*
>   * Create a shallow copy of page_read object.
>   * The new object shares the pagemap structures with the original, but
> diff --git a/criu/pagemap.c b/criu/pagemap.c
> index 2cf91e3..dcc1332 100644
> --- a/criu/pagemap.c
> +++ b/criu/pagemap.c
> @@ -279,7 +279,8 @@ static int read_local_page(struct page_read *pr, unsigned long vaddr,
>  	return 0;
>  }
> 
> -static int enqueue_async_iov(struct page_read *pr, unsigned long len, void *buf)
> +static int enqueue_async_iov(struct page_read *pr, void *buf,
> +		unsigned long len, struct list_head *to)
>  {
>  	struct page_read_iov *pr_iov;
>  	struct iovec *iov;
> @@ -303,19 +304,19 @@ static int enqueue_async_iov(struct page_read *pr, unsigned long len, void *buf)
>  	pr_iov->to = iov;
>  	pr_iov->nr = 1;
> 
> -	list_add_tail(&pr_iov->l, &pr->async);
> +	list_add_tail(&pr_iov->l, to);
> 
>  	return 0;
>  }
> 
> -static int enqueue_async_page(struct page_read *pr, unsigned long vaddr,
> -			      unsigned long len, void *buf)
> +int pagemap_enqueue_iovec(struct page_read *pr, void *buf,
> +			      unsigned long len, struct list_head *to)
>  {
>  	struct page_read_iov *cur_async = NULL;
>  	struct iovec *iov;
> 
> -	if (!list_empty(&pr->async))
> -		cur_async = list_entry(pr->async.prev, struct page_read_iov, l);
> +	if (!list_empty(to))
> +		cur_async = list_entry(to->prev, struct page_read_iov, l);
> 
>  	/*
>  	 * We don't have any async requests or we have new read
> @@ -324,7 +325,7 @@ static int enqueue_async_page(struct page_read *pr, unsigned long vaddr,
>  	 * Start the new preadv request here.
>  	 */
>  	if (!cur_async || pr->pi_off != cur_async->end)
> -		return enqueue_async_iov(pr, len, buf);
> +		return enqueue_async_iov(pr, buf, len, to);
> 
>  	/*
>  	 * This read is pure continuation of the previous one. Let's
> @@ -339,7 +340,7 @@ static int enqueue_async_page(struct page_read *pr, unsigned long vaddr,
>  		unsigned int n_iovs = cur_async->nr + 1;
> 
>  		if (n_iovs >= IOV_MAX)
> -			return enqueue_async_iov(pr, len, buf);
> +			return enqueue_async_iov(pr, buf, len, to);
> 
>  		iov = xrealloc(cur_async->to, n_iovs * sizeof(*iov));
>  		if (!iov)
> @@ -372,7 +373,7 @@ static int maybe_read_page_local(struct page_read *pr, unsigned long vaddr,
>  	 * cached read.
>  	 */
>  	if ((flags & (PR_ASYNC|PR_ASAP)) == PR_ASYNC && !opts.remote)
> -		ret = enqueue_async_page(pr, vaddr, len, buf);
> +		ret = pagemap_enqueue_iovec(pr, buf, len, &pr->async);
>  	else {
>  		ret = read_local_page(pr, vaddr, len, buf);
>  		if (ret == 0 && pr->io_complete)
> -- 
> 2.5.5
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
>
Pavel Emelianov May 10, 2017, 8:45 a.m.
On 05/07/2017 01:49 PM, Mike Rapoport wrote:
> 
> On Fri, May 05, 2017 at 07:02:15PM +0300, Pavel Emelyanov wrote:
>> pagemap: Enqueue iovec to some list
> 
> Maybe "pagemap: allow to enqueue iovec to arbitrary list"?

Yup, makes sense, thanks.

>> We currently can batch pagemap entries into page-read list, but will
>> need to queue them into per-pstree_entry one.
>>
>> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
>> ---
>>  criu/include/pagemap.h |  3 +++
>>  criu/pagemap.c         | 19 ++++++++++---------
>>  2 files changed, 13 insertions(+), 9 deletions(-)
>>
>> diff --git a/criu/include/pagemap.h b/criu/include/pagemap.h
>> index b23ec3a..aa3c4aa 100644
>> --- a/criu/include/pagemap.h
>> +++ b/criu/include/pagemap.h
>> @@ -104,6 +104,9 @@ extern int open_page_read(int pid, struct page_read *, int pr_flags);
>>  extern int open_page_read_at(int dfd, int pid, struct page_read *pr,
>>  		int pr_flags);
>>
>> +int pagemap_enqueue_iovec(struct page_read *pr, void *buf,
>> +			      unsigned long len, struct list_head *to);
>> +
>>  /*
>>   * Create a shallow copy of page_read object.
>>   * The new object shares the pagemap structures with the original, but
>> diff --git a/criu/pagemap.c b/criu/pagemap.c
>> index 2cf91e3..dcc1332 100644
>> --- a/criu/pagemap.c
>> +++ b/criu/pagemap.c
>> @@ -279,7 +279,8 @@ static int read_local_page(struct page_read *pr, unsigned long vaddr,
>>  	return 0;
>>  }
>>
>> -static int enqueue_async_iov(struct page_read *pr, unsigned long len, void *buf)
>> +static int enqueue_async_iov(struct page_read *pr, void *buf,
>> +		unsigned long len, struct list_head *to)
>>  {
>>  	struct page_read_iov *pr_iov;
>>  	struct iovec *iov;
>> @@ -303,19 +304,19 @@ static int enqueue_async_iov(struct page_read *pr, unsigned long len, void *buf)
>>  	pr_iov->to = iov;
>>  	pr_iov->nr = 1;
>>
>> -	list_add_tail(&pr_iov->l, &pr->async);
>> +	list_add_tail(&pr_iov->l, to);
>>
>>  	return 0;
>>  }
>>
>> -static int enqueue_async_page(struct page_read *pr, unsigned long vaddr,
>> -			      unsigned long len, void *buf)
>> +int pagemap_enqueue_iovec(struct page_read *pr, void *buf,
>> +			      unsigned long len, struct list_head *to)
>>  {
>>  	struct page_read_iov *cur_async = NULL;
>>  	struct iovec *iov;
>>
>> -	if (!list_empty(&pr->async))
>> -		cur_async = list_entry(pr->async.prev, struct page_read_iov, l);
>> +	if (!list_empty(to))
>> +		cur_async = list_entry(to->prev, struct page_read_iov, l);
>>
>>  	/*
>>  	 * We don't have any async requests or we have new read
>> @@ -324,7 +325,7 @@ static int enqueue_async_page(struct page_read *pr, unsigned long vaddr,
>>  	 * Start the new preadv request here.
>>  	 */
>>  	if (!cur_async || pr->pi_off != cur_async->end)
>> -		return enqueue_async_iov(pr, len, buf);
>> +		return enqueue_async_iov(pr, buf, len, to);
>>
>>  	/*
>>  	 * This read is pure continuation of the previous one. Let's
>> @@ -339,7 +340,7 @@ static int enqueue_async_page(struct page_read *pr, unsigned long vaddr,
>>  		unsigned int n_iovs = cur_async->nr + 1;
>>
>>  		if (n_iovs >= IOV_MAX)
>> -			return enqueue_async_iov(pr, len, buf);
>> +			return enqueue_async_iov(pr, buf, len, to);
>>
>>  		iov = xrealloc(cur_async->to, n_iovs * sizeof(*iov));
>>  		if (!iov)
>> @@ -372,7 +373,7 @@ static int maybe_read_page_local(struct page_read *pr, unsigned long vaddr,
>>  	 * cached read.
>>  	 */
>>  	if ((flags & (PR_ASYNC|PR_ASAP)) == PR_ASYNC && !opts.remote)
>> -		ret = enqueue_async_page(pr, vaddr, len, buf);
>> +		ret = pagemap_enqueue_iovec(pr, buf, len, &pr->async);
>>  	else {
>>  		ret = read_local_page(pr, vaddr, len, buf);
>>  		if (ret == 0 && pr->io_complete)
>> -- 
>> 2.5.5
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU@openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
>>
> 
> .
>