All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Keir Fraser <keir@xen.org>, Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] x86: Adjust rdtsc inline assembly
Date: Wed, 18 Feb 2015 13:11:37 +0000	[thread overview]
Message-ID: <54E49D99020000780006114E@mail.emea.novell.com> (raw)
In-Reply-To: <1424262318-3405-1-git-send-email-andrew.cooper3@citrix.com>

>>> On 18.02.15 at 13:25, <andrew.cooper3@citrix.com> wrote:
> The single use of the old rdtsc() in emulate_privileged_op() is altered to use
> the new rdtsc() and the rdmsr_writeback path to set eax/edx appropriately.

I'm not entirely sure about this one - the current code surely is slightly
faster than the replacement. Question is how much this matters. I'd
suggest to be on the safe side and simply open-code the asm() there.
If you decide to follow that, there are a few more cosmetic things which
otherwise I would adjust while committing:

> @@ -1426,13 +1426,13 @@ static void __init tsc_check_writability(void)
>      if ( boot_cpu_has(X86_FEATURE_TSC_RELIABLE) )
>          return;
>  
> -    rdtscll(tsc);
> +    tsc = rdtsc();
>      if ( wrmsr_safe(MSR_IA32_TSC, 0) == 0 )
>      {
>          uint64_t tmp, tmp2;
> -        rdtscll(tmp2);
> +        tmp2 = rdtsc();

Blank line between declaration and statements. And perhaps the
assignment could become the variable's initializer.

> @@ -1973,8 +1973,7 @@ void tsc_set_info(struct domain *d,
>          else {
>              /* when using native TSC, offset is nsec relative to power-on
>               * of physical machine */
> -            uint64_t tsc = 0;
> -            rdtscll(tsc);
> +            uint64_t tsc = rdtsc();
>              d->arch.vtsc_offset = scale_delta(tsc,&d->arch.vtsc_to_ns) -

Blank line missing again.

> --- a/xen/include/asm-x86/msr.h
> +++ b/xen/include/asm-x86/msr.h
> @@ -71,17 +71,14 @@ static inline int wrmsr_safe(unsigned int msr, uint64_t val)
>      return _rc;
>  }
>  
> -#define rdtsc(low,high) \
> -     __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
> +static inline uint64_t rdtsc(void)
> +{
> +    uint32_t low, high;
>  
> -#define rdtscl(low) \
> -     __asm__ __volatile__("rdtsc" : "=a" (low) : : "edx")
> +    __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high));
>  
> -#define rdtscll(val) do { \
> -     unsigned int _eax, _edx; \
> -     asm volatile("rdtsc" : "=a" (_eax), "=d" (_edx)); \
> -     (val) = ((unsigned long)_eax) | (((unsigned long)_edx)<<32); \
> -} while(0)
> +    return (uint64_t)high << 32 | low;

Parentheses around the << please.

Jan

  reply	other threads:[~2015-02-18 13:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-18 12:25 [PATCH] x86: Adjust rdtsc inline assembly Andrew Cooper
2015-02-18 13:11 ` Jan Beulich [this message]
2015-02-18 13:59   ` Andrew Cooper
2015-02-18 14:05     ` [PATCH v2] " Andrew Cooper

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=54E49D99020000780006114E@mail.emea.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=keir@xen.org \
    --cc=xen-devel@lists.xen.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.