mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Avi Kivity <avi@redhat.com>
Cc: Sheng Yang <sheng@linux.intel.com>,
	kvm@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 0/2] module_refcounting and anonymous inodes
Date: Tue, 9 Dec 2008 11:08:39 +0100	[thread overview]
Message-ID: <200812091108.39145.borntraeger@de.ibm.com> (raw)
In-Reply-To: <493E3F8B.7070603@redhat.com>

Am Dienstag, 9. Dezember 2008 schrieb Avi Kivity:
> Sheng Yang wrote:
> > Should we push the first patch to 2.6.28? 
> 
> It's not a recent regression, so no.
> 
> > I got some trouble with the separate 
> > 2nd patch, for I am using Linus' tree and make KVM as modules, so the 
> > reference count reduced to negative now... (Oh Avi, I know you suggest to 
use 
> > in kernel rather than modules, but module is indeed convenient. :) )
> >   
> 
> Right, that would affect everyone.  What we need is to hack the second 
> patch for external modules on <2.6.29.

Oh this is tricky. Both patches belong together, patch 2 depends on patch 1.
For base kernels which do not contain patch1, this additional (untested) patch 
would probably help:

---
 virt/kvm/kvm_main.c |   21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

Index: kvm/virt/kvm/kvm_main.c
===================================================================
--- kvm.orig/virt/kvm/kvm_main.c
+++ kvm/virt/kvm/kvm_main.c
@@ -1501,9 +1501,15 @@ static struct file_operations kvm_vcpu_f
  */
 static int create_vcpu_fd(struct kvm_vcpu *vcpu)
 {
-	int fd = anon_inode_getfd("kvm-vcpu", &kvm_vcpu_fops, vcpu, 0);
-	if (fd < 0)
+	int fd;
+
+	if (!try_module_get(kvm_vcpu_fops.owner))
+		return -ENOENT;
+	fd = anon_inode_getfd("kvm-vcpu", &kvm_vcpu_fops, vcpu, 0);
+	if (fd < 0) {
 		kvm_put_kvm(vcpu->kvm);
+		module_put(kvm_vcpu_fops.owner);
+	}
 	return fd;
 }
 
@@ -1895,12 +1901,19 @@ static int kvm_dev_ioctl_create_vm(void)
 	int fd;
 	struct kvm *kvm;
 
+	if (!try_module_get(kvm_vm_fops.owner))
+		return -ENOENT;
+
 	kvm = kvm_create_vm();
-	if (IS_ERR(kvm))
+	if (IS_ERR(kvm)) {
+		module_put(kvm_vm_fops.owner);
 		return PTR_ERR(kvm);
+	}
 	fd = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm, 0);
-	if (fd < 0)
+	if (fd < 0) {
 		kvm_put_kvm(kvm);
+		module_put(kvm_vm_fops.owner);
+	}
 
 	return fd;
 }


The problem is, how do you detect if the base kernel has patch1 applied?

Christian

  reply	other threads:[~2008-12-09 10:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-02 10:14 Christian Borntraeger
2008-12-02 10:16 ` [PATCH 1/2] anon_inodes: use fops->owner for module refcount Christian Borntraeger
2008-12-02 10:17 ` [PATCH 2/2] kvm: set owner of cpu and vm file operations Christian Borntraeger
2008-12-08 11:51 ` [PATCH 0/2] module_refcounting and anonymous inodes Christian Borntraeger
2008-12-08 11:57   ` Avi Kivity
2008-12-09  9:43     ` Sheng Yang
2008-12-09  9:51       ` Avi Kivity
2008-12-09 10:08         ` Christian Borntraeger [this message]
2008-12-09 10:15           ` Avi Kivity
2008-12-09 13:22             ` Avi Kivity
2008-12-10  2:05               ` Sheng Yang
2008-12-10  9:12                 ` Avi Kivity

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=200812091108.39145.borntraeger@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sheng@linux.intel.com \
    /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

Powered by JetHome