netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@kernel.org>
To: Christopher Hall <christopher.s.hall@intel.com>,
	john.stultz@linaro.org, tglx@linutronix.de,
	richardcochran@gmail.com, mingo@redhat.com,
	jeffrey.t.kirsher@intel.com, john.ronciak@intel.com,
	hpa@zytor.com, x86@kernel.org
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v2 1/4] Add generic correlated clocksource code and ART to TSC conversion code
Date: Fri, 7 Aug 2015 16:44:37 -0700	[thread overview]
Message-ID: <55C542E5.2000100@kernel.org> (raw)
In-Reply-To: <1438988495-9942-2-git-send-email-christopher.s.hall@intel.com>

On 08/07/2015 04:01 PM, Christopher Hall wrote:
> Original patch description:
>
> Subject: ptp: Get sync timestamps
> From: Thomas Gleixner <tglx@linutronix.de>
> Date: Wed, 29 Jul 2015 10:52:06 +0200
>
> The ART stuff wants to be splitted out.
>
> ======== Changes =======
>
> Add struct correlated_cs (clocksource) with pointer to original clocksource
> 	and function pointer to convert correlated clocksource to the original
>
> Add struct correlated_ts (timestamp) with function pointer to read correlated
> 	clocksource, device and system (in terms of correlated clocksource)
> 	counter values (input) with resulting converted real and monotonic raw
> 	system times (output)
>
> Add get_correlated_timestamp() function which given specific correlated_cs
> 	and correlated_ts convert correlated counter value to system time
>
> Add art_to_tsc conversion function translated Always Running Timer (ART) to
> 	TSC value
> ---
>   arch/x86/kernel/tsc.c       | 31 ++++++++++++++++++++++
>   include/linux/clocksource.h | 30 +++++++++++++++++++++
>   include/linux/timekeeping.h |  4 +++
>   kernel/time/timekeeping.c   | 63 +++++++++++++++++++++++++++++++++++++++++++++
>   4 files changed, 128 insertions(+)
>
> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
> index 7437b41..a90aa6a 100644
> --- a/arch/x86/kernel/tsc.c
> +++ b/arch/x86/kernel/tsc.c
> @@ -1059,6 +1059,27 @@ int unsynchronized_tsc(void)
>   	return 0;
>   }
>
> +static u32 tsc_numerator;
> +static u32 tsc_denominator;
> +/*
> + * CHECKME: Do we need the adjust value? It should be 0, but if we run
> + * in a VM this might be a different story.
> + */
> +static u64 tsc_adjust;
> +
> +static u64 art_to_tsc(u64 cycles)
> +{
> +	u64 tmp, res = tsc_adjust;
> +
> +	res += (cycles / tsc_denominator) * tsc_numerator;
> +	tmp = (cycles % tsc_denominator) * tsc_numerator;
> +	res += tmp / tsc_denominator;
> +	return res;

Nice trick!

> diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
> index 278dd27..2ed3d0c 100644
> --- a/include/linux/clocksource.h
> +++ b/include/linux/clocksource.h
> @@ -258,4 +258,34 @@ void acpi_generic_timer_init(void);
>   static inline void acpi_generic_timer_init(void) { }
>   #endif
>
> +/**
> + * struct correlated_cs - Descriptor for a clocksource correlated to another clocksource
> + * @related_cs:		Pointer to the related timekeeping clocksource
> + * @convert:		Conversion function to convert a timestamp from
> + *			the correlated clocksource to cycles of the related
> + *			timekeeping clocksource
> + */
> +struct correlated_cs {
> +	struct clocksource	*related_cs;
> +	u64			(*convert)(u64 cycles);

Should the name make it clearer which way it converts?  For example, 
convert_to_related?  We might also want convert_from_related.

--Andy

  reply	other threads:[~2015-08-07 23:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-07 23:01 [PATCH v2 0/4] Patchset enabling hardware based cross-timestamps for next gen Intel platforms Christopher Hall
2015-08-07 23:01 ` [PATCH v2 1/4] Add generic correlated clocksource code and ART to TSC conversion code Christopher Hall
2015-08-07 23:44   ` Andy Lutomirski [this message]
2015-08-07 23:01 ` [PATCH v2 2/4] Add ART initialization code Christopher Hall
2015-08-07 23:01 ` [PATCH v2 3/4] Add support for driver cross-timestamp to PTP_SYS_OFFSET ioctl Christopher Hall
2015-08-10  8:53   ` Richard Cochran
2015-08-07 23:01 ` [PATCH v2 4/4] Added getsynctime64() callback Christopher Hall
2015-08-10  8:49   ` Richard Cochran
2015-08-13 21:10     ` Hall, Christopher S
2015-08-14  6:32       ` Richard Cochran

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=55C542E5.2000100@kernel.org \
    --to=luto@kernel.org \
    --cc=christopher.s.hall@intel.com \
    --cc=hpa@zytor.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=john.ronciak@intel.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).