Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1704018

Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped events on mux interrupt

From Alexey Budankov <alexey.budankov@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped events on mux interrupt
Date 2017-08-04 16:30 +0200
Message-ID <uaLLX-89C-9@gated-at.bofh.it> (permalink)
References <u9X2N-7mD-15@gated-at.bofh.it> <u9X2O-7mD-25@gated-at.bofh.it> <uapVc-1If-91@gated-at.bofh.it> <uatm2-3Td-5@gated-at.bofh.it> <uaK3x-6XA-27@gated-at.bofh.it>
Organization Intel Corp.

Show all headers | View raw


On 04.08.2017 15:35, Peter Zijlstra wrote:
> On Thu, Aug 03, 2017 at 09:47:56PM +0300, Alexey Budankov wrote:
>> On 03.08.2017 18:00, Peter Zijlstra wrote:
> 
>>> Are the magic spots, right? And I'm not convinced its right.
>>>
>>> Suppose I have two events in my context, and I created them 1 minute
>>> apart. Then their respective tstamp_enabled are 1 minute apart as well.
>>> But the above doesn't seem to preserve that difference.
>>>
>>> A similar argument can be made for running I think. That is a per event
>>> value and cannot be passed along to the ctx and back.
>>
>> Aww, I see your point and it challenges my initial assumptions. 
>> Let me think thru the case more. There must be some solution. Thanks!
> 
> So the sensible thing is probably to rewrite the entire time tracking to
> make more sense. OTOH that's also the riskiest.
> 
> Something like:
> 
> __update_state_and_time(event, new_state)
> {
> 	u64 delta, now = perf_event_time(event);
> 	int old_state = event->state;
> 
> 	event->tstamp = now;
> 	event->state  = new_state;
> 
> 	delta = now - event->tstamp;
> 	switch (state) {
> 	case STATE_ACTIVE:
> 		WARN_ON_ONCE(old_state != STATE_INACTIVE);
> 		event->total_time_enabled += delta;
> 		break;
> 
> 	case STATE_INACTIVE:
> 		switch (old_state) {
> 		case STATE_OFF:
> 			/* ignore the OFF -> INACTIVE period */
> 			break;
> 
> 		case STATE_ACTIVE:
> 			event->total_time_enabled += delta;
> 			event->total_time_running += delta;
> 			break;
> 
> 		default:
> 			WARN_ONCE();
> 		}
> 		break;
> 
> 	case STATE_OFF:
> 		WARN_ON_ONCE(old_state != STATE_INACTIVE)
> 		event->total_time_enabled += delta;
> 		break;
> 	}
> }
> 
> __read_curent_times(event, u64 *enabled, u64 *running)
> {
> 	u64 delta, now = perf_event_time(event);
> 
> 	delta = now - event->tstamp;
> 
> 	*enabled = event->total_time_enabled;
> 	if (event->state >= STATE_INACTIVE)
> 		*enabled += delta;
> 	*running = event->total_time_running
> 	if (event->state == STATE_ACTIVE)
> 		*running += delta;
> }
> 
> perhaps? That instantly solves the problem I think, because now we don't
> need to update inactive events. But maybe I missed some, could you
> verify?

Thanks for the input. I will check it.

> 
> 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v6 0/3] perf/core: addressing 4x slowdown during per-process  profiling of STREAM benchmark on Intel Xeon Phi Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-02 10:20 +0200
  [PATCH v6 3/3]: perf/core: add mux switch to skip to the current  CPU's events list on mux interrupt Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-02 10:20 +0200
  [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped events  on mux interrupt Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-02 10:20 +0200
    Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped  events on mux interrupt Peter Zijlstra <peterz@infradead.org> - 2017-08-03 15:10 +0200
    Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped  events on mux interrupt Peter Zijlstra <peterz@infradead.org> - 2017-08-03 16:10 +0200
      Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped  events on mux interrupt Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-03 18:00 +0200
        Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped  events on mux interrupt Peter Zijlstra <peterz@infradead.org> - 2017-08-04 14:40 +0200
    Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped  events on mux interrupt Peter Zijlstra <peterz@infradead.org> - 2017-08-03 17:10 +0200
      Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped  events on mux interrupt Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-03 20:50 +0200
        Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped  events on mux interrupt Peter Zijlstra <peterz@infradead.org> - 2017-08-04 14:40 +0200
          Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped  events on mux interrupt Peter Zijlstra <peterz@infradead.org> - 2017-08-04 15:00 +0200
            Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped  events on mux interrupt Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-04 16:30 +0200
          Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped  events on mux interrupt Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-04 16:30 +0200
      Re: [PATCH v6 2/3]: perf/core: use context tstamp_data for skipped  events on mux interrupt Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-10 18:00 +0200
  [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-02 10:20 +0200
    Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Peter Zijlstra <peterz@infradead.org> - 2017-08-03 15:10 +0200
      Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-03 22:40 +0200
        Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Peter Zijlstra <peterz@infradead.org> - 2017-08-04 16:40 +0200
          Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-07 09:20 +0200
            Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Peter Zijlstra <peterz@infradead.org> - 2017-08-07 10:40 +0200
              Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Peter Zijlstra <peterz@infradead.org> - 2017-08-07 11:20 +0200
                Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-07 17:40 +0200
                Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Peter Zijlstra <peterz@infradead.org> - 2017-08-07 18:00 +0200
                Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-07 18:30 +0200
                Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Peter Zijlstra <peterz@infradead.org> - 2017-08-07 19:00 +0200
                Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Andi Kleen <ak@linux.intel.com> - 2017-08-07 19:50 +0200
                Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Peter Zijlstra <peterz@infradead.org> - 2017-08-07 20:20 +0200
                Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-07 20:20 +0200
        Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Peter Zijlstra <peterz@infradead.org> - 2017-08-04 17:00 +0200
          Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-08-07 17:30 +0200

csiph-web