From: Joao Martins <joao.m.martins@oracle.com>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Juergen Gross <jgross@suse.com>,
Andy Lutomirski <luto@amacapital.net>
Subject: Re: [PATCH v4 2/3] x86/xen/time: setup vcpu 0 time info page
Date: Wed, 27 Sep 2017 16:26:10 +0100 [thread overview]
Message-ID: <a1fb7112-f8fd-7973-a48a-e1c6ef46b1c8@oracle.com> (raw)
In-Reply-To: <b38ff455-d225-67d5-cf20-047ea54abce4@oracle.com>
On 09/27/2017 03:40 PM, Boris Ostrovsky wrote:
>> +static void xen_setup_vsyscall_time_info(void)
>> +{
>> + struct vcpu_register_time_memory_area t;
>> + struct pvclock_vsyscall_time_info *ti;
>> + struct pvclock_vcpu_time_info *pvti;
>> + int ret;
>> +
>> + pvti = &__this_cpu_read(xen_vcpu)->time;
>> +
>> + /*
>> + * We check ahead on the primary time info if this
>> + * bit is supported hence speeding up Xen clocksource.
>> + */
>> + if (!(pvti->flags & PVCLOCK_TSC_STABLE_BIT))
>> + return;
>> +
>> + pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
>
> Is it OK to have this flag set if anything below fails?
>
Yes - if anything below fails it will only affect userspace mapped page. What I
do above is just allowing xen clocksource to use/check that bit (consequently
speeding up sched_clock) given the necessary support is there in the master
copy. The secondary copy (i.e. what's being set up below, mapped/used in vdso)
has the same data from the master copy, just separate memory regions. The checks
below are just for the unlikely cases of failing to register the secondary copy
or if its content were to differ from master copy in future releases - and
therefore we handle those more gracefully.
> (I can see in the changelog that apparently at some point I've asked
> about this at v1 but I can't remember/find what exactly it was)
>
>> +
>> + ti = (struct pvclock_vsyscall_time_info *)get_zeroed_page(GFP_KERNEL);
>> + if (!ti)
>> + return;
>> +
>> + t.addr.v = &ti->pvti;
>> +
>> + ret = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_time_memory_area, 0, &t);
>> + if (ret) {
>> + pr_notice("xen: VCLOCK_PVCLOCK not supported (err %d)\n", ret);
>> + free_page((unsigned long)ti);
>> + return;
>> + }
>> +
>> + /*
>> + * If the check above succedded this one should too since it's the
>> + * same data on both primary and secondary time infos just different
>> + * memory regions. But we still check it in case hypervisor is buggy.
>> + */
>> + pvti = &ti->pvti;
>> + if (!(pvti->flags & PVCLOCK_TSC_STABLE_BIT)) {
>> + t.addr.v = NULL;
>> + ret = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_time_memory_area,
>> + 0, &t);
>> + if (!ret)
>> + free_page((unsigned long)ti);
>> +
>> + pr_notice("xen: VCLOCK_PVCLOCK not supported (tsc unstable)\n");
>> + return;
>> + }
>> +
>> + xen_clock = ti;
>> + pvclock_set_pvti_cpu0_va(xen_clock);
>> +
>> + xen_clocksource.archdata.vclock_mode = VCLOCK_PVCLOCK;
>> +}
>> +
>
next prev parent reply other threads:[~2017-09-27 15:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-27 13:46 [PATCH v4 0/3] x86/xen: pvclock vdso support Joao Martins
2017-09-27 13:46 ` [PATCH v4 1/3] x86/pvclock: add setter for pvclock_pvti_cpu0_va Joao Martins
2017-09-27 13:46 ` [PATCH v4 2/3] x86/xen/time: setup vcpu 0 time info page Joao Martins
2017-09-27 14:18 ` Juergen Gross
2017-09-27 14:40 ` Boris Ostrovsky
2017-09-27 15:26 ` Joao Martins [this message]
2017-09-27 20:22 ` Boris Ostrovsky
2017-09-27 20:57 ` Joao Martins
2017-09-27 22:44 ` Boris Ostrovsky
2017-09-27 23:46 ` Joao Martins
2017-09-28 10:16 ` Joao Martins
2017-09-27 13:46 ` [PATCH v4 3/3] MAINTAINERS: xen, kvm: track pvclock-abi.h changes Joao Martins
2017-09-27 16:06 ` Konrad Rzeszutek Wilk
2017-09-28 10:56 ` Paolo Bonzini
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=a1fb7112-f8fd-7973-a48a-e1c6ef46b1c8@oracle.com \
--to=joao.m.martins@oracle.com \
--cc=boris.ostrovsky@oracle.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.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
all inboxes | Powered by JetHome®