public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: kan.liang@intel.com
Cc: peterz@infradead.org, mingo@redhat.com, eranian@google.com,
	linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com,
	acme@redhat.com, torvalds@linux-foundation.org,
	tglx@linutronix.de, vincent.weaver@maine.edu, ak@linux.intel.com
Subject: Re: [PATCH V2 1/2] perf/x86/intel: enable CPU ref_cycles for GP counter
Date: Mon, 12 Jun 2017 12:36:31 +0200	[thread overview]
Message-ID: <20170612103631.GA6099@krava> (raw)
In-Reply-To: <1497029283-3332-1-git-send-email-kan.liang@intel.com>

On Fri, Jun 09, 2017 at 10:28:02AM -0700, kan.liang@intel.com wrote:

SNIP

> +	/*
> +	 * Correct the count number if applying ref_cycles replacement.
> +	 * There is a constant ratio between ref_cycles (event A) and
> +	 * ref_cycles replacement (event B). The delta result is from event B.
> +	 * To get accurate event A count, the real delta result must be
> +	 * multiplied with the constant ratio.
> +	 *
> +	 * It is handled differently for sampling and counting.
> +	 * - Fixed period Sampling: The period is already adjusted in
> +	 *   scheduling for event B. The period_left is the remaining period
> +	 *   for event B. Don't need to modify period_left.
> +	 *   It's enough to only adjust event->count here.
> +	 *
> +	 * - Fixed freq Sampling: The adaptive frequency algorithm needs
> +	 *   the last_period and event counts for event A to estimate the next
> +	 *   period for event A. So the period_left is the remaining period
> +	 *   for event A. It needs to multiply the result with the ratio.
> +	 *   However, the period_left is also used to reload the event counter
> +	 *   for event B in x86_perf_event_set_period. It has to be adjusted to
> +	 *   event B's remaining period there.
> +	 *
> +	 * - Counting: It's enough to only adjust event->count for perf stat.
> +	 *
> +	 * - RDPMC: User can also read the counter directly by rdpmc/mmap.
> +	 *   Users have to handle the adjustment themselves.
> +	 *   For kernel, it only needs to guarantee that the offset is correct.
> +	 *   In x86's arch_perf_update_userpage, the offset will be corrected
> +	 *   if event B is used.
> +	 */
> +	adjust_delta = delta;
> +	if (hwc->flags & PERF_X86_EVENT_REF_CYCLES_REP) {
> +		adjust_delta = delta * x86_pmu.ref_cycles_factor;
> +
> +		if (is_sampling_event(event) && event->attr.freq)
> +			local64_sub(adjust_delta, &hwc->period_left);
> +		else
> +			local64_sub(delta, &hwc->period_left);

shouldn't you use adjust_delta in here also ^^^ ?

jirka

  parent reply	other threads:[~2017-06-12 10:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09 17:28 [PATCH V2 1/2] perf/x86/intel: enable CPU ref_cycles for GP counter kan.liang
2017-06-09 17:28 ` [PATCH V2 2/2] perf/x86/intel, watchdog: Switch NMI watchdog to ref cycles on x86 kan.liang
     [not found]   ` <CA+55aFz7jZ0Yx+zxDZFxUOJcMtBtzfVphUdUrGwfv9SmiNwT6A@mail.gmail.com>
2017-06-11 18:44     ` Andi Kleen
2017-06-12 12:51     ` Liang, Kan
2017-06-12 10:36 ` Jiri Olsa [this message]
2017-06-12 13:07   ` [PATCH V2 1/2] perf/x86/intel: enable CPU ref_cycles for GP counter Liang, Kan
2017-06-23 17:21 ` Liang, Kan
2017-06-23 21:46 ` Thomas Gleixner

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=20170612103631.GA6099@krava \
    --to=jolsa@redhat.com \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=eranian@google.com \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=vincent.weaver@maine.edu \
    /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