All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Kacur <jkacur@redhat.com>
To: Nicolas Saenz Julienne <nsaenzju@redhat.com>
Cc: linux-rt-users@vger.kernel.org, peterx@redhat.com, williams@redhat.com
Subject: Re: [PATCH v2 3/3] oslat: Allow for arch specific counter frequency measurements
Date: Mon, 13 Sep 2021 14:39:15 -0400 (EDT)	[thread overview]
Message-ID: <502acee-636e-1a93-f0d8-f191a24282@redhat.com> (raw)
In-Reply-To: <20210913083908.48408-3-nsaenzju@redhat.com>



On Mon, 13 Sep 2021, Nicolas Saenz Julienne wrote:

> Some architectures have special purpose registers to query the system
> counter's frequency. Let's use that when available.
> 
> Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
> --
> 
> Changes since v1:
>  - Use cleaner method to have generic and arch functions to measure
>    couter's freq
> 
>  src/oslat/oslat.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
> index c90ec1a..5fce223 100644
> --- a/src/oslat/oslat.c
> +++ b/src/oslat/oslat.c
> @@ -74,6 +74,16 @@ static inline void frc(uint64_t *pval)
>  # elif defined(__aarch64__)
>  #  define relax()          __asm__ __volatile("yield" : : : "memory")
>  
> +#define arch_measure_counter_mhz
> +static unsigned int measure_counter_mhz(void)
> +{
> +	unsigned int val;
> +
> +	__asm__ __volatile__("mrs %0, cntfrq_el0" : "=r" (val));
> +
> +	return val / 1e6;
> +}
> +
>  static inline void frc(uint64_t *pval)
>  {
>  	/*
> @@ -241,6 +251,7 @@ static int move_to_core(int core_i)
>  	return sched_setaffinity(0, sizeof(cpus), &cpus);
>  }
>  
> +#ifndef arch_measure_counter_mhz
>  static cycles_t __measure_counter_hz(void)
>  {
>  	struct timeval tvs, tve;
> @@ -273,6 +284,7 @@ static unsigned int measure_counter_mhz(void)
>  
>  	return (unsigned int) (m / 1000000);
>  }
> +#endif
>  
>  static void thread_init(struct thread *t)
>  {
> -- 
> 2.31.1
> 
> 
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>


  reply	other threads:[~2021-09-13 18:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13  8:39 [PATCH v2 1/3] oslat: Rename cpu_mhz/cpu_hz to counter_mhz/counter_hz Nicolas Saenz Julienne
2021-09-13  8:39 ` [PATCH v2 2/3] oslat: Add aarch64 support Nicolas Saenz Julienne
2021-09-13 18:38   ` John Kacur
2021-09-14  1:52   ` Punit Agrawal
2021-09-14 10:16     ` nsaenzju
2021-09-14 12:48       ` John Kacur
2021-09-15  1:52       ` Punit Agrawal
2021-09-13  8:39 ` [PATCH v2 3/3] oslat: Allow for arch specific counter frequency measurements Nicolas Saenz Julienne
2021-09-13 18:39   ` John Kacur [this message]
2021-09-13 13:35 ` [PATCH v2 1/3] oslat: Rename cpu_mhz/cpu_hz to counter_mhz/counter_hz John Kacur
2021-09-13 14:57   ` Peter Xu
2021-09-13 18:39     ` John Kacur
2021-09-13 18:38 ` John Kacur

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=502acee-636e-1a93-f0d8-f191a24282@redhat.com \
    --to=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=nsaenzju@redhat.com \
    --cc=peterx@redhat.com \
    --cc=williams@redhat.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.