Re: swapping with MMU Notifiers V2

Andrea Arcangeli
2008-01-31T18:56:29Z

On Thu, Jan 31, 2008 at 01:58:42PM +0100, Andrea Arcangeli wrote:
> It might also be something stale in the buildsystem (perhaps a distcc
> of ccache glitch?), I also cleared 1G of ccache just to be sure in

My build problem might have been related to the fact the
kvm-userland/kernel/include directory isn't used by the kernel build
system while building the external module. I did the kvm modifications
to the kvm.git, synching from kvm.git to kvm-userland.git and then
building the external module against a third tree that happen to have
the kvm_* headers too but slightly different. I thought the
kvm-userland/kernel/include directory was used but apparently it isn't
anymore because the way it gets priority is a bit fragile.

This seems to fix things but it's certainly not more robust, it just
happens to build and run fine so far. I hope there's a better way to
make it work ;)

Signed-off-by: Andrea Arcangeli <andrea-atKUWr5tajBWk0Htik3J/w@public.gmane.org>

diff --git a/kernel/external-module-compat.h b/kernel/external-module-compat.h
index 052d561..96f61d8 100644
--- a/kernel/external-module-compat.h
+++ b/kernel/external-module-compat.h
@@ -10,8 +10,62 @@
#include <linux/compiler.h>
#include <linux/version.h>
#include <linux/string.h>
-#include "include/linux/kvm.h"
+
+#ifndef CONFIG_PREEMPT_NOTIFIERS
+#include <linux/preempt.h>
+#define CONFIG_PREEMPT_NOTIFIERS
+#define CONFIG_PREEMPT_NOTIFIERS_COMPAT
+
+struct preempt_notifier;
+
+struct preempt_ops {
+ void (*sched_in)(struct preempt_notifier *notifier, int cpu);
+ void (*sched_out)(struct preempt_notifier *notifier,
+ struct task_struct *next);
+};
+
+struct preempt_notifier {
+ struct list_head link;
+ struct task_struct *tsk;
+ struct preempt_ops *ops;
+};
+
+void preempt_notifier_register(struct preempt_notifier *notifier);
+void preempt_notifier_unregister(struct preempt_notifier *notifier);
+
+static inline void preempt_notifier_init(struct preempt_notifier *notifier,
+ struct preempt_ops *ops)
+{
+ notifier->ops = ops;
+}
+
+void start_special_insn(void);
+void end_special_insn(void);
+void in_special_section(void);
+void special_reload_dr7(void);
+
+void preempt_notifier_sys_init(void);
+void preempt_notifier_sys_exit(void);
+
+#else
+
+static inline void start_special_insn(void) {}
+static inline void end_special_insn(void) {}
+static inline void in_special_section(void) {}
+static inline void special_reload_dr7(void) {}
+
+static inline void preempt_notifier_sys_init(void) {}
+static inline void preempt_notifier_sys_exit(void) {}
+
+#endif
+
+#include "include/asm/kvm_para.h"
+#include "include/asm/kvm.h"
+#include "include/linux/kvm_types.h"
#include "include/linux/kvm_para.h"
+#include "include/linux/kvm.h"
+#include "include/asm/kvm_host.h"
+#include "include/linux/kvm_host.h"
#include <linux/cpu.h>
#include <asm/processor.h>
#include <linux/hrtimer.h>
@@ -347,53 +401,6 @@ static inline unsigned long long __kvm_cmpxchg64(volatile void *ptr,

#endif

-#ifndef CONFIG_PREEMPT_NOTIFIERS
-#define CONFIG_PREEMPT_NOTIFIERS
-#define CONFIG_PREEMPT_NOTIFIERS_COMPAT
-
-struct preempt_notifier;
-
-struct preempt_ops {
- void (*sched_in)(struct preempt_notifier *notifier, int cpu);
- void (*sched_out)(struct preempt_notifier *notifier,
- struct task_struct *next);
-};
-
-struct preempt_notifier {
- struct list_head link;
- struct task_struct *tsk;
- struct preempt_ops *ops;
-};
-
-void preempt_notifier_register(struct preempt_notifier *notifier);
-void preempt_notifier_unregister(struct preempt_notifier *notifier);
-
-static inline void preempt_notifier_init(struct preempt_notifier *notifier,
- struct preempt_ops *ops)
-{
- notifier->ops = ops;
-}
-
-void start_special_insn(void);
-void end_special_insn(void);
-void in_special_section(void);
-void special_reload_dr7(void);
-
-void preempt_notifier_sys_init(void);
-void preempt_notifier_sys_exit(void);
-
-#else
-
-static inline void start_special_insn(void) {}
-static inline void end_special_insn(void) {}
-static inline void in_special_section(void) {}
-static inline void special_reload_dr7(void) {}
-
-static inline void preempt_notifier_sys_init(void) {}
-static inline void preempt_notifier_sys_exit(void) {}
-
-#endif
-
/* HRTIMER_MODE_ABS started life with a different name */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
#define HRTIMER_MODE_ABS HRTIMER_ABS