From: Ingo Molnar <mingo@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Andi Kleen <andi@firstfloor.org>,
acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org,
Andi Kleen <ak@linux.intel.com>,
stable@vger.kernel.org, Andy Lutomirski <luto@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 1/5] x86, perf: Fix LBR call stack save/restore
Date: Wed, 21 Oct 2015 18:24:00 +0200 [thread overview]
Message-ID: <20151021162400.GA28914@gmail.com> (raw)
In-Reply-To: <20151021131310.GE3604@twins.programming.kicks-ass.net>
* Peter Zijlstra <peterz@infradead.org> wrote:
> > mask = x86_pmu.lbr_nr - 1;
> > - tos = intel_pmu_lbr_tos();
> > + tos = task_ctx->tos;
> > for (i = 0; i < tos; i++) {
> > lbr_idx = (tos - i) & mask;
> > wrmsrl(x86_pmu.lbr_from + lbr_idx, task_ctx->lbr_from[i]);
> > @@ -247,6 +247,7 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx)
> > if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
> > wrmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr_info[i]);
> > }
> > + wrmsrl(x86_pmu.lbr_tos, tos);
> > task_ctx->lbr_stack_state = LBR_NONE;
> > }
>
> Any idea who much more expensive that wrmsr() is compared to the rdmsr() it
> replaces?
>
> If its significant we could think about having this behaviour depend on
> callstacks.
The WRMSR extra cost is probably rather significant - here is a typical Intel
WRMSR vs. RDMSR (non-hardwired) cache-hot/cache-cold cost difference:
[ 170.798574] x86/bench: -------------------------------------------------------------------
[ 170.807258] x86/bench: | RDTSC-cycles: hot (±noise) / cold (±noise)
[ 170.816115] x86/bench: -------------------------------------------------------------------
[ 212.146982] x86/bench: rdtsc : 16 / 60
[ 213.725998] x86/bench: rdmsr : 100 / 148
[ 215.469958] x86/bench: wrmsr : 456 / 708
That's on a Xeon E7-4890 (22nm IvyBridge-EX).
So it's 350-550 RDTSC cycles ...
Thanks,
Ingo
WARNING: multiple messages have this Message-ID (diff)
From: Ingo Molnar <mingo@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Andi Kleen <andi@firstfloor.org>,
acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org,
Andi Kleen <ak@linux.intel.com>,
stable@vger.kernel.org, Andy Lutomirski <luto@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 1/5] x86, perf: Fix LBR call stack save/restore
Date: Wed, 21 Oct 2015 18:24:00 +0200 [thread overview]
Message-ID: <20151021162400.GA28914@gmail.com> (raw)
In-Reply-To: <20151021131310.GE3604@twins.programming.kicks-ass.net>
* Peter Zijlstra <peterz@infradead.org> wrote:
> > mask = x86_pmu.lbr_nr - 1;
> > - tos = intel_pmu_lbr_tos();
> > + tos = task_ctx->tos;
> > for (i = 0; i < tos; i++) {
> > lbr_idx = (tos - i) & mask;
> > wrmsrl(x86_pmu.lbr_from + lbr_idx, task_ctx->lbr_from[i]);
> > @@ -247,6 +247,7 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx)
> > if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
> > wrmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr_info[i]);
> > }
> > + wrmsrl(x86_pmu.lbr_tos, tos);
> > task_ctx->lbr_stack_state = LBR_NONE;
> > }
>
> Any idea who much more expensive that wrmsr() is compared to the rdmsr() it
> replaces?
>
> If its significant we could think about having this behaviour depend on
> callstacks.
The WRMSR extra cost is probably rather significant - here is a typical Intel
WRMSR vs. RDMSR (non-hardwired) cache-hot/cache-cold cost difference:
[ 170.798574] x86/bench: -------------------------------------------------------------------
[ 170.807258] x86/bench: | RDTSC-cycles: hot (�noise) / cold (�noise)
[ 170.816115] x86/bench: -------------------------------------------------------------------
[ 212.146982] x86/bench: rdtsc : 16 / 60
[ 213.725998] x86/bench: rdmsr : 100 / 148
[ 215.469958] x86/bench: wrmsr : 456 / 708
That's on a Xeon E7-4890 (22nm IvyBridge-EX).
So it's 350-550 RDTSC cycles ...
Thanks,
Ingo
next prev parent reply other threads:[~2015-10-21 16:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-20 18:46 [PATCH 1/5] x86, perf: Fix LBR call stack save/restore Andi Kleen
2015-10-20 18:46 ` [PATCH 2/5] x86, perf: Add option to disable reading branch flags/cycles Andi Kleen
2015-11-23 16:25 ` [tip:perf/core] perf/x86: " tip-bot for Andi Kleen
2015-10-20 18:46 ` [PATCH 3/5] perf, tools: Disable branch flags/cycles for --callgraph lbr Andi Kleen
2015-10-21 13:27 ` Peter Zijlstra
2015-10-21 18:04 ` Arnaldo Carvalho de Melo
2015-10-20 18:46 ` [PATCH 4/5] perf, tools: Print branch filter state with -vv Andi Kleen
2015-10-20 18:51 ` Arnaldo Carvalho de Melo
2015-10-21 8:27 ` Peter Zijlstra
2015-10-22 9:23 ` [tip:perf/core] perf evsel: " tip-bot for Andi Kleen
2015-10-20 18:46 ` [PATCH 5/5] x86, perf: Avoid context switching LBR_INFO when not needed Andi Kleen
2015-10-21 13:44 ` Peter Zijlstra
2015-10-21 13:13 ` [PATCH 1/5] x86, perf: Fix LBR call stack save/restore Peter Zijlstra
2015-10-21 14:35 ` Andi Kleen
2015-10-21 16:24 ` Ingo Molnar [this message]
2015-10-21 16:24 ` Ingo Molnar
2015-11-23 16:20 ` [tip:perf/core] perf/x86: " tip-bot for Andi Kleen
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=20151021162400.GA28914@gmail.com \
--to=mingo@kernel.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=andi@firstfloor.org \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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.