RE: [PATCH] perf/x86: fix event counter update issue

2017-02-23 Thread Liang, Kan
> > On Wed, 22 Feb 2017, Liang, Kan wrote: > > > > So from what I understand, the issue is if we have an architecture > > > with full- width counters and we trigger a x86_perf_event_update() > > > when bit > > > 47 is set? > > > > No. It related to the counter width. The number of bits we can us

RE: [PATCH] perf/x86: fix event counter update issue

2017-02-23 Thread Vince Weaver
On Wed, 22 Feb 2017, Liang, Kan wrote: > > So from what I understand, the issue is if we have an architecture with > > full- > > width counters and we trigger a x86_perf_event_update() when bit > > 47 is set? > > No. It related to the counter width. The number of bits we can use should be > 1 bi

Re: [PATCH] perf/x86: fix event counter update issue

2017-02-22 Thread Andi Kleen
> No. It related to the counter width. The number of bits we can use should be > 1 bit less than the total width. Otherwise, there will be problem. > For big cores such as haswell, broadwell, skylake, the counter width is 48 > bit. > So we can only use 47 bits. > For Silvermont and KNL, the counte

RE: [PATCH] perf/x86: fix event counter update issue

2017-02-22 Thread Liang, Kan
> > On Mon, 5 Dec 2016, Peter Zijlstra wrote: > > > --- > > Subject: perf,x86: Fix full width counter, counter overflow > > Date: Tue, 29 Nov 2016 20:33:28 + > > > > Lukasz reported that perf stat counters overflow is broken on KNL/SLM. > > > > Both these parts have full_width_write set, and

Re: [PATCH] perf/x86: fix event counter update issue

2017-02-22 Thread Vince Weaver
On Mon, 5 Dec 2016, Peter Zijlstra wrote: > --- > Subject: perf,x86: Fix full width counter, counter overflow > Date: Tue, 29 Nov 2016 20:33:28 + > > Lukasz reported that perf stat counters overflow is broken on KNL/SLM. > > Both these parts have full_width_write set, and that does indeed ha

RE: [PATCH] perf/x86: fix event counter update issue

2016-12-05 Thread Odzioba, Lukasz
On Monday, December 5, 2016 11:25 AM, Peter Zijlstra wrote: > I'll certainly, try. I've queued it as per the below. Great, thank you! Lukas

Re: [PATCH] perf/x86: fix event counter update issue

2016-12-05 Thread Peter Zijlstra
On Fri, Dec 02, 2016 at 12:58:17PM +, Odzioba, Lukasz wrote: > On Tuesday, November 29, 2016 9:33 PM, Liang, Kan wrote: > > Yes, the patch as below fixes the issue on my SLM. > > It works for me as well. > Can we still have it in 4.9? I'll certainly, try. I've queued it as per the below. --

RE: [PATCH] perf/x86: fix event counter update issue

2016-12-02 Thread Odzioba, Lukasz
On Tuesday, November 29, 2016 9:33 PM, Liang, Kan wrote: > Yes, the patch as below fixes the issue on my SLM. It works for me as well. Can we still have it in 4.9? Thanks, Lukas

Re: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Stephane Eranian
On Tue, Nov 29, 2016 at 12:33 PM, Liang, Kan wrote: > > >> On Tue, Nov 29, 2016 at 07:07:25PM +, Liang, Kan wrote: >> > > diff --git a/arch/x86/events/intel/core.c >> > > b/arch/x86/events/intel/core.c index a74a2dbc0180..cb8522290e6a >> > > 100644 >> > > --- a/arch/x86/events/intel/core.c >>

RE: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Liang, Kan
> On Tue, Nov 29, 2016 at 07:07:25PM +, Liang, Kan wrote: > > > diff --git a/arch/x86/events/intel/core.c > > > b/arch/x86/events/intel/core.c index a74a2dbc0180..cb8522290e6a > > > 100644 > > > --- a/arch/x86/events/intel/core.c > > > +++ b/arch/x86/events/intel/core.c > > > @@ -4034,7 +4034

Re: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Peter Zijlstra
On Tue, Nov 29, 2016 at 07:07:25PM +, Liang, Kan wrote: > > diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c > > index a74a2dbc0180..cb8522290e6a 100644 > > --- a/arch/x86/events/intel/core.c > > +++ b/arch/x86/events/intel/core.c > > @@ -4034,7 +4034,7 @@ __init int int

RE: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Odzioba, Lukasz
On Tuesday, November 29, 2016 6:20 PM Stephane Eranian wrote: >> On Tue, Nov 29, 2016 at 1:25 AM, Peter Zijlstra wrote: >> How can this happen? IIRC the thing increments, we program a negative >> value, and when it passes 0 we generate a PMI. >> > Yeah, that's the part I don't quite unders

RE: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Liang, Kan
> On Tue, Nov 29, 2016 at 09:20:10AM -0800, Stephane Eranian wrote: > > Max period is limited by the number of bits the kernel can write to an > MSR. > > Used to be 31, now it is 47 for core PMU as per patch pointed to by Kan. > > No, I think it sets it to 48 now, which is the problem. It should

