All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Semel <semelpaul@gmail.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: xen-devel@lists.xenproject.org, Paul Semel <phentex@amazon.de>,
	andrew.cooper3@citrix.com, wipawel@amazon.de
Subject: Re: [PATCH v3 1/7] introduce time managment in xtf
Date: Mon, 9 Apr 2018 17:12:46 +0200	[thread overview]
Message-ID: <ec9cc2f5-59b1-d76d-0137-40356cc4170a@gmail.com> (raw)
In-Reply-To: <20180409143555.2rh7um6g7op2bvz3@MacBook-Pro-de-Roger.local>

On 04/09/2018 04:35 PM, Roger Pau Monné wrote:
>> this file is introduce to be able to implement an inter domain
>> communication protocol over xenstore. For synchronization purpose, we do
>> really want to be able to "control" time
>>
>> common/time.c: since_boot_time gets the time in nanoseconds from the
>> moment the VM has booted
>>
>> Signed-off-by: Paul Semel <phentex@amazon.de>
>> ---
> 
> This seems to be missing a list of changes between v2 and v3. Please
> add such a list when posting new versions.
> 
>> +uint64_t since_boot_time(void)
>> +{
>> +    uint64_t tsc;
>> +    uint32_t ver1, ver2;
>> +    uint64_t system_time;
>> +    uint64_t old_tsc;
>> +
>> +    do
>> +    {
>> +        do
>> +        {
>> +            ver1 = ACCESS_ONCE(shared_info.vcpu_info[0].time.version);
>> +            smp_rmb();
>> +        } while ( (ver1 & 1) == 1 );
>> +
>> +        system_time = ACCESS_ONCE(shared_info.vcpu_info[0].time.system_time);
>> +        old_tsc = ACCESS_ONCE(shared_info.vcpu_info[0].time.tsc_timestamp);
>> +        smp_rmb();
>> +        ver2 = ACCESS_ONCE(shared_info.vcpu_info[0].time.version);
>> +        smp_rmb();
>> +    } while ( ver1 != ver2 );
> 
> This is still overly complicated IMO, and you have not replied to my
> question of whether doing the scale_delta below is OK.

About this scale_delta, we discussed with Andrew, and we are going to use 
another version of the function as far as I remember. That's why I am not taking 
care of it for the moment.
> 
> AFAICT uou _cannot_ access any of the vcpu_time_info fields without
> checking for the version (in order to avoid reading inconsistent data
> during an update), yet below you read tsc_to_system_mul and
> tsc_shift.
> 

I'm sorry, I am probably not getting your point here, because I am already 
checking for the version. I was actually checking for the wc_version too in the 
first version of those patches, but after chatting with Andrew, It appeared that 
it was not necessary..

> I've already pointed out the code at:
> 
> https://github.com/freebsd/freebsd/blob/master/sys/x86/x86/pvclock.c#L141
> 
> As a simpler reference implementation.
> 
>> +
>> +    rdtsc(tsc);
>> +
>> +    system_time += scale_delta(tsc - old_tsc,
>> +                   ACCESS_ONCE(shared_info.vcpu_info[0].time.tsc_to_system_mul),
>> +                   ACCESS_ONCE(shared_info.vcpu_info[0].time.tsc_shift));
>> +
>> +    return system_time;
>> +}
>> +
>> +/*
>> + * Local variables:
>> + * mode: C
>> + * c-file-style: "BSD"
>> + * c-basic-offset: 4
>> + * tab-width: 4
>> + * indent-tabs-mode: nil
>> + * End:
>> + */
>> diff --git a/include/xtf/time.h b/include/xtf/time.h
>> new file mode 100644
>> index 0000000..b88da63
>> --- /dev/null
>> +++ b/include/xtf/time.h
>> @@ -0,0 +1,31 @@
>> +/**
>> + * @file include/xtf/time.h
>> + *
>> + * Time management
>> + */
>> +#ifndef XTF_TIME_H
>> +# define XTF_TIME_H
>> +
>> +#include <xtf/types.h>
>> +
>> +#define rdtsc(tsc) {\
>> +    uint32_t lo, hi;\
>> +    __asm__ volatile("rdtsc": "=a"(lo), "=d"(hi));\
> 
> Please make sure you only send a new version after having fixed all
> the comments, this is still missing the serialization requirements
> mentioned in the review, and it's also the wrong file to place this
> helper:
> 

I am sorry, I was really convinced that this version didn't need revision 
anymore (and I still don't see what I should change).

> https://lists.xenproject.org/archives/html/xen-devel/2018-04/msg00546.html
> 
> Roger.
> 

Thanks,

-- 
Paul

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-04-09 14:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-09 14:35 [PATCH v3 1/7] introduce time managment in xtf Paul Semel
2018-04-09 14:35 ` [PATCH v3 2/7] add current_time function to time manager Paul Semel
2018-04-09 14:35 ` [PATCH v3 3/7] add gettimeofday function to time managment Paul Semel
2018-04-09 14:35 ` [PATCH v3 4/7] add nspin_sleep function to time manager Paul Semel
2018-04-09 14:35 ` [PATCH v3 5/7] add spin_sleep " Paul Semel
2018-04-09 14:35 ` [PATCH v3 6/7] add mspin_sleep " Paul Semel
2018-04-09 14:35 ` [PATCH v3 7/7] add sleep, msleep and NOW() macros " Paul Semel
2018-04-09 14:35 ` [PATCH v3 1/7] introduce time managment in xtf Roger Pau Monné
2018-04-09 14:45   ` Andrew Cooper
2018-04-09 15:12   ` Paul Semel [this message]
2018-04-10  8:08     ` Roger Pau Monné
2018-04-10  9:47       ` Paul Semel
2018-04-10 10:05         ` Roger Pau Monné
2018-04-10 10:32           ` Paul Semel
2018-04-10 10:36             ` Roger Pau Monné
2018-04-10 10:39               ` Paul Semel

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=ec9cc2f5-59b1-d76d-0137-40356cc4170a@gmail.com \
    --to=semelpaul@gmail.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=phentex@amazon.de \
    --cc=roger.pau@citrix.com \
    --cc=wipawel@amazon.de \
    --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 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.