mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	perf stat: Refactor __run_perf_stat() common code
This extracts common code from the branches of the forks if-then-else. enable_counters(), which was at the beginning of both branches of the conditional, is now unconditional; evlist__start_workload() is extracted to a different if, which enables making the common clocking code unconditional. Reviewed-by: Leo Yan <leo.yan@linaro.org> Signed-off-by: Adrián Herrera Arcila <adrian.herrera@arm.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Song Liu <songliubraving@fb.com> Link: https://lore.kernel.org/r/20220729161244.10522-1-adrian.herrera@arm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
		
							parent
							
								
									6d499a6b3d
								
							
						
					
					
						commit
						bb8bc52e75
					
				
					 1 changed files with 9 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -967,18 +967,18 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
 | 
			
		|||
			return err;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Enable counters and exec the command:
 | 
			
		||||
	 */
 | 
			
		||||
	if (forks) {
 | 
			
		||||
		err = enable_counters();
 | 
			
		||||
		if (err)
 | 
			
		||||
			return -1;
 | 
			
		||||
	err = enable_counters();
 | 
			
		||||
	if (err)
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	/* Exec the command, if any */
 | 
			
		||||
	if (forks)
 | 
			
		||||
		evlist__start_workload(evsel_list);
 | 
			
		||||
 | 
			
		||||
		t0 = rdclock();
 | 
			
		||||
		clock_gettime(CLOCK_MONOTONIC, &ref_time);
 | 
			
		||||
	t0 = rdclock();
 | 
			
		||||
	clock_gettime(CLOCK_MONOTONIC, &ref_time);
 | 
			
		||||
 | 
			
		||||
	if (forks) {
 | 
			
		||||
		if (interval || timeout || evlist__ctlfd_initialized(evsel_list))
 | 
			
		||||
			status = dispatch_events(forks, timeout, interval, ×);
 | 
			
		||||
		if (child_pid != -1) {
 | 
			
		||||
| 
						 | 
				
			
			@ -996,13 +996,6 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
 | 
			
		|||
		if (WIFSIGNALED(status))
 | 
			
		||||
			psignal(WTERMSIG(status), argv[0]);
 | 
			
		||||
	} else {
 | 
			
		||||
		err = enable_counters();
 | 
			
		||||
		if (err)
 | 
			
		||||
			return -1;
 | 
			
		||||
 | 
			
		||||
		t0 = rdclock();
 | 
			
		||||
		clock_gettime(CLOCK_MONOTONIC, &ref_time);
 | 
			
		||||
 | 
			
		||||
		status = dispatch_events(forks, timeout, interval, ×);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue