public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH][RESEND] Allocate userspace memory for older userspace (v2)
Date: Thu, 18 Oct 2007 16:36:23 +0200	[thread overview]
Message-ID: <47176F67.9000200@qumranet.com> (raw)
In-Reply-To: <1192716331182-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

dAnthony Liguori wrote:
> Allocate a userspace buffer for older userspaces.  Also eliminate phys_mem
> buffer.  The memset() in kvmctl really kills initial memory usage but swapping
> does even with old userspaces.
>
> Since v1, fixed a bug in slot creation.
>
> I send the previous patch in response to a mail instead of top level so I'm
> resending properly.
>
>   


This is really nice, especially the diffstat.

> Signed-off-by: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> @@ -745,29 +727,27 @@ static int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,
>  	r = -ENOMEM;
>  
>  	/* Allocate if a slot is being created */
> -	if (npages && !new.phys_mem) {
> -		new.phys_mem = vmalloc(npages * sizeof(struct page *));
> -
> -		if (!new.phys_mem)
> -			goto out_unlock;
> -
> +	if (npages && !new.rmap) {
>  		new.rmap = vmalloc(npages * sizeof(struct page *));
>  
>  		if (!new.rmap)
>  			goto out_unlock;
>  
> -		memset(new.phys_mem, 0, npages * sizeof(struct page *));
>  		memset(new.rmap, 0, npages * sizeof(*new.rmap));
> -		if (user_alloc) {
> -			new.user_alloc = 1;
> +
> +		if (user_alloc)
>  			new.userspace_addr = mem->userspace_addr;
> -		} else {
> -			for (i = 0; i < npages; ++i) {
> -				new.phys_mem[i] = alloc_page(GFP_HIGHUSER
> -							     | __GFP_ZERO);
> -				if (!new.phys_mem[i])
> -					goto out_unlock;
> -			}
> +		else {
> +			down_write(&current->mm->mmap_sem);
> +			new.userspace_addr = do_mmap(NULL, 0,
> +						     npages * PAGE_SIZE,
> +						     PROT_READ | PROT_WRITE,
> +						     MAP_SHARED | MAP_ANONYMOUS,
> +						     0);
> +			up_write(&current->mm->mmap_sem);
> +
> +			if (new.userspace_addr > -1024UL)
>   

Surely there's some macro to test for this type of error return?  Also 
we may want to return the do_mmap() error code here (not sure).

> +				goto out_unlock;
>  		}
>  	}
>   


-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

  parent reply	other threads:[~2007-10-18 14:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-18 14:05 [PATCH][RESEND] Allocate userspace memory for older userspace (v2) Anthony Liguori
     [not found] ` <1192716331182-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-10-18 14:36   ` Avi Kivity [this message]
     [not found]     ` <47176F67.9000200-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-18 15:02       ` Anthony Liguori
     [not found]         ` <47177578.8010807-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-10-18 15:41           ` Avi Kivity
2007-10-18 14:56   ` Izik Eidus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47176F67.9000200@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox