From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Avi Kivity <avi@argo.co.il>
Cc: kvm-devel <kvm@vger.kernel.org>,
Anthony Liguori <aliguori@us.ibm.com>,
Dave Hansen <dave@linux.vnet.ibm.com>
Subject: [PATCH 3/4] reduce stack usage in kvm_arch_vcpu_ioctl()
Date: Mon, 28 Jul 2008 11:15:09 -0700 [thread overview]
Message-ID: <1217268909-13398-1-git-send-email-dave@linux.vnet.ibm.com> (raw)
This time it is kvm_arch_vcpu_ioctl(). Use dynamic
allocations to reduce its stack usage.
Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
---
arch/x86/kvm/x86.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c8f94ae..0443189 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1302,13 +1302,16 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
struct kvm_vcpu *vcpu = filp->private_data;
void __user *argp = (void __user *)arg;
int r;
+ struct kvm_lapic_state *lapic = NULL;
switch (ioctl) {
case KVM_GET_LAPIC: {
- struct kvm_lapic_state lapic;
+ lapic = kzalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);
- memset(&lapic, 0, sizeof lapic);
- r = kvm_vcpu_ioctl_get_lapic(vcpu, &lapic);
+ r = -ENOMEM;
+ if (!lapic)
+ goto out;
+ r = kvm_vcpu_ioctl_get_lapic(vcpu, lapic);
if (r)
goto out;
r = -EFAULT;
@@ -1318,12 +1321,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
break;
}
case KVM_SET_LAPIC: {
- struct kvm_lapic_state lapic;
-
+ lapic = kmalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);
+ r = -ENOMEM;
+ if (!lapic)
+ goto out;
r = -EFAULT;
- if (copy_from_user(&lapic, argp, sizeof lapic))
+ if (copy_from_user(lapic, argp, sizeof(struct kvm_lapic_state)))
goto out;
- r = kvm_vcpu_ioctl_set_lapic(vcpu, &lapic);;
+ r = kvm_vcpu_ioctl_set_lapic(vcpu, lapic);
if (r)
goto out;
r = 0;
@@ -1421,6 +1426,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
r = -EINVAL;
}
out:
+ kfree(lapic);
return r;
}
--
1.5.4.3
next reply other threads:[~2008-07-28 18:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-28 18:15 Dave Hansen [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-08-04 18:31 [PATCH 1/4] reduce kvm stack usage in kvm_arch_vm_ioctl() Dave Hansen
2008-08-04 18:31 ` [PATCH 3/4] reduce stack usage in kvm_arch_vcpu_ioctl() Dave Hansen
2008-08-11 17:01 [PATCH 1/4] reduce kvm stack usage in kvm_arch_vm_ioctl() Dave Hansen
2008-08-11 17:01 ` [PATCH 3/4] reduce stack usage in kvm_arch_vcpu_ioctl() Dave Hansen
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=1217268909-13398-1-git-send-email-dave@linux.vnet.ibm.com \
--to=dave@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=avi@argo.co.il \
--cc=kvm@vger.kernel.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