From: Glauber Costa <glommer@parallels.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: <kvm@vger.kernel.org>, <johnstul@us.ibm.com>, <jeremy@goop.org>,
<zamsden@gmail.com>, <gleb@redhat.com>, <avi@redhat.com>,
<pbonzini@redhat.com>
Subject: Re: [patch 07/16] x86: pvclock: generic pvclock vsyscall initialization
Date: Thu, 1 Nov 2012 18:19:46 +0400 [thread overview]
Message-ID: <50928502.6000309@parallels.com> (raw)
In-Reply-To: <20121031224824.149072621@redhat.com>
On 11/01/2012 02:47 AM, Marcelo Tosatti wrote:
> 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,67 @@ void pvclock_read_wallclock(struct pvclo
>
> set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
> }
> +
> +static aligned_pvti_t *pvclock_vdso_info;
is there a non-aligned pvti ?
I would also add that "pvti" is not exactly the most descriptive name
I've seen.
> +
> +static struct pvclock_vsyscall_time_info *
> +pvclock_get_vsyscall_user_time_info(int cpu)
> +{
> + if (pvclock_vdso_info == NULL) {
> + BUG();
> + return NULL;
> + }
> +
> + return &pvclock_vdso_info[cpu].info;
> +}
> +
if (!pvclock_vdso_info)
BUG();
return &pvclock...
> +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);
> +
> + if (pvti == NULL)
> + return NOTIFY_DONE;
> +
When is it NULL? IIUC, this is when the vsyscall is disabled, right?
Would you mind adding comments for it?
Also, this is supposed to be an unlikely branch, right?
> + 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(void)
> +{
> + int idx;
> + unsigned int size = PVCLOCK_VSYSCALL_NR_PAGES*PAGE_SIZE;
> +
> + pvclock_vdso_info = __alloc_bootmem(size, PAGE_SIZE, 0);
This will be the most critical path for reading pvclock's time data. So
why can't we:
1) Make it per-node.
2) Of course, as a consequence, make sure all info structures in the
same page are in the same node ?
> + if (!pvclock_vdso_info)
> + return -ENOMEM;
> +
> + memset(pvclock_vdso_info, 0, size);
> +
> + for (idx = 0; idx <= (PVCLOCK_FIXMAP_END-PVCLOCK_FIXMAP_BEGIN); idx++) {
> + __set_fixmap(PVCLOCK_FIXMAP_BEGIN + idx,
> + __pa_symbol(pvclock_vdso_info) + (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
> @@ -13,6 +13,8 @@ void pvclock_read_wallclock(struct pvclo
> struct pvclock_vcpu_time_info *vcpu,
> struct timespec *ts);
> void pvclock_resume(void);
> +int __init pvclock_init_vsyscall(void);
> +struct pvclock_vcpu_time_info *pvclock_get_vsyscall_time_info(int cpu);
>
> /*
> * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
> @@ -85,4 +87,17 @@ unsigned __pvclock_read_cycles(const str
> return version;
> }
>
> +struct pvclock_vsyscall_time_info {
> + struct pvclock_vcpu_time_info pvti;
> + u32 migrate_count;
> +};
> +
> +typedef union {
> + struct pvclock_vsyscall_time_info info;
> + char pad[SMP_CACHE_BYTES];
> +} aligned_pvti_t ____cacheline_aligned;
Please, just align pvclock_vsyscall_time_info. It is 10 thousand times
more descriptive.
next prev parent reply other threads:[~2012-11-01 14:19 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-24 13:13 [patch 00/18] pvclock vsyscall support + KVM hypervisor support (v2) Marcelo Tosatti
2012-10-24 13:13 ` [patch 01/18] KVM: x86: retain pvclock guest stopped bit in guest memory Marcelo Tosatti
2012-10-24 13:13 ` [patch 02/18] x86: pvclock: make sure rdtsc doesnt speculate out of region Marcelo Tosatti
2012-10-24 13:13 ` [patch 03/18] x86: pvclock: remove pvclock_shadow_time Marcelo Tosatti
2012-10-30 9:23 ` Avi Kivity
2012-10-30 9:24 ` Avi Kivity
2012-10-24 13:13 ` [patch 04/18] x86: pvclock: create helper for pvclock data retrieval Marcelo Tosatti
2012-10-24 13:13 ` [patch 05/18] x86: pvclock: fix flags usage race Marcelo Tosatti
2012-10-24 13:13 ` [patch 06/18] x86: pvclock: introduce helper to read flags Marcelo Tosatti
2012-10-24 13:13 ` [patch 07/18] sched: add notifier for cross-cpu migrations Marcelo Tosatti
2012-10-24 13:13 ` [patch 08/18] x86: pvclock: generic pvclock vsyscall initialization Marcelo Tosatti
2012-10-29 14:18 ` Glauber Costa
2012-10-29 14:54 ` Marcelo Tosatti
2012-10-29 17:46 ` Jeremy Fitzhardinge
2012-10-29 14:39 ` Glauber Costa
2012-10-24 13:13 ` [patch 09/18] KVM: x86: introduce facility to support vsyscall pvclock, via MSR Marcelo Tosatti
2012-10-29 14:45 ` Glauber Costa
2012-10-29 17:44 ` Jeremy Fitzhardinge
2012-10-29 18:40 ` Marcelo Tosatti
2012-10-30 7:41 ` Glauber Costa
2012-10-30 9:39 ` Avi Kivity
2012-10-31 3:12 ` Marcelo Tosatti
2012-11-02 10:21 ` Glauber Costa
2012-10-30 7:38 ` Glauber Costa
2012-10-24 13:13 ` [patch 10/18] x86: kvm guest: pvclock vsyscall support Marcelo Tosatti
2012-10-24 13:13 ` [patch 11/18] x86: vsyscall: pass mode to gettime backend Marcelo Tosatti
2012-10-29 14:47 ` Glauber Costa
2012-10-29 18:41 ` Marcelo Tosatti
2012-10-30 7:42 ` Glauber Costa
2012-10-24 13:13 ` [patch 12/18] x86: vdso: pvclock gettime support Marcelo Tosatti
2012-10-29 14:59 ` Glauber Costa
2012-10-29 18:42 ` Marcelo Tosatti
2012-10-30 7:49 ` Glauber Costa
2012-10-31 3:16 ` Marcelo Tosatti
2012-10-24 13:13 ` [patch 13/18] KVM: x86: pass host_tsc to read_l1_tsc Marcelo Tosatti
2012-10-29 15:04 ` Glauber Costa
2012-10-29 18:45 ` Marcelo Tosatti
2012-10-30 7:55 ` Glauber Costa
2012-10-24 13:13 ` [patch 14/18] time: export time information for KVM pvclock Marcelo Tosatti
2012-11-10 1:02 ` John Stultz
2012-11-13 21:07 ` Marcelo Tosatti
2012-10-24 13:13 ` [patch 15/18] KVM: x86: implement PVCLOCK_TSC_STABLE_BIT pvclock flag Marcelo Tosatti
2012-10-30 8:34 ` Glauber Costa
2012-10-31 3:19 ` [patch 15/18] KVM: x86: implement PVCLOCK_TSC_STABLE_BIT pvclock flag\ Marcelo Tosatti
2012-10-24 13:13 ` [patch 16/18] KVM: x86: notifier for clocksource changes Marcelo Tosatti
2012-10-24 13:13 ` [patch 17/18] KVM: x86: add kvm_arch_vcpu_postcreate callback, move TSC initialization Marcelo Tosatti
2012-10-24 13:13 ` [patch 18/18] KVM: x86: require matched TSC offsets for master clock Marcelo Tosatti
2012-10-31 22:46 ` [patch 00/16] pvclock vsyscall support + KVM hypervisor support (v3) Marcelo Tosatti
2012-10-31 22:46 ` [patch 01/16] KVM: x86: retain pvclock guest stopped bit in guest memory Marcelo Tosatti
2012-11-01 10:39 ` Gleb Natapov
2012-11-01 20:51 ` Marcelo Tosatti
2012-11-01 13:44 ` Glauber Costa
2012-10-31 22:46 ` [patch 02/16] x86: pvclock: make sure rdtsc doesnt speculate out of region Marcelo Tosatti
2012-11-01 11:48 ` Gleb Natapov
2012-11-01 13:49 ` Glauber Costa
2012-11-01 13:51 ` Gleb Natapov
2012-11-01 20:56 ` Marcelo Tosatti
2012-11-01 22:13 ` Gleb Natapov
2012-11-01 22:21 ` Marcelo Tosatti
2012-11-02 6:02 ` Gleb Natapov
2012-10-31 22:46 ` [patch 03/16] x86: pvclock: remove pvclock_shadow_time Marcelo Tosatti
2012-11-01 13:52 ` Glauber Costa
2012-10-31 22:47 ` [patch 04/16] x86: pvclock: create helper for pvclock data retrieval Marcelo Tosatti
2012-11-01 14:04 ` Glauber Costa
2012-11-01 20:57 ` Marcelo Tosatti
2012-10-31 22:47 ` [patch 05/16] x86: pvclock: introduce helper to read flags Marcelo Tosatti
2012-11-01 14:07 ` Glauber Costa
2012-11-01 21:08 ` Marcelo Tosatti
2012-10-31 22:47 ` [patch 06/16] sched: add notifier for cross-cpu migrations Marcelo Tosatti
2012-11-01 14:08 ` Glauber Costa
2012-10-31 22:47 ` [patch 07/16] x86: pvclock: generic pvclock vsyscall initialization Marcelo Tosatti
2012-11-01 14:19 ` Glauber Costa [this message]
2012-10-31 22:47 ` [patch 08/16] KVM: x86: introduce facility to support vsyscall pvclock, via MSR Marcelo Tosatti
2012-11-01 14:28 ` Glauber Costa
2012-11-01 21:39 ` Marcelo Tosatti
2012-11-02 10:23 ` Glauber Costa
2012-11-02 13:00 ` Marcelo Tosatti
2012-11-05 8:03 ` Glauber Costa
2012-10-31 22:47 ` [patch 09/16] x86: kvm guest: pvclock vsyscall support Marcelo Tosatti
2012-11-02 9:42 ` Glauber Costa
2012-11-05 8:35 ` Marcelo Tosatti
2012-10-31 22:47 ` [patch 10/16] x86: vdso: pvclock gettime support Marcelo Tosatti
2012-11-01 14:41 ` Glauber Costa
2012-11-01 21:42 ` Marcelo Tosatti
2012-11-02 0:33 ` Marcelo Tosatti
2012-11-02 10:25 ` Glauber Costa
2012-11-14 10:42 ` Gleb Natapov
2012-11-14 22:42 ` Marcelo Tosatti
2012-10-31 22:47 ` [patch 11/16] KVM: x86: pass host_tsc to read_l1_tsc Marcelo Tosatti
2012-10-31 22:47 ` [patch 12/16] time: export time information for KVM pvclock Marcelo Tosatti
2012-10-31 22:47 ` [patch 13/16] KVM: x86: implement PVCLOCK_TSC_STABLE_BIT pvclock flag Marcelo Tosatti
2012-10-31 22:47 ` [patch 14/16] KVM: x86: notifier for clocksource changes Marcelo Tosatti
2012-10-31 22:47 ` [patch 15/16] KVM: x86: add kvm_arch_vcpu_postcreate callback, move TSC initialization Marcelo Tosatti
2012-10-31 22:47 ` [patch 16/16] KVM: x86: require matched TSC offsets for master clock Marcelo Tosatti
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=50928502.6000309@parallels.com \
--to=glommer@parallels.com \
--cc=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=jeremy@goop.org \
--cc=johnstul@us.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=zamsden@gmail.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 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.