All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: PPC: Allocate vcpu struct using vmalloc
@ 2010-02-19 11:24 ` Alexander Graf
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2010-02-19 11:24 UTC (permalink / raw)
  To: kvm-ppc; +Cc: kvm list

We used to use get_free_pages to allocate our vcpu struct. Unfortunately
that call failed on me several times after my machine had a big enough
uptime, as memory became too fragmented by then.

Fortunately, we don't need it to be page aligned any more! We can just
vmalloc it and everything's great.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/powerpc/kvm/book3s.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index f842d1d..794c94b 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -1110,8 +1110,7 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
 	struct kvm_vcpu *vcpu;
 	int err;
 
-	vcpu_book3s = (struct kvmppc_vcpu_book3s *)__get_free_pages( GFP_KERNEL | __GFP_ZERO,
-			get_order(sizeof(struct kvmppc_vcpu_book3s)));
+	vcpu_book3s = vmalloc(sizeof(struct kvmppc_vcpu_book3s));
 	if (!vcpu_book3s) {
 		err = -ENOMEM;
 		goto out;
@@ -1149,7 +1148,7 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
 	return vcpu;
 
 free_vcpu:
-	free_pages((long)vcpu_book3s, get_order(sizeof(struct kvmppc_vcpu_book3s)));
+	vfree(vcpu_book3s);
 out:
 	return ERR_PTR(err);
 }
@@ -1160,7 +1159,7 @@ void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu)
 
 	__destroy_context(vcpu_book3s->context_id);
 	kvm_vcpu_uninit(vcpu);
-	free_pages((long)vcpu_book3s, get_order(sizeof(struct kvmppc_vcpu_book3s)));
+	vfree(vcpu_book3s);
 }
 
 extern int __kvmppc_vcpu_entry(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
-- 
1.6.0.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] KVM: PPC: Allocate vcpu struct using vmalloc
@ 2010-02-19 11:24 ` Alexander Graf
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2010-02-19 11:24 UTC (permalink / raw)
  To: kvm-ppc; +Cc: kvm list

We used to use get_free_pages to allocate our vcpu struct. Unfortunately
that call failed on me several times after my machine had a big enough
uptime, as memory became too fragmented by then.

Fortunately, we don't need it to be page aligned any more! We can just
vmalloc it and everything's great.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/powerpc/kvm/book3s.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index f842d1d..794c94b 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -1110,8 +1110,7 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
 	struct kvm_vcpu *vcpu;
 	int err;
 
-	vcpu_book3s = (struct kvmppc_vcpu_book3s *)__get_free_pages( GFP_KERNEL | __GFP_ZERO,
-			get_order(sizeof(struct kvmppc_vcpu_book3s)));
+	vcpu_book3s = vmalloc(sizeof(struct kvmppc_vcpu_book3s));
 	if (!vcpu_book3s) {
 		err = -ENOMEM;
 		goto out;
@@ -1149,7 +1148,7 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
 	return vcpu;
 
 free_vcpu:
-	free_pages((long)vcpu_book3s, get_order(sizeof(struct kvmppc_vcpu_book3s)));
+	vfree(vcpu_book3s);
 out:
 	return ERR_PTR(err);
 }
@@ -1160,7 +1159,7 @@ void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu)
 
 	__destroy_context(vcpu_book3s->context_id);
 	kvm_vcpu_uninit(vcpu);
-	free_pages((long)vcpu_book3s, get_order(sizeof(struct kvmppc_vcpu_book3s)));
+	vfree(vcpu_book3s);
 }
 
 extern int __kvmppc_vcpu_entry(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
-- 
1.6.0.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: PPC: Allocate vcpu struct using vmalloc
       [not found] ` <1266578673-32254-1-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org>
@ 2010-02-21 12:29     ` Avi Kivity
  0 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2010-02-21 12:29 UTC (permalink / raw)
  To: Alexander Graf; +Cc: kvm-ppc-u79uwXL29TY76Z2rM5mHXA, kvm list

On 02/19/2010 01:24 PM, Alexander Graf wrote:
> We used to use get_free_pages to allocate our vcpu struct. Unfortunately
> that call failed on me several times after my machine had a big enough
> uptime, as memory became too fragmented by then.
>
> Fortunately, we don't need it to be page aligned any more! We can just
> vmalloc it and everything's great.
>    

Applied, thanks.

We have the same problem in x86 (though never observed it in practice); 
my plan there is to split the various structure so they take less than a 
page.

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: PPC: Allocate vcpu struct using vmalloc
@ 2010-02-21 12:29     ` Avi Kivity
  0 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2010-02-21 12:29 UTC (permalink / raw)
  To: Alexander Graf; +Cc: kvm-ppc-u79uwXL29TY76Z2rM5mHXA, kvm list

On 02/19/2010 01:24 PM, Alexander Graf wrote:
> We used to use get_free_pages to allocate our vcpu struct. Unfortunately
> that call failed on me several times after my machine had a big enough
> uptime, as memory became too fragmented by then.
>
> Fortunately, we don't need it to be page aligned any more! We can just
> vmalloc it and everything's great.
>    

Applied, thanks.

We have the same problem in x86 (though never observed it in practice); 
my plan there is to split the various structure so they take less than a 
page.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: PPC: Allocate vcpu struct using vmalloc
  2010-02-19 11:24 ` Alexander Graf
  (?)
  (?)
@ 2010-02-21 14:50 ` Alexander Graf
  -1 siblings, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2010-02-21 14:50 UTC (permalink / raw)
  To: kvm-ppc


On 21.02.2010, at 13:29, Avi Kivity wrote:

> On 02/19/2010 01:24 PM, Alexander Graf wrote:
>> We used to use get_free_pages to allocate our vcpu struct. Unfortunately
>> that call failed on me several times after my machine had a big enough
>> uptime, as memory became too fragmented by then.
>> 
>> Fortunately, we don't need it to be page aligned any more! We can just
>> vmalloc it and everything's great.
>>   
> 
> Applied, thanks.
> 
> We have the same problem in x86 (though never observed it in practice); my plan there is to split the various structure so they take less than a page.

That was my original idea too, but then I looked over the code again and realized that I never need to access the vcpu struct from critical sections, as we moved everything we need there to the PACA.

I also did experience it several times on PPC. But then again, I'm fairly sure the Book3S vcpu struct is a _lot_ larger than the average x86 vcpu struct ;-). I'd need to actually measure it up, but I'm pretty sure it's > 64k.

Alex

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: PPC: Allocate vcpu struct using vmalloc
  2010-02-19 11:24 ` Alexander Graf
                   ` (2 preceding siblings ...)
  (?)
@ 2010-02-21 15:08 ` Avi Kivity
  -1 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2010-02-21 15:08 UTC (permalink / raw)
  To: kvm-ppc

On 02/21/2010 04:50 PM, Alexander Graf wrote:
> On 21.02.2010, at 13:29, Avi Kivity wrote:
>
>    
>> On 02/19/2010 01:24 PM, Alexander Graf wrote:
>>      
>>> We used to use get_free_pages to allocate our vcpu struct. Unfortunately
>>> that call failed on me several times after my machine had a big enough
>>> uptime, as memory became too fragmented by then.
>>>
>>> Fortunately, we don't need it to be page aligned any more! We can just
>>> vmalloc it and everything's great.
>>>
>>>        
>> Applied, thanks.
>>
>> We have the same problem in x86 (though never observed it in practice); my plan there is to split the various structure so they take less than a page.
>>      
> That was my original idea too, but then I looked over the code again and realized that I never need to access the vcpu struct from critical sections, as we moved everything we need there to the PACA.
>
> I also did experience it several times on PPC. But then again, I'm fairly sure the Book3S vcpu struct is a _lot_ larger than the average x86 vcpu struct ;-). I'd need to actually measure it up, but I'm pretty sure it's>  64k.
>    

Right, x86 is around 8k, which is the thread stack size, and if we can't 
allocate that we're really dead.

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-02-21 15:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-19 11:24 [PATCH] KVM: PPC: Allocate vcpu struct using vmalloc Alexander Graf
2010-02-19 11:24 ` Alexander Graf
     [not found] ` <1266578673-32254-1-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org>
2010-02-21 12:29   ` Avi Kivity
2010-02-21 12:29     ` Avi Kivity
2010-02-21 14:50 ` Alexander Graf
2010-02-21 15:08 ` Avi Kivity

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.