lkml.org 
[lkml]   [2009]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v2 03/19] vbus: add connection-client helper infrastructure
On Thu, Apr 09, 2009 at 12:30:57PM -0400, Gregory Haskins wrote:
> +static unsigned long
> +task_memctx_copy_to(struct vbus_memctx *ctx, void *dst, const void *src,
> + unsigned long n)
> +{
> + struct task_memctx *tm = to_task_memctx(ctx);
> + struct task_struct *p = tm->task;
> +
> + while (n) {
> + unsigned long offset = ((unsigned long)dst)%PAGE_SIZE;
> + unsigned long len = PAGE_SIZE - offset;
> + int ret;
> + struct page *pg;
> + void *maddr;
> +
> + if (len > n)
> + len = n;
> +
> + down_read(&p->mm->mmap_sem);
> + ret = get_user_pages(p, p->mm,
> + (unsigned long)dst, 1, 1, 0, &pg, NULL);
> +
> + if (ret != 1) {
> + up_read(&p->mm->mmap_sem);
> + break;
> + }
> +
> + maddr = kmap_atomic(pg, KM_USER0);
> + memcpy(maddr + offset, src, len);
> + kunmap_atomic(maddr, KM_USER0);
> + set_page_dirty_lock(pg);
> + put_page(pg);
> + up_read(&p->mm->mmap_sem);
> +
> + src += len;
> + dst += len;
> + n -= len;
> + }
> +
> + return n;
> +}

BTW, why did you decide to use get_user_pages?
Would switch_mm + copy_to_user work as well
avoiding page walk if all pages are present?

Also - if we just had vmexit because a process executed
io (or hypercall), can't we just do copy_to_user there?
Avi, I think at some point you said that we can?


--
MST


\
 
 \ /
  Last update: 2009-06-04 20:11    [W:0.152 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site