perf: Don't bother to init the hrtimer for no SW sampling counters
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1290525705-6265-3-git-send-email-fbuihuu@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
		
					parent
					
						
							
								2e939d1da9
							
						
					
				
			
			
				commit
				
					
						5d508e820a
					
				
			
		
					 1 changed files with 13 additions and 11 deletions
				
			
		| 
						 | 
					@ -4917,24 +4917,26 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer)
 | 
				
			||||||
static void perf_swevent_start_hrtimer(struct perf_event *event)
 | 
					static void perf_swevent_start_hrtimer(struct perf_event *event)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct hw_perf_event *hwc = &event->hw;
 | 
						struct hw_perf_event *hwc = &event->hw;
 | 
				
			||||||
 | 
						s64 period;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!is_sampling_event(event))
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 | 
						hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 | 
				
			||||||
	hwc->hrtimer.function = perf_swevent_hrtimer;
 | 
						hwc->hrtimer.function = perf_swevent_hrtimer;
 | 
				
			||||||
	if (is_sampling_event(event)) {
 | 
					 | 
				
			||||||
		s64 period = local64_read(&hwc->period_left);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (period) {
 | 
						period = local64_read(&hwc->period_left);
 | 
				
			||||||
			if (period < 0)
 | 
						if (period) {
 | 
				
			||||||
				period = 10000;
 | 
							if (period < 0)
 | 
				
			||||||
 | 
								period = 10000;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			local64_set(&hwc->period_left, 0);
 | 
							local64_set(&hwc->period_left, 0);
 | 
				
			||||||
		} else {
 | 
						} else {
 | 
				
			||||||
			period = max_t(u64, 10000, hwc->sample_period);
 | 
							period = max_t(u64, 10000, hwc->sample_period);
 | 
				
			||||||
		}
 | 
						}
 | 
				
			||||||
		__hrtimer_start_range_ns(&hwc->hrtimer,
 | 
						__hrtimer_start_range_ns(&hwc->hrtimer,
 | 
				
			||||||
				ns_to_ktime(period), 0,
 | 
									ns_to_ktime(period), 0,
 | 
				
			||||||
				HRTIMER_MODE_REL_PINNED, 0);
 | 
									HRTIMER_MODE_REL_PINNED, 0);
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void perf_swevent_cancel_hrtimer(struct perf_event *event)
 | 
					static void perf_swevent_cancel_hrtimer(struct perf_event *event)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue