From: Tejun Heo <tj@kernel.org>
To: linux-kernel@vger.kernel.org, jeff@garzik.org, mingo@elte.hu,
akpm@linux-foundation.org, jens.axboe@oracle.com,
rusty@rustcorp.com.au, cl@linux-foundation.org,
dhowells@redhat.com, arjan@linux.intel.com,
torvalds@linux-foundation.org, avi@redhat.com,
peterz@infradead.org, andi@firstfloor.org, fweisbec@gmail.com
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 05/21] kvm: convert kvm to use new scheduler notifiers
Date: Tue, 17 Nov 2009 02:15:10 +0900 [thread overview]
Message-ID: <1258391726-30264-6-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1258391726-30264-1-git-send-email-tj@kernel.org>
Convert kvm to use new scheduler notifiers instead of preempt
notifiers.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Avi Kivity <avi@redhat.com>
---
include/linux/kvm_host.h | 5 +--
virt/kvm/kvm_main.c | 51 +++++++++++++++++++--------------------------
2 files changed, 24 insertions(+), 32 deletions(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index b7bbb5d..b6e56f1 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -74,9 +74,8 @@ void kvm_io_bus_unregister_dev(struct kvm *kvm, struct kvm_io_bus *bus,
struct kvm_vcpu {
struct kvm *kvm;
-#ifdef CONFIG_PREEMPT_NOTIFIERS
- struct preempt_notifier preempt_notifier;
-#endif
+ struct sched_notifier sched_in_notifier;
+ struct sched_notifier sched_out_notifier;
int vcpu_id;
struct mutex mutex;
int cpu;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 7495ce3..4cc8051 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -79,8 +79,6 @@ static cpumask_var_t cpus_hardware_enabled;
struct kmem_cache *kvm_vcpu_cache;
EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
-static __read_mostly struct preempt_ops kvm_preempt_ops;
-
struct dentry *kvm_debugfs_dir;
static long kvm_vcpu_ioctl(struct file *file, unsigned int ioctl,
@@ -713,7 +711,8 @@ void vcpu_load(struct kvm_vcpu *vcpu)
mutex_lock(&vcpu->mutex);
cpu = get_cpu();
- preempt_notifier_register(&vcpu->preempt_notifier);
+ sched_notifier_register(SCHED_NOTIFIER_IN, &vcpu->sched_in_notifier);
+ sched_notifier_register(SCHED_NOTIFIER_OUT, &vcpu->sched_out_notifier);
kvm_arch_vcpu_load(vcpu, cpu);
put_cpu();
}
@@ -722,11 +721,28 @@ void vcpu_put(struct kvm_vcpu *vcpu)
{
preempt_disable();
kvm_arch_vcpu_put(vcpu);
- preempt_notifier_unregister(&vcpu->preempt_notifier);
+ sched_notifier_unregister(&vcpu->sched_in_notifier);
+ sched_notifier_unregister(&vcpu->sched_out_notifier);
preempt_enable();
mutex_unlock(&vcpu->mutex);
}
+static void kvm_sched_in(struct sched_notifier *sn, struct task_struct *prev)
+{
+ struct kvm_vcpu *vcpu =
+ container_of(sn, struct kvm_vcpu, sched_in_notifier);
+
+ kvm_arch_vcpu_load(vcpu, smp_processor_id());
+}
+
+static void kvm_sched_out(struct sched_notifier *sn, struct task_struct *next)
+{
+ struct kvm_vcpu *vcpu =
+ container_of(sn, struct kvm_vcpu, sched_out_notifier);
+
+ kvm_arch_vcpu_put(vcpu);
+}
+
static void ack_flush(void *_completed)
{
}
@@ -1772,7 +1788,8 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
if (IS_ERR(vcpu))
return PTR_ERR(vcpu);
- preempt_notifier_init(&vcpu->preempt_notifier, &kvm_preempt_ops);
+ vcpu->sched_in_notifier.in = kvm_sched_in;
+ vcpu->sched_out_notifier.out = kvm_sched_out;
r = kvm_arch_vcpu_setup(vcpu);
if (r)
@@ -2690,27 +2707,6 @@ static struct sys_device kvm_sysdev = {
struct page *bad_page;
pfn_t bad_pfn;
-static inline
-struct kvm_vcpu *preempt_notifier_to_vcpu(struct preempt_notifier *pn)
-{
- return container_of(pn, struct kvm_vcpu, preempt_notifier);
-}
-
-static void kvm_sched_in(struct preempt_notifier *pn, int cpu)
-{
- struct kvm_vcpu *vcpu = preempt_notifier_to_vcpu(pn);
-
- kvm_arch_vcpu_load(vcpu, cpu);
-}
-
-static void kvm_sched_out(struct preempt_notifier *pn,
- struct task_struct *next)
-{
- struct kvm_vcpu *vcpu = preempt_notifier_to_vcpu(pn);
-
- kvm_arch_vcpu_put(vcpu);
-}
-
int kvm_init(void *opaque, unsigned int vcpu_size,
struct module *module)
{
@@ -2780,9 +2776,6 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
goto out_free;
}
- kvm_preempt_ops.sched_in = kvm_sched_in;
- kvm_preempt_ops.sched_out = kvm_sched_out;
-
kvm_init_debug();
return 0;
--
1.6.4.2
next prev parent reply other threads:[~2009-11-16 17:19 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-16 17:15 [PATCHSET] workqueue: prepare for concurrency managed workqueue Tejun Heo
2009-11-16 17:15 ` [PATCH 01/21] workqueue: fix race condition in schedule_on_each_cpu() Tejun Heo
2009-11-16 23:04 ` Frederic Weisbecker
2009-11-17 0:08 ` Tejun Heo
2009-11-17 7:04 ` Avi Kivity
2009-11-17 16:16 ` Tejun Heo
2009-11-16 17:15 ` [PATCH 02/21] sched, kvm: fix race condition involving sched_in_preempt_notifers Tejun Heo
2009-11-16 17:15 ` [PATCH 03/21] workqueue: Add debugobjects support Tejun Heo
2009-11-16 17:15 ` [PATCH 04/21] sched: implement scheduler notifiers Tejun Heo
2009-11-16 18:31 ` Avi Kivity
2009-11-16 18:43 ` Tejun Heo
2009-11-16 18:41 ` Peter Zijlstra
2009-11-16 18:54 ` Tejun Heo
2009-11-16 20:29 ` Peter Zijlstra
2009-11-17 16:16 ` Tejun Heo
2009-11-16 17:15 ` Tejun Heo [this message]
2009-11-16 17:15 ` [PATCH 06/21] sched: drop preempt notifiers Tejun Heo
2009-11-16 17:15 ` [PATCH 07/21] sched: implement sched_notifier_wake_up_process() Tejun Heo
2009-11-16 17:15 ` [PATCH 08/21] scheduler: implement force_cpus_allowed_ptr() Tejun Heo
2009-11-17 5:14 ` Rusty Russell
2009-11-17 5:19 ` Tejun Heo
2009-11-16 17:15 ` [PATCH 09/21] acpi: use queue_work_on() instead of binding workqueue worker to cpu0 Tejun Heo
2009-11-16 17:15 ` [PATCH 10/21] stop_machine: reimplement without using workqueue Tejun Heo
2009-11-16 17:15 ` [PATCH 11/21] workqueue: misc/cosmetic updates Tejun Heo
2009-11-16 17:15 ` [PATCH 12/21] workqueue: merge feature parametesr into flags Tejun Heo
2009-11-16 17:15 ` [PATCH 13/21] workqueue: update cwq alignement and make one more flag bit available Tejun Heo
2009-11-16 17:15 ` [PATCH 14/21] workqueue: define both bit position and mask for work flags Tejun Heo
2009-11-16 17:15 ` [PATCH 15/21] workqueue: separate out process_one_work() Tejun Heo
2009-11-16 17:15 ` [PATCH 16/21] workqueue: temporarily disable workqueue tracing Tejun Heo
2009-11-16 17:15 ` [PATCH 17/21] workqueue: simple reimplementation of SINGLE_THREAD workqueue Tejun Heo
2009-11-17 0:47 ` Andy Walls
2009-11-17 5:23 ` Tejun Heo
2009-11-17 12:05 ` Andy Walls
2009-11-17 16:21 ` Tejun Heo
2009-11-17 16:26 ` Hi ... I want to introduce myself :) Setiajie 余鴻昌
2009-11-17 15:05 ` [PATCH 17/21] workqueue: simple reimplementation of SINGLE_THREAD workqueue Linus Torvalds
2009-11-17 16:12 ` Tejun Heo
2009-11-17 19:01 ` Linus Torvalds
2009-11-17 14:03 ` Johannes Berg
2009-11-17 16:24 ` Tejun Heo
2009-11-16 17:15 ` [PATCH 18/21] workqueue: reimplement workqueue flushing using color coded works Tejun Heo
2009-11-16 17:15 ` [PATCH 19/21] workqueue: introduce worker Tejun Heo
2009-11-17 11:39 ` Louis Rilling
2009-11-17 11:51 ` Louis Rilling
2009-11-17 16:25 ` Tejun Heo
2009-11-16 17:15 ` [PATCH 20/21] workqueue: reimplement work flushing using linked works Tejun Heo
2009-11-16 17:15 ` [PATCH 21/21] workqueue: reimplement workqueue freeze using cwq->frozen_works queue Tejun Heo
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=1258391726-30264-6-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=arjan@linux.intel.com \
--cc=avi@redhat.com \
--cc=cl@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=fweisbec@gmail.com \
--cc=jeff@garzik.org \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.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