Re: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Andi Kleen
On Tue, Nov 29, 2016 at 06:30:55PM +0100, Peter Zijlstra wrote: > On Tue, Nov 29, 2016 at 09:20:10AM -0800, Stephane Eranian wrote: > > Max period is limited by the number of bits the kernel can write to an MSR. > > Used to be 31, now it is 47 for core PMU as per patch pointed to by Kan. > > No, I

Re: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Stephane Eranian
On Tue, Nov 29, 2016 at 9:30 AM, Peter Zijlstra wrote: > On Tue, Nov 29, 2016 at 09:20:10AM -0800, Stephane Eranian wrote: >> Max period is limited by the number of bits the kernel can write to an MSR. >> Used to be 31, now it is 47 for core PMU as per patch pointed to by Kan. > > No, I think it s

Re: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Peter Zijlstra
On Tue, Nov 29, 2016 at 09:20:10AM -0800, Stephane Eranian wrote: > Max period is limited by the number of bits the kernel can write to an MSR. > Used to be 31, now it is 47 for core PMU as per patch pointed to by Kan. No, I think it sets it to 48 now, which is the problem. It should be 1 bit less

Re: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Stephane Eranian
On Tue, Nov 29, 2016 at 1:25 AM, Peter Zijlstra wrote: > > > So caveat that I'm ill and cannot think much.. > > On Mon, Nov 28, 2016 at 11:26:46AM -0800, kan.li...@intel.com wrote: > > > Here, all the possible failure cases are listed. > > Terms: > > - new: current PMU counter value which read

Re: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Peter Zijlstra
On Tue, Nov 29, 2016 at 05:06:36PM +, Liang, Kan wrote: > > > > On Tue, Nov 29, 2016 at 02:46:14PM +, Liang, Kan wrote: > > > > And note that we _ALWAYS_ set the IN bits, even for !sampling events. > > > > Also note we set max_period to (1<<31) - 1, so we should never > > > > exceed 31 bi

RE: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Liang, Kan
> On Tue, Nov 29, 2016 at 02:46:14PM +, Liang, Kan wrote: > > > And note that we _ALWAYS_ set the IN bits, even for !sampling events. > > > Also note we set max_period to (1<<31) - 1, so we should never > > > exceed 31 bits. > > > > > > > The max_period is 0xf. > > > > The limit is br

Re: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Peter Zijlstra
On Tue, Nov 29, 2016 at 02:46:14PM +, Liang, Kan wrote: > > And note that we _ALWAYS_ set the IN bits, even for !sampling events. > > Also note we set max_period to (1<<31) - 1, so we should never exceed 31 > > bits. > > > > The max_period is 0xf. > > The limit is breaked by this pat

RE: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Liang, Kan
> So caveat that I'm ill and cannot think much.. > > On Mon, Nov 28, 2016 at 11:26:46AM -0800, kan.li...@intel.com wrote: > > > Here, all the possible failure cases are listed. > > Terms: > > - new: current PMU counter value which read from rdpmcl. > > - prev: previous counter value whi

Re: [PATCH] perf/x86: fix event counter update issue

2016-11-29 Thread Peter Zijlstra
So caveat that I'm ill and cannot think much.. On Mon, Nov 28, 2016 at 11:26:46AM -0800, kan.li...@intel.com wrote: > Here, all the possible failure cases are listed. > Terms: > - new: current PMU counter value which read from rdpmcl. > - prev: previous counter value which is stored in &

RE: [PATCH] perf/x86: fix event counter update issue

2016-11-28 Thread Liang, Kan
> >> > Case B: In PMI. new > prev. delta is positive. > >> >That's the failure case of Test 3. > >> >The PMI is triggered by overflow. But there is latency between > >> >overflow and PMI handler. So new has small amount. > >> >Current calculation lose the max count value. > >> > >

Re: [PATCH] perf/x86: fix event counter update issue

2016-11-28 Thread Stephane Eranian
On Mon, Nov 28, 2016 at 11:59 AM, Liang, Kan wrote: > > >> > >> > Here, all the possible failure cases are listed. >> > Terms: >> > - new: current PMU counter value which read from rdpmcl. >> > - prev: previous counter value which is stored in &hwc->prev_count. >> > - in PMI/not in PMI

RE: [PATCH] perf/x86: fix event counter update issue

2016-11-28 Thread Liang, Kan
> > > > Here, all the possible failure cases are listed. > > Terms: > > - new: current PMU counter value which read from rdpmcl. > > - prev: previous counter value which is stored in &hwc->prev_count. > > - in PMI/not in PMI: the event update happens in PMI handler or not. > > Current

Re: [PATCH] perf/x86: fix event counter update issue

2016-11-28 Thread Stephane Eranian
On Mon, Nov 28, 2016 at 11:26 AM, wrote: > > From: Kan Liang > > Fixes: ec3232bdf851 ("perf_counter: x86: More accurate counter update") > > A bug can be easily reproduced by perf stat loop program on KNL/SLM. > The loop program is just "for (i=0;i "loops" is set to different value during the tes

[PATCH] perf/x86: fix event counter update issue

2016-11-28 Thread kan . liang
From: Kan Liang Fixes: ec3232bdf851 ("perf_counter: x86: More accurate counter update") A bug can be easily reproduced by perf stat loop program on KNL/SLM. The loop program is just "for (i=0;iprev_count. - in PMI/not in PMI: the event update happens in PMI handler or not. Current code to ca