All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: mingo@kernel.org, kvm@vger.kernel.org
Cc: johnstul@us.ibm.com, jeremy@goop.org, glommer@parallels.com,
	Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 09/18] x86: pvclock: generic pvclock vsyscall initialization
Date: Mon, 19 Nov 2012 19:58:07 -0200	[thread overview]
Message-ID: <20121119215959.067134244@redhat.com> (raw)
In-Reply-To: 20121119215758.686768790@redhat.com

[-- Attachment #1: 07-add-pvclock-structs-and-fixmap --]
[-- Type: text/plain, Size: 4272 bytes --]

Originally from Jeremy Fitzhardinge.

Introduce generic, non hypervisor specific, pvclock initialization 
routines.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: vsyscall/arch/x86/kernel/pvclock.c
===================================================================
--- vsyscall.orig/arch/x86/kernel/pvclock.c
+++ vsyscall/arch/x86/kernel/pvclock.c
@@ -17,6 +17,10 @@
 
 #include <linux/kernel.h>
 #include <linux/percpu.h>
+#include <linux/notifier.h>
+#include <linux/sched.h>
+#include <linux/gfp.h>
+#include <linux/bootmem.h>
 #include <asm/pvclock.h>
 
 static u8 valid_flags __read_mostly = 0;
@@ -122,3 +126,68 @@ void pvclock_read_wallclock(struct pvclo
 
 	set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
 }
+
+static struct pvclock_vsyscall_time_info *pvclock_vdso_info;
+
+static struct pvclock_vsyscall_time_info *
+pvclock_get_vsyscall_user_time_info(int cpu)
+{
+	if (!pvclock_vdso_info) {
+		BUG();
+		return NULL;
+	}
+
+	return &pvclock_vdso_info[cpu];
+}
+
+struct pvclock_vcpu_time_info *pvclock_get_vsyscall_time_info(int cpu)
+{
+	return &pvclock_get_vsyscall_user_time_info(cpu)->pvti;
+}
+
+int pvclock_task_migrate(struct notifier_block *nb, unsigned long l, void *v)
+{
+	struct task_migration_notifier *mn = v;
+	struct pvclock_vsyscall_time_info *pvti;
+
+	pvti = pvclock_get_vsyscall_user_time_info(mn->from_cpu);
+
+	/* this is NULL when pvclock vsyscall is not initialized */
+	if (unlikely(pvti == NULL))
+		return NOTIFY_DONE;
+
+	pvti->migrate_count++;
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block pvclock_migrate = {
+	.notifier_call = pvclock_task_migrate,
+};
+
+/*
+ * Initialize the generic pvclock vsyscall state.  This will allocate
+ * a/some page(s) for the per-vcpu pvclock information, set up a
+ * fixmap mapping for the page(s)
+ */
+
+int __init pvclock_init_vsyscall(struct pvclock_vsyscall_time_info *i,
+				 int size)
+{
+	int idx;
+
+	WARN_ON (size != PVCLOCK_VSYSCALL_NR_PAGES*PAGE_SIZE);
+
+	pvclock_vdso_info = i;
+
+	for (idx = 0; idx <= (PVCLOCK_FIXMAP_END-PVCLOCK_FIXMAP_BEGIN); idx++) {
+		__set_fixmap(PVCLOCK_FIXMAP_BEGIN + idx,
+			     __pa_symbol(i) + (idx*PAGE_SIZE),
+			     PAGE_KERNEL_VVAR);
+	}
+
+
+	register_task_migration_notifier(&pvclock_migrate);
+
+	return 0;
+}
Index: vsyscall/arch/x86/include/asm/fixmap.h
===================================================================
--- vsyscall.orig/arch/x86/include/asm/fixmap.h
+++ vsyscall/arch/x86/include/asm/fixmap.h
@@ -19,6 +19,7 @@
 #include <asm/acpi.h>
 #include <asm/apicdef.h>
 #include <asm/page.h>
+#include <asm/pvclock.h>
 #ifdef CONFIG_X86_32
 #include <linux/threads.h>
 #include <asm/kmap_types.h>
@@ -81,6 +82,10 @@ enum fixed_addresses {
 	VVAR_PAGE,
 	VSYSCALL_HPET,
 #endif
+#ifdef CONFIG_PARAVIRT_CLOCK
+	PVCLOCK_FIXMAP_BEGIN,
+	PVCLOCK_FIXMAP_END = PVCLOCK_FIXMAP_BEGIN+PVCLOCK_VSYSCALL_NR_PAGES-1,
+#endif
 	FIX_DBGP_BASE,
 	FIX_EARLYCON_MEM_BASE,
 #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
Index: vsyscall/arch/x86/include/asm/pvclock.h
===================================================================
--- vsyscall.orig/arch/x86/include/asm/pvclock.h
+++ vsyscall/arch/x86/include/asm/pvclock.h
@@ -85,4 +85,16 @@ unsigned __pvclock_read_cycles(const str
 	return version;
 }
 
+struct pvclock_vsyscall_time_info {
+	struct pvclock_vcpu_time_info pvti;
+	u32 migrate_count;
+} __attribute__((__aligned__(SMP_CACHE_BYTES)));
+
+#define PVTI_SIZE sizeof(struct pvclock_vsyscall_time_info)
+#define PVCLOCK_VSYSCALL_NR_PAGES (((NR_CPUS-1)/(PAGE_SIZE/PVTI_SIZE))+1)
+
+int __init pvclock_init_vsyscall(struct pvclock_vsyscall_time_info *i,
+				 int size);
+struct pvclock_vcpu_time_info *pvclock_get_vsyscall_time_info(int cpu);
+
 #endif /* _ASM_X86_PVCLOCK_H */
Index: vsyscall/arch/x86/include/asm/clocksource.h
===================================================================
--- vsyscall.orig/arch/x86/include/asm/clocksource.h
+++ vsyscall/arch/x86/include/asm/clocksource.h
@@ -8,6 +8,7 @@
 #define VCLOCK_NONE 0  /* No vDSO clock available.	*/
 #define VCLOCK_TSC  1  /* vDSO should use vread_tsc.	*/
 #define VCLOCK_HPET 2  /* vDSO should use vread_hpet.	*/
+#define VCLOCK_PVCLOCK 3 /* vDSO should use vread_pvclock. */
 
 struct arch_clocksource_data {
 	int vclock_mode;



  parent reply	other threads:[~2012-11-19 21:58 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-15  0:08 [patch 00/18] pvclock vsyscall support + KVM hypervisor support (v4) Marcelo Tosatti
2012-11-15  0:08 ` [patch 01/18] KVM: x86: retain pvclock guest stopped bit in guest memory Marcelo Tosatti
2012-11-15  0:08 ` [patch 02/18] x86: kvmclock: allocate pvclock shared memory area Marcelo Tosatti
2012-11-15 17:05   ` Glauber Costa
2012-11-16  2:07     ` [patch 02/18] x86: kvmclock: allocate pvclock shared memory area (v2) Marcelo Tosatti
2012-11-16  7:06       ` Glauber Costa
2012-11-15  0:08 ` [patch 03/18] x86: pvclock: make sure rdtsc doesnt speculate out of region Marcelo Tosatti
2012-11-15  0:08 ` [patch 04/18] x86: pvclock: remove pvclock_shadow_time Marcelo Tosatti
2012-11-15  0:08 ` [patch 05/18] x86: pvclock: create helper for pvclock data retrieval Marcelo Tosatti
2012-11-15 12:27   ` Glauber Costa
2012-11-15  0:08 ` [patch 06/18] x86: pvclock: introduce helper to read flags Marcelo Tosatti
2012-11-15 12:28   ` Glauber Costa
2012-11-15  0:08 ` [patch 07/18] x86: pvclock: add note about rdtsc barriers Marcelo Tosatti
2012-11-15 12:30   ` Glauber Costa
2012-11-16  2:05     ` [patch 07/18] x86: pvclock: add note about rdtsc barriers (v2) Marcelo Tosatti
2012-11-15  0:08 ` [patch 08/18] sched: add notifier for cross-cpu migrations Marcelo Tosatti
2012-11-15  7:01   ` Gleb Natapov
2012-11-15  0:08 ` [patch 09/18] x86: pvclock: generic pvclock vsyscall initialization Marcelo Tosatti
2012-11-15  0:08 ` [patch 10/18] x86: kvm guest: pvclock vsyscall support Marcelo Tosatti
2012-11-15  0:08 ` [patch 11/18] x86: vdso: pvclock gettime support Marcelo Tosatti
2012-11-15  0:08 ` [patch 12/18] KVM: x86: pass host_tsc to read_l1_tsc Marcelo Tosatti
2012-11-15  0:08 ` [patch 13/18] time: export time information for KVM pvclock Marcelo Tosatti
2012-11-15  1:38   ` John Stultz
2012-11-15  0:08 ` [patch 14/18] KVM: x86: notifier for clocksource changes Marcelo Tosatti
2012-11-15  0:08 ` [patch 15/18] KVM: x86: implement PVCLOCK_TSC_STABLE_BIT pvclock flag Marcelo Tosatti
2012-11-15  0:08 ` [patch 16/18] KVM: x86: add kvm_arch_vcpu_postcreate callback, move TSC initialization Marcelo Tosatti
2012-11-15  0:08 ` [patch 17/18] KVM: x86: require matched TSC offsets for master clock Marcelo Tosatti
2012-11-15  0:08 ` [patch 18/18] KVM: x86: update pvclock area conditionally, on cpu migration Marcelo Tosatti
2012-11-15 12:34   ` Glauber Costa
2012-11-19 21:57 ` [patch 00/18] pvclock vsyscall support + KVM hypervisor support (v5) Marcelo Tosatti
2012-11-19 21:57   ` [patch 01/18] KVM: x86: retain pvclock guest stopped bit in guest memory Marcelo Tosatti
2012-11-19 21:58   ` [patch 02/18] x86: kvmclock: allocate pvclock shared memory area Marcelo Tosatti
2012-11-19 21:58   ` [patch 03/18] x86: pvclock: make sure rdtsc doesnt speculate out of region Marcelo Tosatti
2012-11-19 21:58   ` [patch 04/18] x86: pvclock: remove pvclock_shadow_time Marcelo Tosatti
2012-11-19 21:58   ` [patch 05/18] x86: pvclock: create helper for pvclock data retrieval Marcelo Tosatti
2012-11-19 21:58   ` [patch 06/18] x86: pvclock: introduce helper to read flags Marcelo Tosatti
2012-11-19 21:58   ` [patch 07/18] x86: pvclock: add note about rdtsc barriers Marcelo Tosatti
2012-11-19 21:58   ` [patch 08/18] sched: add notifier for cross-cpu migrations Marcelo Tosatti
2012-11-19 21:58   ` Marcelo Tosatti [this message]
2012-11-19 21:58   ` [patch 11/18] x86: vdso: pvclock gettime support Marcelo Tosatti
2012-11-19 21:58   ` [patch 12/18] KVM: x86: pass host_tsc to read_l1_tsc Marcelo Tosatti
2012-11-19 21:58   ` [patch 13/18] time: export time information for KVM pvclock Marcelo Tosatti
2012-11-19 21:58   ` [patch 14/18] KVM: x86: notifier for clocksource changes Marcelo Tosatti
2012-11-19 21:58   ` [patch 15/18] KVM: x86: implement PVCLOCK_TSC_STABLE_BIT pvclock flag Marcelo Tosatti
2012-11-19 21:58   ` [patch 16/18] KVM: x86: add kvm_arch_vcpu_postcreate callback, move TSC initialization Marcelo Tosatti
2012-11-19 21:58   ` [patch 17/18] KVM: x86: require matched TSC offsets for master clock Marcelo Tosatti
2012-11-19 21:58   ` [patch 18/18] KVM: x86: update pvclock area conditionally, on cpu migration Marcelo Tosatti
2012-11-20  9:01     ` Glauber Costa
2012-11-20  9:03   ` [patch 00/18] pvclock vsyscall support + KVM hypervisor support (v5) Glauber Costa

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=20121119215959.067134244@redhat.com \
    --to=mtosatti@redhat.com \
    --cc=glommer@parallels.com \
    --cc=jeremy@goop.org \
    --cc=johnstul@us.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@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 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.